Home > Software engineering >  MFC dialog box of a question
MFC dialog box of a question

Time:09-17

I just learning MFC, wash the dishes today think encountered a problem during the day, although solved after baidu, but thought still have a question, this is not very relevant questions and questions in the morning, but she also related problems are abstract, I don't know if I can't describe clearly, I as far as possible, so
Learn MFC before I took a look at the basic knowledge of c + +, we typically see in c + + function form is such a
Class A {
...//member functions and data members
};
Int main () {
A, A.
return 1;
}
Are generally in this form, when we create A class, does not occupy memory space, only after the class is instantiated memory space, also A have this sentence is A object A will take up memory space,
But in MFC, I built a project, and then set up step by step, at the same time, the middle one step I checked is based on the dialog box, after setting, system will automatically generate a main dialog box, and then on the left is an app. CPP and a DLG. CPP, there are various. H file and some resource file, I write programs are * * * DLG. CPP to add all kinds of code, that is to say, I just in this kind of * * * DLG for various operation,
I doubt who system generated when the dialog is created, I think should have a similar to the above such a * * * DLG; Code to create dialog, otherwise how to generate the dialog box, lead me in the morning of a problem, I am in the class in a static function to access a non-static function, I will need to use the object name. Functions such access, but the main dialog box I don't know who is created, how do I use the object name to access and use professional terms is to obtain the meaning of the pointer to the parent window,
Say so many, do not know to have understand, still hope the great god glad to try to speak the full

CodePudding user response:

"Who is this dialog system generated created" dialog main dialog is created by the MFC project, with the CWnd * AfxGetMainWnd ();

Get

CodePudding user response:

The
CxxxDlg * pDlg=(CxxxDlg *) AfxGetMainWnd ();

CodePudding user response:

App based on dialog, pay attention to the App class InitInstance

CodePudding user response:

"I think that there is a similar to the above such a * * * DLG;" Your understanding is correct, just didn't find a place to see,
This thing on the App have code in your InitInstance function embodied in the class

CodePudding user response:

see MFC automatically created app DLG that a few classes

CodePudding user response:

System guide to help you create

CodePudding user response:

Look at your App InitInstance function of a class ~

CodePudding user response:

reference 4 floor sichuanwww response:
"I think should have a similar to the above such a * * * DLG;" Your understanding is correct, just didn't find a place to see,
The east east the InitInstance function of the code inside the App class reflect
thank you, I see, but there is still a doubt, in the App. CPP in InitInstance see this code, * * * Dlg Dlg; That is the main dialog box is the objects created by the DLG, but the local object is created, is not a global object, I think in DLG. One of the CPP access non-static function under the static functions, such as I think DLG. SetDlgItemText () no, because is not a global object

CodePudding user response:

SetDlgItemText (AfxGetMainWnd () - & gt; IDC_XXXX GetSafeHwnd (), TEXT (" "));

CodePudding user response:

Ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha

CodePudding user response:

This dialog is automatically created, MFC framework in the App class InitInstance function call code,

At the same time, the static function can't calling non-static functions or variables
  • Related