Skip to content

Conversation

@vasilich-tregub
Copy link

In project Windows-classic-samples/Samples/Win7Samples/multimedia/DirectWrite/HelloWorld, when processing message == WM_CREATE in TabWindow::WndProc(...), TabWindow fails to save its USERDATA with a ::SetWindowLongPtrW(hwnd, GWLP_USERDATA, PtrToUlong(pTabWindow)) call (file TabWindow.cpp, line 286), and consequently fails to initialize pTabWindow when processing later the WM_SIZE message.

As the debugger reports an access violation exception in the _SCRT_STARTUP_WWINMAIN-branch routine, the error is hard to identify for beginner programmers.

Use a standard-compliant reinterpret_cast<LONG_PTR>(pTabWindow).

In project Windows-classic-samples/Samples/Win7Samples/multimedia/DirectWrite/HelloWorld,
when processing message == WM_CREATE in TabWindow::WndProc(...), TabWindow fails to save its USERDATA with a ::SetWindowLongPtrW(hwnd, GWLP_USERDATA, PtrToUlong(pTabWindow)) call (file TabWindow.cpp, line 286), and consequently fails to initialize pTabWindow when processing later the WM_SIZE message. 

As the debugger reports an access violation exception in the _SCRT_STARTUP_WWINMAIN-branch routine, the error is hard to identify for beginner programmers.

Use a standard-compliant reinterpret_cast<LONG_PTR>(pTabWindow).
Copy link

@zhuman zhuman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants