guys , I am a new commer ,and I have just started to study MFC. I have a question about the MDI application framework. In MFC. I leaned from the code that a ChildFrame is always created by MDI Client Window when I new a file. But I can not find what's the WindowProc of "MDI Client Window“ in MFC. Actually,"MDI Client Window“ is created after we create the Main Frame.
winmdi.cpp
// Create MDICLIENT control with special IDC
if ((m_hWndMDIClient = ::AfxCtxCreateWindowEx(dwExStyle, _T("mdiclient"), NULL,
dwStyle, 0, 0, 0, 0, m_hWnd, (HMENU)AFX_IDW_PANE_FIRST,
AfxGetInstanceHandle(), (LPVOID)&ccs)) == NULL)
About the "MDI Client Window“
And while we are creating a ChildFrame ,we send a WM_MDICREATE message to "MDI Client Window“,and then we get the Handle of the Window.
winmdi.cpp
BOOL CMDIChildWnd::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CMDIFrameWnd* pParentWnd,
CCreateContext* pContext)
{
//......
// create the window through the MDICLIENT window
AfxHookWindowCreate(this);
HWND hWnd = (HWND)::SendMessage(pParentWnd->m_hWndMDIClient,
WM_MDICREATE, 0, (LPARAM)&mcs);
About the WM_MDICREATE ,I found this information from Microsoft. *An application sends the WM_MDICREATE message to a multiple-document interface (MDI) client window to create an MDI child window. If the message succeeds, the return value is the handle to the new child window. If the message fails, the return value is NULL.*
I guess,perhaps Windows the WindowProc from AfxGetInstanceHandle();But to be honest,I do not really know how it does so.
AfxGetInstanceHandle http://msdn.microsoft.com/en-us/library/vstudio/36z3tfsb.aspx This function allows you to retrieve the instance handle of the current application.
Please help me... Thank you very much indeed.