1
votes

I am in a need of hiding the console window, which I quickly resolved by P/Invoking ShowWindow. However, the call hides the console window as well as the taskbar button of the console window. I need the taskbar button to remain visible. I am not, however, looking for a way to minimize the console window. Clicking the taskbar button show not do anything. I tried to use SetWinEventHook and hide the window every time it was activated, but to no avail, as the window calling this function must run message loop in order to receive the events (and my console window didn't, no matter if I set OutOfContext or InContext flag).

Is there a way I can make my console application run, show itself in taskbar, then hide itself (or never show itself in a first place) and just keep running with no window but taskbar button visible?

1
I'm not sure how it shows in the taskbar, but if you compile your console application as a windows forms app you won't ever see the console window on screen.ovaltein
Exactly. If you never want a console to show, don't make a console app.David Heffernan
Thank you. Let me reword the question. What I am the most interested in is whether it is possible to make hidden console window with visible taskbar button. I know I can make a Windows Forms or WPF application, but that's not what I am asking.user3506768
Well what are you asking? What do you expect to happen when the user presses the taskbar button? Could you be a little more forthcoming in what you are trying to achieve?David Heffernan
As I described, when the taskbar button is pushed, nothing should happen -- you can see I tried to receive activation event using SetWinEventHook, but that didn't work for message-loop-less application. What I am wondering is: Is there a way around it? I do not intend to introduce message loop to the process, I am curious to see whether either a process can receive window event not having a message loop or if it is possible to have a hidden console window that will have visible taskbar button which doesn't activate it.user3506768

1 Answers

1
votes

The normal way to get a button on the taskbar is to create a visible unowned top-level window. So that's no use to you. One possible alternative is to use ITaskbarList::AddTab to add a button. I don't know whether or not this will do anything for an invisible window. Either way you'd need to run a message loop for your window. Even if you could do this the net result would not feel very nice for the user.