@@ -32,8 +32,10 @@ int Win32Application::Run(D3D12Quad* pSample, int nCmdShow)
3232 windowClass.hCursor = LoadCursor (NULL , IDC_ARROW);
3333 windowClass.lpszClassName = L" DXQuad" ;
3434
35+ auto hr = RegisterClassEx (&windowClass);
3536 // Register window class
36- if (!RegisterClassEx (&windowClass))
37+ auto err = GetLastError ();
38+ if (!hr)
3739 {
3840 MessageBox (NULL , L" Error registering class" ,
3941 L" Error" , MB_OK | MB_ICONERROR);
@@ -76,7 +78,8 @@ int Win32Application::Run(D3D12Quad* pSample, int nCmdShow)
7678 // variable is set to true
7779 if (close_window) {
7880 pSample->OnDestroy ();
79- PostMessage (m_hwnd, WM_QUIT, 0 , 0 );
81+ PostMessage (m_hwnd, WM_CLOSE, 0 , 0 );
82+ break ;
8083 }
8184 // Process any messages in the queue.
8285 if (PeekMessage (&msg, NULL , 0 , 0 , PM_REMOVE))
@@ -95,6 +98,9 @@ int Win32Application::Run(D3D12Quad* pSample, int nCmdShow)
9598 L" Error" , MB_OK | MB_ICONERROR);
9699 return 1 ;
97100 }
101+ else {
102+ OutputDebugString (L" Class unregistered" );
103+ }
98104
99105 // Return this part of the WM_QUIT message to Windows.
100106 return static_cast <char >(msg.wParam );
@@ -118,8 +124,11 @@ LRESULT CALLBACK Win32Application::WindowProc(HWND hWnd, UINT message, WPARAM wP
118124 case WM_PAINT:
119125 if (pSample)
120126 {
121- pSample->OnUpdate ();
122- pSample->OnRender ();
127+ if (!close_window)
128+ {
129+ pSample->OnUpdate ();
130+ pSample->OnRender ();
131+ }
123132 }
124133 return 0 ;
125134
0 commit comments