Re: MFC and User Defined objects
one-trick-pony wrote:
Hello,
The DoModal function runs in MFC generated class CDummyApp in
InitInstance().
BOOL CDummyDlg::OnInitDialog()
{
...
How do I get window handle here? What function and coding will allow
me to get the window handle?
HWND hDummy = m_hWnd;
m_hWnd is a member variable of CWnd. CDummyDlg is a CWnd, so it
inherits the m_hWnd.
PostMessage(UWM_AutoRun);
...
return TRUE;
}
CWnd *p_UIWnd = what? How can I get handle of the window using CWnd*?
I know below line of code is inaccurate because I got error during
compile.
CWnd *p_UIWnd = CDummyDlg.m_hWnd;
or in HWND case (which works):
HwND hDummy = CDummyDlg::m_hWnd;
These are both bad C++. The second one works because the "CDummyDlg::"
is redundant -- unneeded.
This works too:
HWND hDmmy = AfxGetMainWnd()->m_hWnd;
I am interested in knowing how to use CWnd type object. Thanks for
help.
It is very confusing to try and learn C++ and MFC and Windows
programming all at the same time. Doing more C++ exercises from a C++
book would probably help you a lot.
--
Scott McPhillips [VC++ MVP]