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.