热情软件屋

 

为什么PreCreateWindow被调用了两次


编号:QA004429
建立日期: 2001年9月25日 最后修改日期:2001年9月25日
所属类别:

白乐贤:
    操作系统:windows 2000
    编程工具:vc6.0
    问题:我在vc6.0 、windows 2000 环境下用mfc编 SDI程序。在我的 CMainFrame 的 PreCreateWindow函数里,输出了一句话就如下面所示
    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
     TRACE("PRECREARE \n");
     if( !CFrameWnd::PreCreateWindow(cs) )
     return FALSE;
     // TODO: Modify the Window class or styles here by modifying
     // the CREATESTRUCT cs
    
     return TRUE;
    }
    可不知道为什么总是在Debug 窗口输出两次一样的句子,PreCreateWindow被调用了两次吗。谢谢!

回答:

    经过调试可以发现PreCreateWindow被调用了两次,以下是两次执行时Call stack中的内容,
    第一次:
    CMainFrame::PreCreateWindow() line 81
    CFrameWnd::GetIconWndClass() line 666
    CFrameWnd::LoadFrame() line 692 + 16 bytes
    CDocTemplate::CreateNewFrame() line 279 + 32 bytes
    CSingleDocTemplate::OpenDocumentFile() line 132 + 17 bytes
    CDocManager::OnFileNew() line 829
    CWinApp::OnFileNew() line 29
    _AfxDispatchCmdMsg() line 88
    CCmdTarget::OnCmdMsg() line 302 + 39 bytes
    CWinApp::ProcessShellCommand() line 31 + 30 bytes
    CTestApp::InitInstance() line 88 + 12 bytes
    AfxWinMain() line 39 + 11 bytes
    WinMain() line 30
    WinMainCRTStartup() line 330 + 54 bytes
    KERNEL32! bff8b86c()
    KERNEL32! bff8b71e()
    KERNEL32! bff8a0e1()
    第二次:
    CMainFrame::PreCreateWindow() line 81
    CWnd::CreateEx() line 685 + 15 bytes
    CFrameWnd::Create() line 564 + 79 bytes
    CFrameWnd::LoadFrame() line 695 + 45 bytes
    CDocTemplate::CreateNewFrame() line 279 + 32 bytes
    CSingleDocTemplate::OpenDocumentFile() line 132 + 17 bytes
    CDocManager::OnFileNew() line 829
    CWinApp::OnFileNew() line 29
    _AfxDispatchCmdMsg() line 88
    CCmdTarget::OnCmdMsg() line 302 + 39 bytes
    CWinApp::ProcessShellCommand() line 31 + 30 bytes
    CTestApp::InitInstance() line 88 + 12 bytes
    AfxWinMain() line 39 + 11 bytes
    WinMain() line 30
    WinMainCRTStartup() line 330 + 54 bytes
    KERNEL32! bff8b86c()
    KERNEL32! bff8b71e()
    KERNEL32! bff8a0e1()

此问题由梅耀中回答。

 
把这个问题推荐给朋友
   
   
您的意见类别
您的名字
您的电子邮件
您的建议(请尽可能详细)
 
 

版权所有 1997-2008 热情软件屋
如果您有任何建议和意见, 请给我发个电子邮件 askpro@china-askpro.com
Web Designed by ZebraStudio