Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The meaning of SW_SHOW and SW_SHOWNORMAL

Tags:

winapi

In my apps I use sometimes: ShowWindow(MyForm.Handle, SW_SHOW).

The documentation for ShowWindow function has a section for SW_SHOWNORMAL that says

"An application should specify this flag when displaying the window for the first time".

Does it means that for every form (that I pass to ShowWindow) I need to keep a boolean var to see if the form was displayed or not and based on that I should use SW_SHOW or SW_SHOWNORMAL?

What is the deep meaning of SW_SHOWNORMAL?

like image 903
Server Overflow Avatar asked Jul 05 '13 12:07

Server Overflow


2 Answers

The term normal is synonymous with restored. This terminology dates back to older versions of windows and nowadays all the MSDN documentation uses restored rather than normal or normalized.

So, SW_SHOWNORMAL sets the window state to restored and makes the window visible. On the other hand, SW_SHOW simply makes the window visible.

Back in the day, restored was called normalized, minimized was called iconic, and maximized was called full screen. If memory serves, that older terminology was still in use in Windows 3.1, but was changed with Windows 95 and NT.

like image 113
David Heffernan Avatar answered Oct 07 '22 03:10

David Heffernan


SW_SHOW is often used in conjunction with SW_HIDE so if you were showing/hiding a window for some reason (e.g. based on a user action) you would use them in tandem. SW_SHOWNORMAL was originally used in the 'old' days when first showing a window.

SW_SHOWNORMAL is sometimes valuable if you want to make sure a window is not minimized (or maximized) at some particular point in the program (e.g. if the window might be minimized but you want to 'restore' it so the user can interact with it).

like image 45
edtheprogrammerguy Avatar answered Oct 07 '22 05:10

edtheprogrammerguy