Hello to all !!!
I'm fairly new to MFC programming and I was wondering how can I reference my main window controls when i'm within a modal dialog box ???
Any help would be greatly appreciated :)
Happy coding =:-)
Printable View
Hello to all !!!
I'm fairly new to MFC programming and I was wondering how can I reference my main window controls when i'm within a modal dialog box ???
Any help would be greatly appreciated :)
Happy coding =:-)
You can try using AfxGetMainWnd, this should return your mainframe window.
-Safai
Hummm thanx for the answer but it didn't help very much... After getting the CWnd pointer to the main window how can refer to the controls in it ??? i.e I have a CListBox name lst...
thanx in advance :)
Well, you can cast your "CMainFrame" to the CWnd you got from AfxGetMainWnd. Then you can access the controls inside it, assuming you have member variables of those controls.
CMainFrame *pMainFrame = (CMainFrame*)AfxGetMainWnd();
pMainFrame->m_listbox.AddString("item1");
You can do this cast because you know for sure that the main window returned from AfxGetMainWnd is always of the type CMainFrame. (or whatever you set in CWinApp::InitInstance throught CWinApp::m_pMainWnd variable)
-Safai
Thank you very much... It works wonderfully :)