]]>The relation between MFC class and Resourcehttp://m.shnenglu.com/citywanderer/articles/9170.htmlcitywanderercitywandererThu, 29 Jun 2006 10:14:00 GMThttp://m.shnenglu.com/citywanderer/articles/9170.htmlhttp://m.shnenglu.com/citywanderer/comments/9170.htmlhttp://m.shnenglu.com/citywanderer/articles/9170.html#Feedback0http://m.shnenglu.com/citywanderer/comments/commentRss/9170.htmlhttp://m.shnenglu.com/citywanderer/services/trackbacks/9170.html (Figure 1-1.The Visual C++ MFC application build process. in 《inside vc.net?/span>) From Figure1.1 above, we can see that resource.h is the bridge between MFC files and Resource file. Any an ID value in resource.h corresponds to a control. 1?/strong>If haven't Resouce file, we can also create a control by Create function. For instance: //in .h file CButton m_nRTButton; //in OnInitDialog() function m_nRTButton.Create("RunTime", WS_CHILD|WS_VISIBLE|BS_AUTO3STATE, CRect(0,0,100,20), this, 100);
virtual BOOLCreate ( LPCTSTRlpszCaption, DWORDdwStyle, constRECT&rect, CWnd*pParentWnd, UINTnID ); nID can be any number if you will use it later, otherwise, the id number may conflict with others. 2?/strong>If you want to change data between a control and a variable, here are three ways as follow: (1):DDX_Control(…? …?br />(2):object = (Class*)GetDlgItem(nID) The class must derive from CWND, and the data flow just from variable to control i think (3):Create(…? CButton m_nRTButton; m_nRTButton.Create("RunTime", WS_CHILD|WS_VISIBLE|BS_AUTO3STATE, CRect(0,0,100,20), this, 100); as above. (4):create an object of the class corresponding to a resource. Of cource if you want to generate a modeless dialog, you must use Create function, otherwise , you can
]]>Start my network program with winpcap using C++http://m.shnenglu.com/citywanderer/articles/8868.htmlcitywanderercitywandererFri, 23 Jun 2006 03:14:00 GMThttp://m.shnenglu.com/citywanderer/articles/8868.htmlhttp://m.shnenglu.com/citywanderer/comments/8868.htmlhttp://m.shnenglu.com/citywanderer/articles/8868.html#Feedback0http://m.shnenglu.com/citywanderer/comments/commentRss/8868.htmlhttp://m.shnenglu.com/citywanderer/services/trackbacks/8868.html
]]>Windows message categorieshttp://m.shnenglu.com/citywanderer/articles/8685.htmlcitywanderercitywandererSun, 18 Jun 2006 06:19:00 GMThttp://m.shnenglu.com/citywanderer/articles/8685.htmlhttp://m.shnenglu.com/citywanderer/comments/8685.htmlhttp://m.shnenglu.com/citywanderer/articles/8685.html#Feedback0http://m.shnenglu.com/citywanderer/comments/commentRss/8685.htmlhttp://m.shnenglu.com/citywanderer/services/trackbacks/8685.htmlThere are three main categories: 1、Command message: This includes WM_COMMAND notification messages from user-interface objects: menus, toolbar buttons, and accelerator keys.(digested from msdn) for example: Add click event handler to menuitem about, the MFC generate automatically three lines code( macro definition: ON_COMMAND(ID_HELP_ABOUT, OnAbout) in .cpp file , event handle function: void CCapturePacketDlg::OnAbout() in .cpp file, and event handle function's declaration: void OnAbout() in .h file), the macro ON_COMMAND(ID_HELP_ABOUT, OnAbout) depresent: { WM_COMMAND, CN_COMMAND, (WORD)id, (WORD)id, AfxSigCmd_v, static_cast<AFX_PMSG> (memberFxn) }, among therm, WM_COMMAND is message id, and is also Command message. 2、Windows messages This includes primarily those messages beginning with the WM_ prefix, except for WM_COMMAND. Windows messages are handled by windows and views. These messages often have parameters that are used in determining how to handle the message.(digested by msdn) for example: Add event handle function OnHotkey() witch responds to Alt + F5 to show or hide the main window. I don't kown how use MFC to add the event code automatically, so i add code into three places( macro definition: ON_MESSAGE(WM_HOTKEY, OnHotkey) in .cpp file , event handle function: LRESULT CCapturePacketDlg::OnHotkey(WPARAM wp,LPARAM lp) in .cpp file, and event handle function's declaration: LRESULT OnHotkey(WPARAM wp,LPARAM lp) in .h file). But how does the application responde to Alt + F5? we must register the hot key, so i can call API RegisterHotKey in my dialog class's OnInitDialog function. 3、Control notifications Sorry, so far, i have used it.