Мой процесс не выходит, когда я нажимаю кнопку «Остановка », как показывают следующие фотографии:
mwe
Код: Выделить всё
#include
LRESULT CALLBACK CrosshairWindow_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_PAINT:
// Something
return 0;
case WM_ERASEBKGND:
return 1;
case WM_SIZE:
// Something
return 0;
case WM_CLOSE:
case WM_QUIT:
case WM_NCDESTROY:
case WM_DESTROY:
// Something
PostQuitMessage(0);
return 0;
default:
// In my option, problems happens here, and if I DELETE this, the problem whould disappear but the Window created by this function would not be shown.
return DefWindowProc(hWnd, msg, wParam, lParam);
}
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) {
WNDCLASSEXW wc = { sizeof(wc) };
wc.lpfnWndProc = CrosshairWindow_WndProc;
wc.hInstance = hInstance;
wc.lpszClassName = L"TestWndProcClass";
RegisterClassExW(&wc);
// Create Window
HWND hwnd = CreateWindowExW(
0, L"TestWndProcClass", L"WndProc Demo",
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,
nullptr, nullptr, hInstance, nullptr
);
if (!hwnd) return 1;
ShowWindow(hwnd, SW_SHOW);
// MSG loop
MSG msg;
while (GetMessage(&msg, nullptr, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
< /code>
Вопрос < /h2>
Я подтвердил, что эта проблема связана с [b]WMПодробнее здесь: https://stackoverflow.com/questions/797 ... debug-mode