Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting the main dialog in MFC

127 views
Skip to first unread message

Gordon Jeffrey

unread,
Sep 1, 2004, 7:08:36 AM9/1/04
to
Is the a function to get the main dialog similar the the
::AfxGetMainWnd() to get the main window?

Scott McPhillips [MVP]

unread,
Sep 1, 2004, 9:18:40 AM9/1/04
to
Gordon Jeffrey wrote:

> Is the a function to get the main dialog similar the the
> ::AfxGetMainWnd() to get the main window?

If you are talking about the standard wizard-generated dialog based
application the the main dialog IS the main window. AfxGetMainWnd()
will return a pointer to it, which you must cast into a pointer to your
main dialog class.

CMyMainDlg* pmain = (CMyMainDlg*)AfxGetMainWnd();

--
Scott McPhillips [VC++ MVP]

M. Kools

unread,
Sep 1, 2004, 8:20:01 AM9/1/04
to
Just AfxGetMainWnd() ? It'll return a CWnd pointer to your main window.
Or do you mean in the WinAPI?

Gordon Jeffrey wrote:
> Is the a function to get the main dialog similar the the
> ::AfxGetMainWnd() to get the main window?

--
Maarten Kools
___________________________________________
Van Gennep - Media Automation Consulting bv
Burg. Stramanweg 105
1101 AA Amsterdam
The Netherlands

Phone: +31-20-697 6029
Fax: +31-20-697 2249
E-mail: mko...@vangennep.nl
WWW: http://www.vangennep.nl
WWW: http://www.vangennep.com
___________________________________________

Joseph M. Newcomer

unread,
Sep 1, 2004, 10:54:46 AM9/1/04
to
I'm not sure what you mean by "main dialog". If you mean you have a dialog-based app, then
a dialog, being of course a window, and being used as the main window, will be what you
get when you call AfxGetMainWnd(). The call doesn't care about what type of window it is,
a CMainFrame or a CDialog-derived, so in either case you have a "main window".
joe

On 1 Sep 2004 04:08:36 -0700, gordonj...@hotmail.com (Gordon Jeffrey) wrote:

>Is the a function to get the main dialog similar the the
>::AfxGetMainWnd() to get the main window?

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

0 new messages