Привет. После закрытия окна процесс не хочет умирать.
#include <d3dcompiler.h>
#include <d3d11.h>
#include "resource.h"
#include <DirectXMath.h>
#include <Windows.h>
using namespace DirectX;
HWND g_hWnd=NULL;
HINSTANCE g_hMainInstance=NULL;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
HRESULT initWindow(HINSTANCE, int);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow){
g_hMainInstance = hInstance;
WNDCLASSEX wc = {};
//ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.hInstance = g_hMainInstance;
wc.lpszMenuName = NULL;
wc.lpszClassName = L"MyName1";
if (!RegisterClassEx(&wc)){
MessageBox(NULL, L"Eroare la inregistrarea clasei!", L"Eroare", MB_OK | MB_ICONERROR);
return -1;
}
g_hWnd = CreateWindow(L"MyName1", L"Window_1",
WS_MINIMIZEBOX | WS_MAXIMIZEBOX| WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
0, CW_USEDEFAULT,0, (HWND)NULL, NULL, g_hMainInstance, NULL);
if (!g_hWnd){
MessageBoxA(NULL, "Eroare la crearea ferestrei!", "Eroare", MB_OK);
return -1;
}
ShowWindow(g_hWnd,nCmdShow);
UpdateWindow(g_hWnd);
MSG msg = { 0 };
while (true){
if (PeekMessage(&msg, g_hWnd, NULL, NULL,PM_REMOVE)){
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int)msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hMainWnd, UINT uMessage,
WPARAM wParam, LPARAM lParam){
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
HBRUSH brush;
switch (uMessage){
case WM_PAINT:
hdc = BeginPaint(hMainWnd, &ps);
GetClientRect(hMainWnd, &rect);
brush = CreateSolidBrush(RGB(200, 120, 50));
FillRect(hdc, &rect, brush);
EndPaint(hMainWnd, &ps);
break;
case WM_KEYDOWN:
switch (wParam){
case 'A':
case 'a':
MessageBox(NULL, L"A fost tastata tasta A.", L"Informatie", MB_OK);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hMainWnd, uMessage, wParam, lParam);
}
return 0;
}
WM_QUIT
приходит? – VladD 5 фев '17 в 12:09WM_DESTROY
? – VladD 5 фев '17 в 12:37