User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 425,978 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,672 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1168 | Replies: 7 | Solved
Reply
Join Date: Feb 2008
Posts: 40
Reputation: vedmack is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
vedmack vedmack is offline Offline
Light Poster

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

  #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

HWND hWnd = FindWindow(NULL, sName);
if(hWnd)
{
	ShowWindow(hWnd, SW_HIDE);
}

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....
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,174
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 38
Solved Threads: 930
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

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

  #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.
HWND hWnd = FindWindow(NULL, sName);
if(hWnd)
{
	ShowWindow(hWnd, SW_HIDE);
	ShowWindow(hWnd, SW_HIDE);
}
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: Apr 2008
Posts: 27
Reputation: marco93 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 4
marco93 marco93 is offline Offline
Light Poster

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

  #3  
May 7th, 2008
Originally Posted by Ancient Dragon View Post
Try calling ShowWindow twice


Is it a joke ?!
Reply With Quote  
Join Date: Mar 2006
Location: Bangalore, India
Posts: 167
Reputation: dubeyprateek is an unknown quantity at this point 
Rep Power: 3
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" ???

  #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  
Join Date: Mar 2006
Location: Bangalore, India
Posts: 167
Reputation: dubeyprateek is an unknown quantity at this point 
Rep Power: 3
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" ???

  #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  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,174
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 38
Solved Threads: 930
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

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

  #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.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Reply With Quote  
Join Date: Feb 2008
Posts: 40
Reputation: vedmack is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
vedmack vedmack is offline Offline
Light Poster

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

  #7  
May 8th, 2008
thx 4 the help Ancient Dragon, i will try it and will post the results...
Reply With Quote  
Join Date: Feb 2008
Posts: 40
Reputation: vedmack is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
vedmack vedmack is offline Offline
Light Poster

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

  #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:

myClass::FocusP(str);
myClass::Hidep(str);
...
...
...
void myClass::FocusP(CString str)
{
	HWND hWnd = FindWindow(NULL, str);
	if(hWnd){
		ShowWindow(hWnd, SW_MINIMIZE);
		ShowWindow(hWnd, SW_HIDE);
		
	}
}

void myClass::Hidep(CString str)
{
	HWND hWnd = FindWindow(NULL, str);
	if(hWnd){
		ShowWindow(hWnd, SW_HIDE);
	}
}

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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the C++ Forum

All times are GMT -4. The time now is 11:21 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC