943,948 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 12941
  • C++ RSS
May 7th, 2008
0

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

Expand Post »
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

C++ Syntax (Toggle Plain Text)
  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....
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vedmack is offline Offline
59 posts
since Feb 2008
May 7th, 2008
0

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

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.
C++ Syntax (Toggle Plain Text)
  1. HWND hWnd = FindWindow(NULL, sName);
  2. if(hWnd)
  3. {
  4. ShowWindow(hWnd, SW_HIDE);
  5. ShowWindow(hWnd, SW_HIDE);
  6. }
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005
May 7th, 2008
0

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

Try calling ShowWindow twice
Is it a joke ?!
Reputation Points: -76
Solved Threads: 14
Junior Poster
marco93 is offline Offline
132 posts
since Apr 2008
May 7th, 2008
0

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

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 ?
Reputation Points: 39
Solved Threads: 24
Junior Poster
dubeyprateek is offline Offline
176 posts
since Mar 2006
May 7th, 2008
0

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

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.
Reputation Points: 39
Solved Threads: 24
Junior Poster
dubeyprateek is offline Offline
176 posts
since Mar 2006
May 7th, 2008
-1

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

Click to Expand / Collapse  Quote originally posted by marco93 ...
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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005
May 8th, 2008
0

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

thx 4 the help Ancient Dragon, i will try it and will post the results...
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vedmack is offline Offline
59 posts
since Feb 2008
May 11th, 2008
0

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

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:

C++ Syntax (Toggle Plain Text)
  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...
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vedmack is offline Offline
59 posts
since Feb 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Marital tax revamped
Next Thread in C++ Forum Timeline: Is this normal?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC