Direct2D: unhandled exception In case of WM_RESIZE switch

I am creating a Simple Direct2D Application . Unfortunately, this gives an unhandled exception. The function in which it occurs:

    void DemoApp::OnResize(UINT width, UINT height)
{
    if (m_pRenderTarget) <----|****The exception occurs here.....****
    {
        // Note: This method can fail, but it okay to ignore the
        // error here, because the error will be returned again
        // the next time EndDraw is called.
        m_pRenderTarget->Resize(D2D1::SizeU(width, height));
    }
}

And the code snippet calling OnResize ():

DemoApp *pDemoApp = reinterpret_cast<DemoApp *>(static_cast<LONG_PTR>(
            ::GetWindowLongPtrW(
                hwnd,
                GWLP_USERDATA
            )));

        bool wasHandled = false;

        if (pDemoApp)
        {
            switch (message)
            {
            case WM_SIZE:
            {
                UINT width = LOWORD(lParam);
                UINT height = HIWORD(lParam);
                pDemoApp->OnResize(width, height);
            }
            result = 0;
            wasHandled = true;
            break;
/*rest of switch case*/
       }

Exception: Unhandled exception in 0x00007FF6BE402CCA in Simple Direct2D application.exe: 0xC000041D: An unhandled exception occurred during user callback. occurred

Screenshot:

the pic of exception

As soon as I start debugging, the program throws an exception. I even copied the program word for word from the site. Since I'm new to the DirectX world, I don't know about the exception. What should I do?

+4
2

. 32- , 64- .

Microsoft Direct2D.

this SetWindowLongPtr PtrToUlong . 64- this 8 , SetWindowLongPtr 8 , PtrToUlong unsigned long, 4 . , PtrToUlong 4 this, .

, PtrToUlong( pDemoApp ) (LONG_PTR)pDemoApp

P.S. , , MS , Win32 , UWP. DirectX Direct2D ATL, . ATL : CComPtr , CWindowImpl .

: .

+3

, , -, , , , . SetWindowLong, , GetWindowLong, null, () , , ( , ). , , SetWindowLong, DemoApp, - , . , , ,

  • , SetWindowLong, DemoApp
  • DemoApp, , , ,
  • DemoApp, ,

, Unicode- GetWindowLongPtr, ( ). , Unicode-.

+1

Source: https://habr.com/ru/post/1684247/


All Articles