Accessing a method in the Dlg object from the App object.
-
I have an MFC Dlg Application. Say the project is called Test. Visual Studio creates a TestDlg.cpp and a Test.cpp among others. I am finding that some initialization that i need to do in the Test.cpp involves me having to have access to a variable in the TestDlg.cpp. I cannot do a static cast of the TestDlg.cpp can I?
-
I have an MFC Dlg Application. Say the project is called Test. Visual Studio creates a TestDlg.cpp and a Test.cpp among others. I am finding that some initialization that i need to do in the Test.cpp involves me having to have access to a variable in the TestDlg.cpp. I cannot do a static cast of the TestDlg.cpp can I?
Before calling the dialog's
DoModal()
method, you can access the dialog's public members."Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I have an MFC Dlg Application. Say the project is called Test. Visual Studio creates a TestDlg.cpp and a Test.cpp among others. I am finding that some initialization that i need to do in the Test.cpp involves me having to have access to a variable in the TestDlg.cpp. I cannot do a static cast of the TestDlg.cpp can I?
"Test.cpp" is where your
CTestApp
implementation is. "TestDlg.cpp" is where your main dialog windowCTestDlg
implementation is. In "Test.cpp", there is the functionCTestApp::InitInstance
. Inside this function body, you can see the variable// ...
CTestDlg dlg;
dlg.DoModal();
// ...So you can do initialization like this:
// ...
CTestDlg dlg;
dlg.InitMyMemberValues();
dlg.DoModal();
// ...Maxwell Chen
-
"Test.cpp" is where your
CTestApp
implementation is. "TestDlg.cpp" is where your main dialog windowCTestDlg
implementation is. In "Test.cpp", there is the functionCTestApp::InitInstance
. Inside this function body, you can see the variable// ...
CTestDlg dlg;
dlg.DoModal();
// ...So you can do initialization like this:
// ...
CTestDlg dlg;
dlg.InitMyMemberValues();
dlg.DoModal();
// ...Maxwell Chen
-
LCI wrote:
Is this the same way of thinking for a View application as opposed to a dlg based?
This is the C++ object-oriented way. :-D
Maxwell Chen
-
LCI wrote:
Is this the same way of thinking for a View application as opposed to a dlg based?
This is the C++ object-oriented way. :-D
Maxwell Chen
What i mean is in a dlg based app we have: CTestDlg dlg; dlg.DoModal(); in the initistance. What is the equivalent for a Single or multiple document based application? In other words , the same original question,just applied to a single or multi0ple document based app instead of a dlg based?
-
I have an MFC Dlg Application. Say the project is called Test. Visual Studio creates a TestDlg.cpp and a Test.cpp among others. I am finding that some initialization that i need to do in the Test.cpp involves me having to have access to a variable in the TestDlg.cpp. I cannot do a static cast of the TestDlg.cpp can I?
not sure if it's really related to your problem, but have a look at this article[^] anyway...
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
What i mean is in a dlg based app we have: CTestDlg dlg; dlg.DoModal(); in the initistance. What is the equivalent for a Single or multiple document based application? In other words , the same original question,just applied to a single or multi0ple document based app instead of a dlg based?
After the view object has been created, you can access its
public
members."Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I have an MFC Dlg Application. Say the project is called Test. Visual Studio creates a TestDlg.cpp and a Test.cpp among others. I am finding that some initialization that i need to do in the Test.cpp involves me having to have access to a variable in the TestDlg.cpp. I cannot do a static cast of the TestDlg.cpp can I?
LCI wrote:
I have an MFC Dlg Application. Say the project is called Test. Visual Studio creates a TestDlg.cpp and a Test.cpp among others. I am finding that some initialization that i need to do in the Test.cpp involves me having to have access to a variable in the TestDlg.cpp. I cannot do a static cast of the TestDlg.cpp can I?
I would add a CTestDlg member variable to CTestApp and change InitInstance to use that instead of one local to InitInstance. Nathan