Click to See Complete Forum and Search --> : Hiding A Window You Have The Hwnd To
2MuchRiceMakesMeSick
July 17th, 2007, 02:00 AM
I have handle/id of a window and I need to create a program that will hide the window and the make it reappear when the user wants.
How can I make the window visible and then later on make it reappear?
Thanks for the help...
ashukasama
July 17th, 2007, 02:51 AM
BOOL ShowWindow(
HWND hWnd,
int nCmdShow
);
hWnd
[in] Handle to the window.
nCmdShow
[in] Specifies how the window is to be shown
SW_HIDE - Hides the window and activates another window.
SW_SHOW - Activates the window and displays it in its current size and position.
SW_SHOWNA - Displays the window in its current state. The active window remains active.
SW_SHOWNORMAL - Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
2MuchRiceMakesMeSick
July 17th, 2007, 03:32 AM
thanks for the help...any ideas on why this wont work?
[DllImport("user32")] extern IntPtr FindWindow(String ^ lpClassName, String ^ lpWindowName);
[DllImport("user32")] extern int ShowWindow(IntPtr ^ hwnd, int nCmdShow);
IntPtr ^ iPtr = FindWindow ("Notepad", "Untitled - Notepad");
MessageBox::Show(iPtr->ToString()); // this does return the a positive number
ShowWindow (iPtr,1);
ashukasama
July 17th, 2007, 06:47 AM
sorry i reply you for unmanaged code
now solution :wave:
[DllImport("user32")] extern IntPtr FindWindow(String ^ lpClassName, String ^ lpWindowName);
[DllImport("user32")] extern int ShowWindow(IntPtr ^ hwnd, int nCmdShow);
it should be
[DllImport("user32")]
extern int ShowWindow(IntPtr hwnd, int nCmdShow);
IntPtr ^ iPtr = FindWindow ("Notepad", "Untitled - Notepad");
it should be
IntPtr iPtr = FindWindow ("Notepad", "Untitled - Notepad");
i think you understand what is the problem
:)
2MuchRiceMakesMeSick
July 17th, 2007, 06:51 AM
thanks for the help. I did change those lines and findwindow finds the handle to the window but "ShowWindow (iPtr,1);" does not hide the window. i am stumped on this one.
2MuchRiceMakesMeSick
July 17th, 2007, 06:55 AM
err..... ShowWindow (iPtr,0); hides the window.
Thanks for the help!!!
2MuchRiceMakesMeSick
July 17th, 2007, 06:58 AM
now ... does anyone know how to get the icon out of the system tray???
ashukasama
July 17th, 2007, 07:01 AM
thanks for the help. I did change those lines and findwindow finds the handle to the window but "ShowWindow (iPtr,1);" does not hide the window. i am stumped on this one.
for hiding use
ShowWindow (iPtr,0);
Krishnaa
July 17th, 2007, 07:49 AM
now ... does anyone know how to get the icon out of the system tray???
Is you created there by you ?? You can use Shell_NotifyIcon Function (http://msdn2.microsoft.com/en-us/library/ms647738.aspx) to remove it.
2MuchRiceMakesMeSick
July 17th, 2007, 08:11 AM
no its not created by me..its an external program. will shell notify still work?
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.