What is nCmdShow?

I was always curious what nCmdShow means in C programs in WinMain using the Windows API.

I looked at the formal explanation: "Controls how the window should be displayed. This parameter can be one of the following values."

I do not understand what this means, since a Windows program can contain more than one window or no windows at all. In addition, as the program starts, there is no window to show in order to start with it, which further forces me to ask this argument.

Also from what I read, it always remains 10, which is not even included in the list of options in the section http://msdn.microsoft.com/en-us/library/windows/desktop/ms633559%28v=vs.85% 29.aspx "...

Is it out of date? Can someone explain their purpose or provide any links explaining its use? I tried searching on the Internet but did not see anything.

Thanks!

REVISED :

When you right-click a shortcut and go to properties, you can launch the Minimized, Maximized, or Normal (ly) window.

Windows provides the nCmdShow program for your program if it wants to act in a special way if it was launched in any of these three ways. For example, it may be hiding inside the notification panel if it was suggested to start minimizing it.


For completeness:

enter image description here

https://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx describes all the ways that can be transferred.

+8
winapi
source share
4 answers

Basically this is a hint for the application how it should show the main window. Although this is a legacy, it is not as obsolete as the hPrevInstance parameter. But, I'm distracted ...

The nCmdShow parameter nCmdShow will be one of the constants specified in the ShowWindow API link. It can be installed by another process or system that launches your application through CreateProcess . The STARTUPINFO structure, which can optionally be passed to CreateProcess , contains the wShowWindow member wShowWindow , which will be passed to WinMain via nCmdShow .

Another way to pass the nCmdShow parameter is to call ShellExecute .

At the top of my head, I canโ€™t think of any scenario (in recent versions of Windows) in which the operating system will explicitly pass a value other than SW_SHOW when the application starts.

It is unsuitable or bad for an application to ignore the nCmdShow flag passed to WinMain [?] .

+4
source share

Take a look at this section from the ShowWindow documentation :

nCmdShow : this parameter is ignored the first time the ShowWindow application is ShowWindow , if the program that starts the application provides the STARTUPINFO structure.

Despite the fact that your program does not have a window at startup, the specified value gets implicit use on the first call to ShowWindow . (It is not read directly from WinMain local nCmdShow , however, therefore you cannot change its value in WinMain and expect different results. In this sense, this is not particularly useful if your program does not need something special, if it was reduced to minimum or maximized.)

+5
source share

nCmdShow is an integer type, this parameter specifies how application windows should be displayed (for OS) If the value is not specified by you, than the default Windows OS say SW_NORMAL value of this parameter. You can specify the values โ€‹โ€‹of this parameter, but those who passed WinMain () for Windows OS only

+1
source share

"n" in nCmdShow means "Short int".

(This is what I wanted to know when I came to this page)

Source: https://msdn.microsoft.com/en-us/library/windows/desktop/aa378932(v=vs.85).aspx

0
source share

All Articles