]]>The relation between MFC class and Resourcehttp://www.shnenglu.com/citywanderer/articles/9170.htmlcitywanderercitywandererThu, 29 Jun 2006 10:14:00 GMThttp://www.shnenglu.com/citywanderer/articles/9170.htmlhttp://www.shnenglu.com/citywanderer/comments/9170.htmlhttp://www.shnenglu.com/citywanderer/articles/9170.html#Feedback0http://www.shnenglu.com/citywanderer/comments/commentRss/9170.htmlhttp://www.shnenglu.com/citywanderer/services/trackbacks/9170.html 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 (Figure 1-1.The Visual C++ MFC application build process. in 銆奿nside 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://www.shnenglu.com/citywanderer/articles/8868.htmlcitywanderercitywandererFri, 23 Jun 2006 03:14:00 GMThttp://www.shnenglu.com/citywanderer/articles/8868.htmlhttp://www.shnenglu.com/citywanderer/comments/8868.htmlhttp://www.shnenglu.com/citywanderer/articles/8868.html#Feedback0http://www.shnenglu.com/citywanderer/comments/commentRss/8868.htmlhttp://www.shnenglu.com/citywanderer/services/trackbacks/8868.html
]]>.Net2005涓」鐩伐紼嬬殑閰嶇疆http://www.shnenglu.com/citywanderer/articles/8786.htmlcitywanderercitywandererWed, 21 Jun 2006 08:06:00 GMThttp://www.shnenglu.com/citywanderer/articles/8786.htmlhttp://www.shnenglu.com/citywanderer/comments/8786.htmlhttp://www.shnenglu.com/citywanderer/articles/8786.html#Feedback0http://www.shnenglu.com/citywanderer/comments/commentRss/8786.htmlhttp://www.shnenglu.com/citywanderer/services/trackbacks/8786.html榪欓噷浠ャ婃繁鍏ユ祬鍑篗FC銆嬩腑鐨刪ello紼嬪簭涓轟緥銆?br />1銆佸垱寤轟竴涓狦eneral鐨勭┖欏圭洰銆?br />2銆佸皢鍚庣紑涓?RC銆?H銆?CPP銆?ICO鐨勬枃浠禼opy鍒版柊寤虹洰褰曚笅銆?br />3銆佸皢榪欎簺鏂囦歡娣誨姞鍒皃roject涓幓銆?br />4銆佸湪Project-銆塒roperties-銆塁onfigurationProperties-銆塋inker-銆塖ystem-銆塖ubsystem涓夋嫨Windows錛?Subsystem錛歐indows錛夈傦紙濡傛灉榪欓噷娌℃湁淇敼浼氫駭鐢熻繖鏍風(fēng)殑閿欒錛欵rror聽1聽error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup聽libcmt.lib聽錛屾墍鏈夌▼搴忓寘鎷瑆indow銆乧onsole絳夌瓑閮芥槸浠巁tmainCRTStartup鍑芥暟鍚姩鐨勶紝婧愪唬鐮佸彲瑙佲︹Microsoft Visual Studio 8\VC\crt\src\crt0.c Line94錛岀▼搴忎笉鍚宊tmainCRTStartup鐨勫畾涔変篃涓嶅悓銆傦級
]]>Windows message categorieshttp://www.shnenglu.com/citywanderer/articles/8685.htmlcitywanderercitywandererSun, 18 Jun 2006 06:19:00 GMThttp://www.shnenglu.com/citywanderer/articles/8685.htmlhttp://www.shnenglu.com/citywanderer/comments/8685.htmlhttp://www.shnenglu.com/citywanderer/articles/8685.html#Feedback0http://www.shnenglu.com/citywanderer/comments/commentRss/8685.htmlhttp://www.shnenglu.com/citywanderer/services/trackbacks/8685.htmlThere are three main categories: 1銆丆ommand 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銆乄indows 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銆丆ontrol notifications Sorry, so far, i have used it.