Click here to Skip to main content
15,911,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WebBrowser - browse in one window Pin
igor19602-Oct-03 6:45
igor19602-Oct-03 6:45 
GeneralRe: WebBrowser - browse in one window Pin
rrrado2-Oct-03 23:36
rrrado2-Oct-03 23:36 
GeneralRe: WebBrowser - browse in one window Pin
igor19603-Oct-03 6:30
igor19603-Oct-03 6:30 
GeneralCListCtrl derived class not receiving WM_VSCROLL Pin
b_girl1-Oct-03 4:30
b_girl1-Oct-03 4:30 
GeneralRe: CListCtrl derived class not receiving WM_VSCROLL Pin
Mike Dimmick1-Oct-03 12:14
Mike Dimmick1-Oct-03 12:14 
GeneralRe: CListCtrl derived class not receiving WM_VSCROLL Pin
b_girl2-Oct-03 3:27
b_girl2-Oct-03 3:27 
GeneralSetting the packet priority! Pin
tongc1-Oct-03 4:30
tongc1-Oct-03 4:30 
QuestionHiding the main app window created by ShellExecuteEx? Pin
Kayembi1-Oct-03 3:34
Kayembi1-Oct-03 3:34 
Hi,

I have launched an executable from my program using ShellExecuteEx(). However, I want this program initially to run in the background in a hidden state. Setting the nShow property of the SHELLEXECUTEINFO structure to SW_HIDE in this instance doesn't work - presumably because the launched program won't allow it (in accordance with what it says on MSDN, ie. that this info is passed to the program but it's up to the program how to use it). Thus, I guess I need to explicitly call ShowWindow with SW_HIDE set to hide the window created. The problem is, how do I do this effectively, so that the main window of the program launched is hidden from the very start? At the moment I am using FindWindow(), like this:

<br />
ShellExecuteEx(&app);<br />
<br />
HWND app_hWnd;<br />
<br />
while(app_hWnd == 0)	//loop until app window is found<br />
{<br />
	//if there is an error and the app closes, leave loop:<br />
	if(WaitForSingleObject(app.hProcess,0)==WAIT_TIMEOUT)<br />
	{		<br />
		ShowWindow((app_hWnd = FindWindow("app_mainwin",NULL)),SW_HIDE);<br />
<br />
		//Ensure loading window is updated if anything happens in the meantime:<br />
		if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))<br />
		{<br />
			TranslateMessage(&msg);<br />
			DispatchMessage(&msg);<br />
		}<br />
	}<br />
	else<br />
	{break;}	//if app has quit (eg. error), exit loop so we can end the program normally<br />
}<br />


This isn't a great solution, though, as the launched program window is shown for a couple of seconds before FindWindow() and ShowWindow() catch it and hide it.

Does anybody know of a better way of doing this, so that the launched application window is not shown at all until I call ShowWindow again with SW_SHOW?

...Talking of which, I have a secondary problem relating to this. When I do call ShowWindow(app_hWnd,SW_SHOW) to restore the window, even after the window is shown again, it does not appear in the taskbar until I alt-tab out of it and back in again. How do I ensure that a program's window is restored to the taskbar on re-showing it? (I have tried SW_RESTORE, SW_SHOWNORMAL etc...)

Any suggestions or help much appreciated, as always.
Many thanks,
KB
AnswerRe: Hiding the main app window created by ShellExecuteEx? Pin
jmkhael1-Oct-03 5:21
jmkhael1-Oct-03 5:21 
GeneralRe: Hiding the main app window created by ShellExecuteEx? Pin
Kayembi1-Oct-03 5:37
Kayembi1-Oct-03 5:37 
GeneralRe: Hiding the main app window created by ShellExecuteEx? Pin
jmkhael1-Oct-03 5:50
jmkhael1-Oct-03 5:50 
GeneralRe: Hiding the main app window created by ShellExecuteEx? Pin
David Crow1-Oct-03 7:16
David Crow1-Oct-03 7:16 
AnswerRe: Hiding the main app window created by ShellExecuteEx? Pin
igor19601-Oct-03 8:09
igor19601-Oct-03 8:09 
AnswerRe: Hiding the main app window created by ShellExecuteEx? Pin
Anthony_Yio1-Oct-03 15:48
Anthony_Yio1-Oct-03 15:48 
GeneralRe: Hiding the main app window created by ShellExecuteEx? Pin
Kayembi2-Oct-03 0:04
Kayembi2-Oct-03 0:04 
GeneralRe: Hiding the main app window created by ShellExecuteEx? Pin
David Crow2-Oct-03 2:59
David Crow2-Oct-03 2:59 
GeneralGDI + : Dynamic Pen Pin
arturapps1-Oct-03 3:12
arturapps1-Oct-03 3:12 
GeneralRe: GDI + : Dynamic Pen Pin
Frank K1-Oct-03 20:27
Frank K1-Oct-03 20:27 
GeneralBrowser in new window Pin
Shah Shehpori1-Oct-03 2:23
sussShah Shehpori1-Oct-03 2:23 
GeneralRe: Browser in new window Pin
David Crow1-Oct-03 3:47
David Crow1-Oct-03 3:47 
GeneralRe: Browser in new window Pin
RobJones1-Oct-03 5:00
RobJones1-Oct-03 5:00 
QuestionHow to move character or word on screen Pin
sunju1-Oct-03 2:10
sunju1-Oct-03 2:10 
AnswerRe: How to move character or word on screen Pin
David Crow1-Oct-03 5:00
David Crow1-Oct-03 5:00 
AnswerRe: How to move character or word on screen Pin
Terry O'Nolley1-Oct-03 15:51
Terry O'Nolley1-Oct-03 15:51 
GeneralEnumWindows Pin
Jadeja1-Oct-03 0:20
Jadeja1-Oct-03 0:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.