4
4
4ainik2018-12-04 21:47:05
Windows
4ainik, 2018-12-04 21:47:05

How to get messages using GetMessage?

WINAPI has a GetMessage function for receiving messages, but the trouble is that there is some subtlety between the console and window applications that affects the operation of this function.
Those. if you create a program as a window application with the main WinMain function, then GetMessage works as it should, but you need a console program, not a window program, and when I create a console program, GetMessage stops working, while the main function is main.
What is the subtlety here and can a CONSOLE program receive messages using the GetMessage call?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
none7, 2018-12-05
@none7

Making an invisible window created without dwStyle : WS_VISIBLE and with ShowWindow(hWnd,SW_HIDE) is the traditional way of catching window system messages, even for services. In this case, it is not at all necessary to compile the application as a graphical one. After all, no one bothers to call the RegisterClassEx and CreateWindowEx functions in a console application or service.

K
Konstantin Tsvetkov, 2018-12-04
@tsklab

GetMessage in a console application .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question