Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win7Samples/multimedia/DirectWriteCustomLayout throws exception #362

Open
PeterCon opened this issue Sep 9, 2024 · 0 comments
Open

Win7Samples/multimedia/DirectWriteCustomLayout throws exception #362

PeterCon opened this issue Sep 9, 2024 · 0 comments

Comments

@PeterCon
Copy link
Contributor

PeterCon commented Sep 9, 2024

After retargeting this project for VS 2022 and fixing a few minor issues (e.g. min() max() macros defined in Common.h conflicting with std functions), the project builds. However, when run, a main window is show with no client content, and then after some seconds the app automatically terminates.

On debugging, it is consistently throwing an exception before it has finished initializing (in MainWindow::Initialize()).

The implementation has a MainWindow class that holds the hwnd (and other stuff in protected members). When the call to CreateWindow() returns, it is not setting hwnd_; rather, a pointer to the MainWindow object is passed so that the object can be retrieved when WM_NCCreate is processed and hwnd_ is set then.

However, when ShowWindow() is called, a WM_SIZE message gets processed, and the OnSize() handler calls GetClientRect(hwnd_, &rect)
which throws because hwnd_ isn't set or can't be accessed. I tried changing the OnSize() signature to pass down the hwnd, but that still didn't work. I don't understand why a method within the MainWindow object can't access the hwnd_ protected member within that object.

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

No branches or pull requests

1 participant