Closed walbourn closed 1 year ago
The existing templates for Win32 use SetWindowsLongPtr after creating the window and showing it.
SetWindowsLongPtr
The official DirectX-Graphics-Samples projects use WM_CREATE and the lpParam on CreateWindow instead.
WM_CREATE
lpParam
HWND hwnd = CreateWindowExW(0, ..., g_game.get());
switch (message) { case WM_CREATE: if (lParam) { auto pCreateStruct = reinterpret_cast<LPCREATESTRUCTW>(lParam); SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pCreateStruct->lpCreateParams)); } return 0;
Note this works fine, but needs one tweak to DeviceResources:
bool DeviceResources::WindowSizeChanged(int width, int height) { if (!m_window) return false; ...
https://github.com/walbourn/directx-vs-templates/commit/6fa457f4466e5e59d4362b4e4b4d2c45a2e56c80
The existing templates for Win32 use
SetWindowsLongPtr
after creating the window and showing it.The official DirectX-Graphics-Samples projects use
WM_CREATE
and thelpParam
on CreateWindow instead.Note this works fine, but needs one tweak to DeviceResources: