Sign in to follow this  

my call stack

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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().

Share this post


Link to post
Share on other sites
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,

Share this post


Link to post
Share on other sites

This topic is 4199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this