An unhandled exception was encountered during a user callback in C++

0

I'm getting error "Exception thrown at 0x0081B4E0 in LoongDB.exe: 0xC0000005: Access violation executing location 0x0081B4E0." while debugging my project.

Its project that was migrated from old c++ to newer version. I can post all files to github if it will be better.

Is there any way or tips for fixing it? I`m not good with 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

c++
asked on Stack Overflow Apr 23, 2019 by rankery • edited Apr 23, 2019 by rankery

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0