Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,


In Dialog Base Application, if i call DoModal and UpdateData(TRUE) or (FALSE),what are the functions are getting called internally?.

for example:

CEdit m_strString;

In OnInitDialog, if i call UpdateData(FALSE) and what ever the data is initializing into m_strString that value is updated into edit control. If i won't use UpdateData(FALSE) means, the value is not updating.here what is happening?

void classname::OnInitDialog()
{

m_strString = "test_value";
UpdateData(FALSE);

return TRUE;
}


by default return type is TRUE in OnInitDialog, if i changed to FALSE, then what happen?.

what are all the functions are getting called?.

regards,
ranjith
Posted

1 solution

Your example is wrong: Your m_strString variable is of type CEdit but it is used as CString.

You should read about Dialog Data Exchange[^] (DDX).

If you don't want to use DDX, add member variables of your control types and call the appropiate functions to set and get the values from within OnInitDialog (SetWindowText for CEdit) and OnOK (GetWindowText for CEdit).

See the MSDN for OnInitDialog[^] about the return value:
Quote:
Specifies whether the application has set the input focus to one of the controls in the dialog box. If OnInitDialog returns nonzero, Windows sets the input focus to the default location, the first control in the dialog box. The application can return 0 only if it has explicitly set the input focus to one of the controls in the dialog box.

[UPDATE]
The default implementation of OnInitDialog will call UpdateData(FALSE). So you don't have to call it yourself when initializing your control member variables before calling the base class function CDialog::OnInitDialog (which is missing in your example).
 
Share this answer
 
v2
Comments
ranjithkumar81 3-Mar-14 2:55am    
ok,

If i create a modal dialog using DoModal(), what are the functions are called internally.
Jochen Arndt 3-Mar-14 3:15am    
Many functions will be called.

In Visual Studio click right on the DoModal() function call, select 'Goto definition', and select CDialog::DoModal(). Then you will see the MFC source code for the selected function. You can use the same method to see the source of other MFC functions. For non MFC functions (e.g. Windows API functions beginning with '::'), press F1 when the cursor is on the function name to get information about the function. So you can step through the functions called internally.

I just noted another error in your example (you are not calling the base class version of OnInitDialog). I will update my answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900