/** Esimerkki Windowsin viestien suorasta käsittelystä C++ Builderin VCL- sovelluksessa, vrt hellounit.pas ja mhello.c Miika Nurminen, 4.6.2004 */ #ifndef hellounitppH #define hellounitppH //--------------------------------------------------------------------------- #include #include #include #include //--------------------------------------------------------------------------- class TFormHello : public TForm { __published: // IDE-managed Components private: // User declarations void __fastcall OnPaint(TWMPaint* Message) { PAINTSTRUCT ps; if ( BeginPaint(this->Handle,&ps) ) TextOut(ps.hdc, 10, 10, "Hello World!",12); EndPaint(this->Handle,&ps); } void __fastcall OnClose(TWMClose* Message) { if (MessageBox(this->Handle,"Lopetetaanko?","WHello",MB_YESNO)==IDYES) DestroyWindow(this->Handle); } void __fastcall OnDestroy(TWMDestroy* Messge) { PostQuitMessage(0); } //MFC-tyyliä VCL-sovelluksessa :D BEGIN_MESSAGE_MAP MESSAGE_HANDLER(WM_PAINT, TWMPaint*, OnPaint) MESSAGE_HANDLER(WM_CLOSE, TWMClose*, OnClose) MESSAGE_HANDLER(WM_DESTROY, TWMDestroy*, OnDestroy) END_MESSAGE_MAP(TForm) public: // User declarations __fastcall TFormHello(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TFormHello *FormHello; //--------------------------------------------------------------------------- #endif