my call stack

Started by
1 comment, last by Emmanuel Deloget 17 years, 10 months ago
CMainRoom::OnConnectToServer() .... mfc71d.dll!.....//many other mfc stuff .... mfc71d.dll!CWnd::RunModalLoop(unsigned long dwFlags=0x00000004) mfc71d.dll!CDialog::DoModal() Game.exe!CGameApp::InitInstance() Game.exe!WinMain(...) so I wanna know how does DoModal() result in OnConnectToServer() call?? or how does a DoModal() result in a user-defined function call? [Edited by - derek7 on June 13, 2006 7:27:39 PM]
Advertisement
It's been ages since I used MFC, but I seem to recall all DoModal() does is enters the dialogs modal loop. Which causes messages to be dispatched to the dialogs message procedure (implemented in the MFC code). Your dialog class then gets functions called by the MFC framework, which I presume calls OnConnectToServer().
Quote:Original post by Evil Steve
It's been ages since I used MFC, but I seem to recall all DoModal() does is enters the dialogs modal loop. Which causes messages to be dispatched to the dialogs message procedure (implemented in the MFC code). Your dialog class then gets functions called by the MFC framework, which I presume calls OnConnectToServer().


Correct. DoModal() is indeed a message loop in disguise. At some point, DoModal() calls the inner function CWnd::RunModalLoop() which essentialy does:
for (;;) {  do {    AfxMessagePump(); // get one message and dispatch it    if (!ContinueModal())      goto ExitModal; // OMG!!!!   } while (PeekMessage(...);}ExitModal:return m_nModalResult;

The AfxMessagePump() function will dispatch the message - ultimately, CWnd::WindowProc will be called, and that function will in turn call your message handler.

HTH,

This topic is closed to new replies.

Advertisement