Skip to content

Commit 7daf91b

Browse files
committed
Small changes
1 parent 6dc7ba4 commit 7daf91b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Samples/WinMLSamplesGallery/WinMLSamplesGalleryNative/D3D12Quad.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ D3D12Quad::D3D12Quad(UINT width, UINT height, std::wstring name) :
3333
void D3D12Quad::OnInit()
3434
{
3535
auto title = GetTitle();
36-
OutputDebugString(L"In OnInit\n");
3736
fileNames = {
3837
L"C:/Users/numform/Windows-Machine-Learning/Samples/WinMLSamplesGallery/WinMLSamplesGalleryNative/cat.jpg",
3938
L"C:/Users/numform/Windows-Machine-Learning/Samples/WinMLSamplesGallery/WinMLSamplesGalleryNative/fish.png",

Samples/WinMLSamplesGallery/WinMLSamplesGalleryNative/Win32Application.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)