Re: SendMessage/PostMessage
Never post/send a WM_QUIT. Always post/send a WM_CLOSE message instead.
The reason it doesn't work is probably answered here.. which is , WM_QUIT message has to be processed by GetMessage, however, SendMessage bypasses this.
Anyways, refrain from send/posting WM_QUIT. WM_CLOSE is the recommended approach to close a window. If not, you might bypass other stuff the application would typically do when closing a window.
Re: SendMessage/PostMessage
Quote:
What are the differences so postmessage can close the window but postmessage can not
Quote:
Originally Posted by MSDN
The SendMessage function sends the specified message to a window or windows. It calls the window procedure for the specified window and does not return until the window procedure has processed the message.
Quote:
Originally Posted by MSDN
The PostMessage function places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.
Now, you should undestand better what Kiran said (as specified in MSDN)
Quote:
Originally Posted by MSDN
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.
Re: SendMessage/PostMessage
ok.
Thanks friends for help...
Re: SendMessage/PostMessage
Hi All
I want to close another programm from my programm:
Code:
SendMessage(hMw,WM_CLOSE,0,0);
And it works ...
But if another programm is Minimized, it's not closed. Only after the second start of my program it's closed.
Why...?
I don't understand.
Re: SendMessage/PostMessage
Quote:
I don't understand.
I don't undestand this either:
Quote:
after the second start of my program it's closed.
Re: SendMessage/PostMessage
I think he means... if the program he wants to close is minimized, running his program once will not close it. But, running his program a second time will close it.
Re: SendMessage/PostMessage
Yes I meant it.
I badly know English. Sorry...
Re: SendMessage/PostMessage
Why SendMessage ? Why not PostMessage ? ( SendMessage will tie up the sender if , for some reason, the target process is hung ). Instead, use PostMessage, or SendMessageTimeout.
Also, how are you obtaining the hWnd ? Are you sure you are getting the right hWnd ?
Re: SendMessage/PostMessage
PostMessage does not work too.
SendMessageTimeout did't try. I do not know parameter - fuFlags.
Yes Window handle is right. First time it's working.
Re: SendMessage/PostMessage
SendMessageTimeout does not work too.
Maybe i send wrong parameters !?
Code:
hMw = FindWindowEx (NULL,NULL,"WindowsForms10.Window.8.app17",NULL);
SendMessageTimeout(hMw,WM_CLOSE,0,0,0,200,0);