简体   繁体   中英

Win32 Application is not destroyed

I am in the process of learning the Win32 API. I have a problem where the window is visibly closed but the application is running in the background (I can see this using the Windows 10 task manager). Here is my code that closes the window:

case WM_CLOSE:
    DestroyWindow(hwnd);
break;

case WM_DESTROY:
    PostQuitMessage(0);
break;

My application is called a.exe and you can see it in this screenshot I took of the Windows 10 task manager.

这是一个.exe

Read the docs :

"The PostQuitMessage function posts a WM_QUIT message to the thread's message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future. When the thread retrieves the WM_QUIT message from its message queue, it should exit its message loop and return control to the system. The exit value returned to the system must be the wParam parameter of the WM_QUIT message.

The WM_QUIT message is not associated with a window and therefore will never be received through a window's window procedure. It is retrieved only by the GetMessage or PeekMessage functions."

See think link also.

I have discovered the issue. Thanks for all the help but the window was actually being closed but the console was still open in the background. I was running:

FreeConsole();

and that was hiding the console. When I closed the window the console kept running and I am now closing the console as well and it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM