1 #pragmaOnce2#include <UIlib.h>3 using namespaceDuilib;4 5 #ifdef _DEBUG6 # ifdef _unicode7# pragma comment (lib,"Duilib_ud.lib")8#Else9# pragma comment (lib,"Duilib_d.lib")Ten # endif One #else A # ifdef _unicode -# pragma comment (lib,"Duilib_u.lib") -#Else the# pragma comment (lib,"DuiLib.lib") - # endif - #endif - + classCduiframewnd: PublicCwindowwnd, PublicInotifyui - { + Public: A VirtualLPCTSTR Getwindowclassname ()Const{return_t ("Duimainframe"); } at Virtual voidNotify (tnotifyui&msg) - { - if(Msg.stype = = _t ("Click")) - { - if(Msg.psender->getname () = = _t ("Btnhello")) - { in:: MessageBox (NULL, _t ("I'm the button ."), _t ("Click the button"), NULL); - } to } + } - the VirtualLRESULT handlemessage (UINT umsg, WPARAM WPARAM, LPARAM LPARAM) * { $LRESULT lres =0;Panax Notoginseng - if(umsg = =wm_create) the { +Ccontrolui *pwnd =NewCbuttonui; APwnd->setname (_t ("Btnhello"));//Sets the name of the control, which is used to identify each control and must be unique, equivalent to the control ID in MFC thePwnd->settext (_t ("Hello World"));//Set Text +Pwnd->setbkcolor (0xff00ff00);//Set Background color - $ M_paintmanager.init (m_hwnd); $ M_paintmanager.attachdialog (pWnd); -M_paintmanager.addnotifier ( This);//Add a message response such as a control, so that the message will be communicated to the DUILIB message loop, we can do the message processing in the Notify function - returnLres; the } - Wuyi if(M_paintmanager.messagehandler (umsg, WParam, LParam, lres)) the { - returnLres; Wu } - About return__super::handlemessage (umsg, WParam, LParam); $ } - - protected: - Cpaintmanagerui M_paintmanager; A }; + the intApientry _tWinMain (hinstance hinstance, hinstance hprevinstance, LPTSTR lpCmdLine,intncmdshow) - { $ cpaintmanagerui::setinstance (hinstance); the the Cduiframewnd Duiframe; theDuiframe.create (NULL, _t ("Duiwnd"), Ui_wndstyle_frame, Ws_ex_windowedge); the Duiframe.showmodal (); - return 0; in}
Duilib Learning Three-response button