I am writing a simple code that will hide a window, or show a window if it has been hidden. I am using showwindow() to do so.
the above works great, as it hides the window from view completely
however the above will not bring/show the window that has been hidden
I assume showwindow works differently than how I expect to make it work? what is the proper way?
VB.NET:
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As SHOW_WINDOW) As Boolean
<Flags()> Private Enum SHOW_WINDOW As Integer
SW_HIDE = 0
SW_SHOWNORMAL = 1
SW_NORMAL = 1
SW_SHOWMINIMIZED = 2
SW_SHOWMAXIMIZED = 3
SW_MAXIMIZE = 3
SW_SHOWNOACTIVATE = 4
SW_SHOW = 5
SW_MINIMIZE = 6
SW_SHOWMINNOACTIVE = 7
SW_SHOWNA = 8
SW_RESTORE = 9
SW_SHOWDEFAULT = 10
SW_FORCEMINIMIZE = 11
SW_MAX = 11
End Enum
For Each p As Process In Process.GetProcessesByName("notepad")
ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_HIDE)
Next p
VB.NET:
For Each p As Process In Process.GetProcessesByName("notepad")
ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_SHOW)
Next p
I assume showwindow works differently than how I expect to make it work? what is the proper way?