Home > Enterprise >  Win32 window not showing when ran through CLI/VSCode debugger
Win32 window not showing when ran through CLI/VSCode debugger

Time:04-27

I am creating a Win32 application, I have followed some setup code for creating a Win32 window without the need for a WinMain which can be found here. The code builds just fine and if I run the application by opening it in a file browser it runs no problem. However, if I run it via the command line it only outputs the console logs and doesn't create a window. I assume that this is also why if I run it via VSCode's debugger it also doesn't launch a window. Has anyone come across this issue before and found a fix for it? It would be pretty had to debug a GUI application if you can't use the debugger and see it at the same time.

CodePudding user response:

This bit of code contains a mistake:

STARTUPINFO si;
GetStartupInfo(&si);  
int nCmdShow = si.wShowWindow;

You forgot to check si.dwFlags, as indicated in the documentation for wShowWindow:

If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of the values that can be specified in the nCmdShow parameter for the ShowWindow function, except for SW_SHOWDEFAULT. Otherwise, this member is ignored.

  • Related