Just to complement what William said, if you notice, most of the time at the time the call Showwindow inside Winmain sends the nCmdShow argument, this argument is the way Windows wants its window to be displayed(since you can change the view mode of shortcuts), so basically when calling the Showwindow sending nCmdShow, you are not exactly asking function to show your window, but rather to show it the way that Windows wants.
But the window is not shown on the screen alone, it is only shown on the screen automatically if you create the window by sending the WS_VISIBLE flag, see this example:
CreateWindowW(wc.lpszClassName, L"Janela", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 250, 150, NULL, NULL, hInstance, NULL);
In the above case it is shown automatically, because you sent the WS_VISIBLE in the function, that is, even without calling the Showwindow it will be shown.
Now look at this case:
HWND hwnd = CreateWindowW(wc.lpszClassName, L"Janela", WS_OVERLAPPEDWINDOW, 100, 100, 250, 150, NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, SW_SHOW);
In this case the window would not appear without the Showwindow call as the WS_VISIBLE flag was not sent.
Thank you now I realized Xp. The tutorial I am following does not explain certain things that in MSDN are also not explained :/
– krystalgamer
Guilherme, would you have a link to the documentation of all this? Add a lot to your answer.
– bfavaretto
@bfavaretto added documentation on the
ShowWindow
, my English is not very good, I translated the flags of the documentation from microsoft, if you have any gafe forgive me, I translated with the basic that I know of English (which is very bad by the way :p ), I did not use google-translator because often the texts lose meaning for me.– Guilherme Nascimento