在C ++中的用户回调期间遇到未处理的异常

时间:2019-04-23 19:26:42

标签: c++

我收到错误消息“ LoongDB.exe中的0x0081B4E0引发异常:0xC0000005:执行位置0x0081B4E0的访问冲突。”在调试我的项目时。

其项目已从旧的c ++迁移到较新的版本。 如果会更好,我可以将所有文件发布到github。

是否有任何修复方法或提示?我对c ++不好。

BOOL WindowWrap::CreateWnd(LPCTSTR szCaption, HINSTANCE hInst, HICON hIcon, HMENU hMenu, BOOL bMinBox)
{
    m_dwMainThreadID = GetCurrentThreadId();
    m_hCursorArrow = LoadCursor(NULL, IDC_ARROW);
    m_hCursorWait = LoadCursor(NULL, IDC_WAIT);
    m_hCursorIbeam = LoadCursor(NULL, IDC_IBEAM);
    m_hCursorSize = LoadCursor(NULL, IDC_SIZEALL);
    m_hCursorCurrent = m_hCursorArrow;
    m_hCursorHand = LoadCursor(NULL, IDC_HAND);

    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style          = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
    wcex.lpfnWndProc    = (WNDPROC)(m_Trunk.sfp4(&vEngine::WindowWrap::WndProc));
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInst;
    wcex.hIcon          = hIcon;
    wcex.hCursor        = m_hCursorCurrent;
    wcex.hbrBackground  = (HBRUSH)GetStockObject(BLACK_BRUSH);
    wcex.lpszMenuName   = 0;
    wcex.lpszClassName  = szCaption;
    wcex.hIconSm        = 0;// LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

    if( 0 == RegisterClassEx(&wcex) ) 
    {
        OutputDebugString(_T("error register window class"));
        return FALSE;
    }

    if( bMinBox )
        m_hWnd = ::CreateWindow(szCaption, szCaption, WS_OVERLAPPED|WS_CAPTION|WS_MINIMIZEBOX|WS_SYSMENU,
            CW_USEDEFAULT, CW_USEDEFAULT, m_nWidth, m_nHeight, NULL, NULL, hInst, NULL);
    else
        m_hWnd = ::CreateWindow(szCaption, szCaption, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU,
            CW_USEDEFAULT, CW_USEDEFAULT, m_nWidth, m_nHeight, NULL, NULL, hInst, NULL);

    if( !m_hWnd ) 
    {
        OutputDebugString(_T("error creating window"));
        return 1;
    }

    // Ѕ«hwndјЗВјПВАґ
    TObjRef<VarContainer>()->Add((DWORD)m_hWnd, _T("HWND"));

    if( hMenu )
        ::SetMenu(m_hWnd, hMenu);

    if( !m_bBoard )
    {
        // ИҐµфґ°їЪ±кМвєН±Яїт
        SetWindowLong(m_hWnd, GWL_STYLE, WS_POPUP);
        SetWindowPos(m_hWnd,HWND_TOP,0,0,0,0,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
    }

    // јЖЛгґ°їЪїН»§ЗшґуРЎТФј°±ЯїтґуРЎ
    RECT rcInt;   // rcIntПаµ±УЪrcClient
    RECT rcExt;   // rcExtПаµ±УЪrcWindow
    ::GetWindowRect(m_hWnd, &rcExt);    // јЖЛг±ЯїтµДґуРЎ
    ::GetClientRect(m_hWnd, &rcInt);
    INT x = (rcExt.right-rcExt.left) - (rcInt.right-rcInt.left);
    INT y = (rcExt.bottom-rcExt.top) - (rcInt.bottom-rcInt.top);

    if( m_bShowTaskBar )
    {
        // КЗ·с№¤ЧчЗшИыІ»ПВХвГґґуµДґ°їЪ
        RECT rc = {0, m_nWidth, 0, m_nHeight};
        SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);   // µГµЅ№¤ЧчЗшµДґуРЎ(І»є¬ИООсАёµДЗшУт)
        if( m_nWidth + x > rc.right - rc.left || m_nHeight + y > rc.bottom - rc.top )
        {
            ::GetWindowRect(m_hWnd, &rcExt);    // јЖЛг±ЯїтµДґуРЎ
            ::GetClientRect(m_hWnd, &rcInt);
            x = (rcExt.right-rcExt.left) - (rcInt.right-rcInt.left);
            y = (rcExt.bottom-rcExt.top) - (rcInt.bottom-rcInt.top);
            m_nWidth = rc.right - rc.left - x;
            m_nHeight = rc.bottom - rc.top - y;
        }
    }

    // ЧоЦХґ°їЪґуРЎ
    SetWindowPos(m_hWnd, HWND_TOP, 0, 0, m_nWidth + x, m_nHeight + y, SWP_SHOWWINDOW|SWP_NOMOVE);

    ShowWindow(m_hWnd, SW_SHOWNORMAL);
    UpdateWindow(m_hWnd);

    ::SetCursor(m_hCursorCurrent);
    return TRUE;
}

enter image description here

0 个答案:

没有答案