Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: console app which handle windows events Pin
Richard MacCutchan1-Feb-18 22:50
mveRichard MacCutchan1-Feb-18 22:50 
GeneralRe: console app which handle windows events Pin
Fedrer1-Feb-18 22:56
Fedrer1-Feb-18 22:56 
GeneralRe: console app which handle windows events Pin
Richard MacCutchan1-Feb-18 23:01
mveRichard MacCutchan1-Feb-18 23:01 
GeneralRe: console app which handle windows events Pin
leon de boer4-Feb-18 13:32
leon de boer4-Feb-18 13:32 
GeneralRe: console app which handle windows events Pin
Richard MacCutchan4-Feb-18 21:52
mveRichard MacCutchan4-Feb-18 21:52 
GeneralRe: console app which handle windows events Pin
Victor Nijegorodov2-Feb-18 4:07
Victor Nijegorodov2-Feb-18 4:07 
AnswerRe: console app which handle windows events Pin
Jochen Arndt2-Feb-18 0:23
professionalJochen Arndt2-Feb-18 0:23 
AnswerRe: console app which handle windows events Pin
leon de boer4-Feb-18 13:42
leon de boer4-Feb-18 13:42 
Ok so the whole console now is full emulated since Windows 7 it is just a normal window.

However it has a special message handler which filters out the normal windows messages and it doesn't have a proper message queue setup. It's rather technical to go thru and add the steps to convert it when there is a much simpler way.

For the record WM_TIMERTICK and a few other windows message do get passed thru (you can use timers now on a console app) .. This will work as illustration there is a normal windows queue present on a console window however expanding the queue and removing the filter is far more problematic
int main()
{
SetTimer(0, 1, 1000, 0);
SetTimer(0, 2, 750, 0);
MSG Message;
while(GetMessage(&Message, 0, 0, 0))
{
if(Message.message == WM_TIMER)
{
std::cout << "Timer" << std::endl;
}
}
}

By far the easiest way to do what you want is actually setup for a proper windows app but then create and attach a console to it which is the new fancy feature.

AllocConsole function - Windows Console | Microsoft Docs[^]
AttachConsole function - Windows Console | Microsoft Docs[^]

So it basically does exactly what you are after you have a full windows message queue underneath and you can pump whatever message you want to the console. The actual GUI window can remain hidden by simply never setting the WS_VISIBLE flag or attaching it to the taskbar in minimized form.

Your whole app is basically a minimal hidden standard window throwing messages up to a console which is I believe what you are after.
In vino veritas


modified 4-Feb-18 19:53pm.

Questionriver crossing priests and devils in c program Pin
Member 1365554231-Jan-18 23:14
Member 1365554231-Jan-18 23:14 
AnswerRe: river crossing priests and devils in c program Pin
Richard MacCutchan31-Jan-18 23:21
mveRichard MacCutchan31-Jan-18 23:21 
AnswerRe: river crossing priests and devils in c program Pin
jeron11-Feb-18 3:19
jeron11-Feb-18 3:19 
QuestionRe: river crossing priests and devils in c program Pin
David Crow1-Feb-18 3:47
David Crow1-Feb-18 3:47 
QuestionC++ - Static templated method inside a class Pin
phil.o31-Jan-18 12:00
professionalphil.o31-Jan-18 12:00 
AnswerRe: C++ - Static templated method inside a class Pin
Richard MacCutchan31-Jan-18 12:13
mveRichard MacCutchan31-Jan-18 12:13 
GeneralRe: C++ - Static templated method inside a class Pin
phil.o31-Jan-18 13:28
professionalphil.o31-Jan-18 13:28 
GeneralRe: C++ - Static templated method inside a class Pin
Richard MacCutchan31-Jan-18 21:41
mveRichard MacCutchan31-Jan-18 21:41 
GeneralRe: C++ - Static templated method inside a class Pin
phil.o31-Jan-18 14:07
professionalphil.o31-Jan-18 14:07 
GeneralRe: C++ - Static templated method inside a class Pin
CPallini31-Jan-18 21:20
mveCPallini31-Jan-18 21:20 
GeneralRe: C++ - Static templated method inside a class Pin
Richard MacCutchan31-Jan-18 21:48
mveRichard MacCutchan31-Jan-18 21:48 
GeneralRe: C++ - Static templated method inside a class Pin
phil.o1-Feb-18 3:20
professionalphil.o1-Feb-18 3:20 
GeneralRe: C++ - Static templated method inside a class Pin
Richard MacCutchan1-Feb-18 4:08
mveRichard MacCutchan1-Feb-18 4:08 
QuestionExplorer Pin
Fedrer31-Jan-18 0:12
Fedrer31-Jan-18 0:12 
AnswerRe: Explorer Pin
Richard MacCutchan31-Jan-18 0:49
mveRichard MacCutchan31-Jan-18 0:49 
AnswerRe: Explorer Pin
Jochen Arndt31-Jan-18 1:22
professionalJochen Arndt31-Jan-18 1:22 
AnswerRe: Explorer Pin
Randor 31-Jan-18 5:26
professional Randor 31-Jan-18 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.