1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
   | #include <owl/pch.h>
#include <owl/applicat.h>
#include <owl/framewin.h>
#include <owl/dc.h>
#include <string.h>
#include <owl/controlb.h>
#include <owl/statusba.h>
#include <owl/messageb.h>
#include <owl/textgadg.h>
#include <owl/gdiobjec.h>
#include <owl/buttonga.h>
class TDrawWindow : public TWindow {
  public:
    TDrawWindow(TWindow* parent=0);
    protected:
    // Override member function of TWindow
    bool CanClose();
    void fileNew();
    void langFranc();
    void langAng();
    TPopupMenu menu_fl;
    void EvRButtonDown(uint modKeys, TPoint& point);
    void EvMouseMove(uint modKeys, TPoint& point);
    DECLARE_RESPONSE_TABLE(TDrawWindow);
};
DEFINE_RESPONSE_TABLE1(TDrawWindow, TWindow)
	EV_WM_RBUTTONDOWN,
   EV_WM_MOUSEMOVE,
	EV_COMMAND(202, langFranc),
	EV_COMMAND(203, langAng),
END_RESPONSE_TABLE;
TDrawWindow::TDrawWindow(TWindow* parent)
{
	Init(parent, 0, 0);
	SetBkgndColor(TColor::LtBlue) ;
	menu_fl.AppendMenu(MF_STRING, 202, "Français");
   menu_fl.AppendMenu(MF_STRING, 203, "Anglais");
 }
bool
TDrawWindow::CanClose()
{
	return MessageBox("Voulez-vous quitter ?", "Fermeture de l'application",
                    MB_YESNO | MB_ICONQUESTION) == IDYES;
}
void
    TDrawWindow::EvRButtonDown(uint , TPoint& point){
    ClientToScreen(point);
     menu_fl.TrackPopupMenu(TPM_LEFTBUTTON, point, 0,*this );
}
void
    TDrawWindow::EvMouseMove(uint , TPoint& point){
    point=point;
    //sb->SetText("mouse moving");
    }
void
TDrawWindow::fileNew(){
	TClientDC dc(*this);
	char s[2]={'a','b'};
   dc.TextOut(0,0, s);
}
void
TDrawWindow::langFranc() {
	GetApplication()->MainWindow->AssignMenu(2);
   MessageBox("Vous Avez Choisi Le Francais", "Langue Choisie",
                    MB_OK );
}
void
TDrawWindow::langAng() {
	GetApplication()->MainWindow->AssignMenu(1);
     MessageBox("Vous Avez Choisi L'Anglais", "Langue Choisie",
                    MB_OK );
}
class MonTApplication : public TApplication {
  public:
    MonTApplication() : TApplication() {}
    void InitMainWindow()
    {
    TDecoratedFrame* frame = new TDecoratedFrame(0, "Barre d'etat", new TDrawWindow, true);
    TStatusBar* sb = new TStatusBar(frame, TGadget::Recessed);
    frame->Insert(*sb, TDecoratedFrame::Bottom);
    sb->SetText("Allah Akbar :-)");
    TControlBar* cb = new TControlBar(frame);
  cb->Insert(*new TButtonGadget(202,202));
 frame->Insert(*cb, TDecoratedFrame::Top);
              SetMainWindow(frame);
        MainWindow->AssignMenu(1);
    }
};
int
OwlMain(int , char* [])
{
  return MonTApplication().Run();
} | 
Partager