(
Figure 1-1.The Visual C++ MFC application build process. in 《inside vc.net》)
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、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、If you want to change data between a control and a variable, here are three ways as
follow:
(1):DDX_Control(……)
……
(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