I have a very simple app which has a few buttons and text fields. I want to be able to add an icon to it, as you cant see if it is running when it is behind other windows. What is the simplest way of doing this?
I tried creating a window which was hidden which kinda works but you can see that other window blink when you click on the taskbar icon and I can't seem to make it focus on the dialog box.
I think the fundamental problem is that you have a hidden top-level window which owns your dialog. The dialog is acting as the main window, but the taskbar shows a button associated with the hidden window.
So I guess what you need to do is remove the hidden window altogether. That means getting rid of the RegisterClass
and CreateWindow
calls.
I'm assuming you show the dialog modeless. In which case you use CreateDialog and ShowWindow to show it. Take heed particularly of this section of the documentation:
After CreateDialog returns, the application displays the dialog box (if it is not already displayed) by using the ShowWindow function. The application destroys the dialog box by using the DestroyWindow function. To support keyboard navigation and other dialog box functionality, the message loop for the dialog box must call the IsDialogMessage function.
Of course if you are showing the dialog modally you can probably carry on doing that. In which case your WinMain
function is very simple. It's just a call to DialogBox
. No message loop needed because the modal dialog's message loop handles the messages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With