ShowWindow()崩溃

时间:2012-02-07 09:31:32

标签: c++ winapi notepad++

我正在开发一个Notepad ++插件。

我有一个简单的对话框,使用CreateDialogParam()创建。它最初是隐藏的。

点击菜单后,我会在其句柄上调用ShowWindow() SW_SHOW,这会导致此异常:

c000041d

调试后,我发现这两条消息在崩溃之前就被发送到了我的对话框 WM_SHOWWINDOW
WM_WINDOWPOSCHANGING

他们两个,我没有处理。这是我的dlgproc代码。知道为什么会这样吗?

BOOL CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
{
    switch (message) 
    {
        case WM_INITDIALOG :
        {
            // Get the additional init data
            StaticDialog *pStaticDlg = (StaticDialog *)(lParam);

            // Store the handle in the object
            pStaticDlg->_hSelf = hwnd;


            ::SetWindowLongPtr(hwnd, GWL_USERDATA, (long)lParam);

            // Store the co-ordinates in the object
            ::GetWindowRect(hwnd, &(pStaticDlg->_rc));

            // Forward the message for further processing
            pStaticDlg->run_dlgProc(message, wParam, lParam);

            // TRUE if it processed the message
            return TRUE;
        }

        default :
        {
            // Retrieve the user data
            StaticDialog *pStaticDlg = (StaticDialog *)(::GetWindowLongPtr(hwnd, GWL_USERDATA));
            if (!pStaticDlg)
                return FALSE;

            // Send the message for further processing
            return pStaticDlg->run_dlgProc(message, wParam, lParam);

            // return FALSE if it processed the message
        }
    }
}



BOOL CALLBACK MarkDownViewDialog::run_dlgProc( UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch (Message) 
    {
        case WM_INITDIALOG:
        {
            EmbedBrowserObject(this->_hSelf);
            DisplayHTMLPage(this->_hSelf,L"http://www.microsoft.com");
            DisplayHTMLStr(this->_hSelf, L"<H2><CENTER>HTML string test</CENTER></H2><P><FONT COLOR=RED>This is a <U>HTML string</U> in memory.</FONT>");

            break;
        }



        default:
            break;
    }

    return FALSE;
}

该对话框是通过Notpead ++的插件机制创建的。我从其文件StaticDialog.cpp中提取源代码。该控件在下面的代码中经过else块。

void StaticDialog::create(int dialogID, bool isRTL, bool isModeles)
{
    if (isRTL)
    {
        DLGTEMPLATE *pMyDlgTemplate = NULL;
        HGLOBAL hMyDlgTemplate = makeRTLResource(dialogID, &pMyDlgTemplate);
        _hSelf = ::CreateDialogIndirectParam(_hInst, pMyDlgTemplate, _hParent, (DLGPROC)dlgProc, (LPARAM)this);
        ::GlobalFree(hMyDlgTemplate);
    }
    else
        _hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, (DLGPROC)dlgProc, (LPARAM)this);
    //int i=GetLastError();

    if (!_hSelf)
    {
        //systemMessage(_T("StaticDialog"));
        return;
    }

    if (isModeles) {
        _isModeles = isModeles;
        ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGADD, (WPARAM)_hSelf);
    }
}

我的整个解决方案源代码都在这里托管: https://github.com/madhur/Npp-Markdown-Viewer

问题解决方案

以下是我为解决问题所做的工作:

返回pStaticDlg-&gt; run_dlgProc(message,wParam,lParam);

0 个答案:

没有答案