ShowWindow(hWnd, SW_HIDE); Does not work -- Only with "SW_HIDE" ???

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2008
Posts: 51
Reputation: vedmack is an unknown quantity at this point 
Solved Threads: 0
vedmack vedmack is offline Offline
Junior Poster in Training

ShowWindow(hWnd, SW_HIDE); Does not work -- Only with "SW_HIDE" ???

 
0
  #1
May 7th, 2008
Heya i want to use ShowWindow(hWnd, SW_HIDE); to hide some application,

The problem is that the code i wrote works perfectly for any application except the one i need it for

heres the code

  1. HWND hWnd = FindWindow(NULL, sName);
  2. if(hWnd)
  3. {
  4. ShowWindow(hWnd, SW_HIDE);
  5. }

it does execute the line "ShowWindow(hWnd, SW_HIDE);" but it has no affect on the application, while if i put "SW_MAXIMIZE" , "SW_MINIMIZE" or any other "SW_***" it works perfectly and does manipulation on the application window,

Any idea why SW_HIDE does not work while all other SW_*** works?


Thanks Ahead....
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,358
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: ShowWindow(hWnd, SW_HIDE); Does not work -- Only with "SW_HIDE" ???

 
0
  #2
May 7th, 2008
Try calling ShowWindow twice, according to MSDN the second parameter to ShowWindow() might get ignored the first time it is called. I don't know if it will work, but its worth a try.
  1. HWND hWnd = FindWindow(NULL, sName);
  2. if(hWnd)
  3. {
  4. ShowWindow(hWnd, SW_HIDE);
  5. ShowWindow(hWnd, SW_HIDE);
  6. }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 118
Reputation: marco93 is infamous around these parts marco93 is infamous around these parts marco93 is infamous around these parts 
Solved Threads: 12
marco93 marco93 is offline Offline
Junior Poster

Re: ShowWindow(hWnd, SW_HIDE); Does not work -- Only with "SW_HIDE" ???

 
0
  #3
May 7th, 2008
Originally Posted by Ancient Dragon View Post
Try calling ShowWindow twice
Is it a joke ?!
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 176
Reputation: dubeyprateek is an unknown quantity at this point 
Solved Threads: 22
dubeyprateek's Avatar
dubeyprateek dubeyprateek is offline Offline
Junior Poster

Re: ShowWindow(hWnd, SW_HIDE); Does not work -- Only with "SW_HIDE" ???

 
0
  #4
May 7th, 2008
Does it happens with all the Windows or with any specefic Window ?
Are you trying to hide any window which you have created or any other applciaiton's Window ?
I know I am. Therefore I am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 176
Reputation: dubeyprateek is an unknown quantity at this point 
Solved Threads: 22
dubeyprateek's Avatar
dubeyprateek dubeyprateek is offline Offline
Junior Poster

Re: ShowWindow(hWnd, SW_HIDE); Does not work -- Only with "SW_HIDE" ???

 
0
  #5
May 7th, 2008
The WM_SHOWWINDOW message is sent to a window when the window is about to be hidden or shown.

I suspect the window you are trying to hide processes this message and prevents itself from hiding.

You might use Spy++ to see wheather or not this notification is send to the target Window.
I know I am. Therefore I am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,358
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: ShowWindow(hWnd, SW_HIDE); Does not work -- Only with "SW_HIDE" ???

 
-1
  #6
May 7th, 2008
Originally Posted by marco93 View Post
Is it a joke ?!
No. Did you read the link I posted? MSDN says the first time ShowWindow is called SW_HIDE might be ignored. After that SW_HIDE parameter is honored.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 51
Reputation: vedmack is an unknown quantity at this point 
Solved Threads: 0
vedmack vedmack is offline Offline
Junior Poster in Training

Re: ShowWindow(hWnd, SW_HIDE); Does not work -- Only with "SW_HIDE" ???

 
0
  #7
May 8th, 2008
thx 4 the help Ancient Dragon, i will try it and will post the results...
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 51
Reputation: vedmack is an unknown quantity at this point 
Solved Threads: 0
vedmack vedmack is offline Offline
Junior Poster in Training

Re: ShowWindow(hWnd, SW_HIDE); Does not work -- Only with "SW_HIDE" ???

 
0
  #8
May 11th, 2008
Hi again... I found the solution...

1)This phenomenon happens with only one specific window...

2)To force this window to hide I do need call the "ShowWindow(hWnd, SW_HIDE);" Twice in the following way:

  1. myClass::FocusP(str);
  2. myClass::Hidep(str);
  3. ...
  4. ...
  5. ...
  6. void myClass::FocusP(CString str)
  7. {
  8. HWND hWnd = FindWindow(NULL, str);
  9. if(hWnd){
  10. ShowWindow(hWnd, SW_MINIMIZE);
  11. ShowWindow(hWnd, SW_HIDE);
  12.  
  13. }
  14. }
  15.  
  16. void myClass::Hidep(CString str)
  17. {
  18. HWND hWnd = FindWindow(NULL, str);
  19. if(hWnd){
  20. ShowWindow(hWnd, SW_HIDE);
  21. }
  22. }

I could call twice the myClass::FocusP(str); twice, but i prefered to split it... looks better IMO


Thx 4 the help Ancient Dragon and others...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC