How to pass datas to a modal dialog?
-
The snippets as follows: CAboutDlg dlg; dlg.DoModal(); Now,how to pass data to the modal dialog,for example modify the title of the modal dialog.Thx!
I am not a genius, but shed more sweat!
Override
OnInitDialog
and change any values there. If you need the values to be set before instantiating the dialog then add class members and set their values when you first create the dialog object.txtspeak is the realm of 9 year old children, not developers. Christian Graus
-
The snippets as follows: CAboutDlg dlg; dlg.DoModal(); Now,how to pass data to the modal dialog,for example modify the title of the modal dialog.Thx!
I am not a genius, but shed more sweat!
You could extend the constructor of the dialog to accept the passed parameter(s) by dialogs member(s). As Richard said, all visual things should be apllied at
OnInitDialog()
, as them_hWnd
is already valid, for example:if (m_cszPassedTitle.GetLength()) {
SetWindowText(m_cszPassedTitle);
}Check your definition of Irrationality[^] :) 1 - Avicenna 5 - Hubbard 3 - Own definition
-
The snippets as follows: CAboutDlg dlg; dlg.DoModal(); Now,how to pass data to the modal dialog,for example modify the title of the modal dialog.Thx!
I am not a genius, but shed more sweat!
The other alternative to the above suggestions, is that you define your own message, and use that to signal to your child window that you've got some data for it. I use the following code to pass an image to a child window. IDC_COPYIMAGE is the message I defined. (#define IDC_COPYIMAGE 1010) There just needs to be an appropriate handler in the windowproc for the child dialog.
if (myWad.getLumpSize(myItem.iItem) == 4096)
{
flatData = (char*)myWad.loadResource(resNum, &resLen);
pal = (char*) myWad.loadResource(195, &resLen);
darkMap = (char*) myWad.loadResource(1, &resLen);
tmpImg = createImageFromFlat(flatData, pal, darkMap);
delete pal;
delete flatData;
delete darkMap;
SendMessage(imgChildHWND, IDC_COPYIMAGE, 0, (LPARAM)tmpImg);
DeleteObject(tmpImg);
}