ShellExecute 
Author Message
 ShellExecute

I am playing around with ShellExecute using some tips from this group.
I discovered that some older 32 bit Windows programs and 16 bit
programs need to be open before ShellExecute will properly bring them
forward. Otherwise they seem to be loaded but cannot be accessed.

Is there any solution to this? A way to bring the window forward
perhaps? Thanks.
--
John

(Spam avoidance: Actual address has one S.)



Fri, 07 Mar 2003 03:00:00 GMT  
 ShellExecute
John,

If you know the window title you can use FindWindow() and
SetForegroundWindow():

DECLARE INTEGER SetForegroundWindow IN WIN32API INTEGER

declare integer FindWindow in win32api ;
  string lpClassName, ; && pointer to class name
  string lpWindowName && pointer to window name

lnHwnd = FindWindow( .null., "appsingleton.prg - Notepad" )

SetForegroundWindow( lnHwnd )

--
df    - (Microsoft FoxPro MVP) http://www.geocities.com/df_FoxPro/

Quote:

> I am playing around with ShellExecute using some tips from this group.
> I discovered that some older 32 bit Windows programs and 16 bit
> programs need to be open before ShellExecute will properly bring them
> forward. Otherwise they seem to be loaded but cannot be accessed.

> Is there any solution to this? A way to bring the window forward
> perhaps? Thanks.



Sat, 08 Mar 2003 11:38:14 GMT  
 ShellExecute
Could I reference the window with the result from this?

hDCScreen=GetDesktopWindow()

This is already used to call ShellExecute.

I'll give your idea a try. My concern is that I won't know the window
name any more than the program that calls the file unless I also have
some kind of file extension registration program in my Fox app, which
is another brainstorm I might pursue.

Thanks for spurring some ideas.

On Tue, 19 Sep 2000 03:38:14 GMT, "David Frankenbach"

Quote:

>If you know the window title you can use FindWindow() and
>SetForegroundWindow():

>DECLARE INTEGER SetForegroundWindow IN WIN32API INTEGER

>declare integer FindWindow in win32api ;
>  string lpClassName, ; && pointer to class name
>  string lpWindowName && pointer to window name

>lnHwnd = FindWindow( .null., "appsingleton.prg - Notepad" )

>SetForegroundWindow( lnHwnd )

>--
>df    - (Microsoft FoxPro MVP) http://www.geocities.com/df_FoxPro/


>> I am playing around with ShellExecute using some tips from this group.
>> I discovered that some older 32 bit Windows programs and 16 bit
>> programs need to be open before ShellExecute will properly bring them
>> forward. Otherwise they seem to be loaded but cannot be accessed.

>> Is there any solution to this? A way to bring the window forward
>> perhaps? Thanks.

--
John

(Spam avoidance: Actual address has one S.)


Sat, 08 Mar 2003 03:00:00 GMT  
 ShellExecute
I gave this the college try but even if I type the name of the window
into the code it will not bring the window forward. I've tried this
with a 16 bit Windows program and the first 32 bit release of
Microsoft Works. It's out there, Alt+Tab shows it and the 3 finger
salute is necessary to close it, but I can't make it visible.

I appreciate the tip. If anything else comes to mind, please post it.
Thanks.

On Tue, 19 Sep 2000 03:38:14 GMT, "David Frankenbach"

Quote:

>If you know the window title you can use FindWindow() and
>SetForegroundWindow():

--
John

(Spam avoidance: Actual address has one S.)


Sat, 08 Mar 2003 03:00:00 GMT  
 ShellExecute
John,

Quote:

> Could I reference the window with the result from this?

> hDCScreen=GetDesktopWindow()

No, this code gets a handle to the Windows desktop to use as the parent
window of the spawned process.
--
df    - (Microsoft FoxPro MVP) http://www.geocities.com/df_FoxPro/


Sun, 09 Mar 2003 10:51:53 GMT  
 ShellExecute
John,

I don't think I have any old 16 bit apps to even run tests with. Have you
tried using any of the other showwindow constants? The values are detailed
in foxpro.h
--
df    - (Microsoft FoxPro MVP) http://www.geocities.com/df_FoxPro/

Quote:

> I gave this the college try but even if I type the name of the window
> into the code it will not bring the window forward. I've tried this
> with a 16 bit Windows program and the first 32 bit release of
> Microsoft Works. It's out there, Alt+Tab shows it and the 3 finger
> salute is necessary to close it, but I can't make it visible.



Sun, 09 Mar 2003 10:56:05 GMT  
 ShellExecute
David,

I'll look into the other constants. In the meantime, I don't think
ShellExecute is completely working properly.

I've had a problem bringing forward WinZip and MSPaint as well.
They'll only work if they were opened first. Seems to be older 32 bit
programs. Also, after the file is closed down, there is still a
reference to the calling program when you look at the Task Manager
with Ctrl+Alt+Del. This happened with IE5.

Is there a way to get rid of them completely? Is this just the window
left behind? Thanks so much for your continued follow up.

On Wed, 20 Sep 2000 02:56:05 GMT, "David Frankenbach"

Quote:

>I don't think I have any old 16 bit apps to even run tests with. Have you
>tried using any of the other showwindow constants? The values are detailed
>in foxpro.h
>--
>df    - (Microsoft FoxPro MVP) http://www.geocities.com/df_FoxPro/


>> I gave this the college try but even if I type the name of the window
>> into the code it will not bring the window forward. I've tried this
>> with a 16 bit Windows program and the first 32 bit release of
>> Microsoft Works. It's out there, Alt+Tab shows it and the 3 finger
>> salute is necessary to close it, but I can't make it visible.

--
John

(Spam avoidance: Actual address has one S.)


Sun, 09 Mar 2003 12:00:28 GMT  
 ShellExecute
David,

I'm an idiot! I used 0 as the last parameter, which is to open a
window and hide it. Duh! Setting it to 1 opens in it's last size, 3
maximizes it. Sorry it took me so long and thanks for the continued
follow up.

On Wed, 20 Sep 2000 02:56:05 GMT, "David Frankenbach"

Quote:

>John,

>I don't think I have any old 16 bit apps to even run tests with. Have you
>tried using any of the other showwindow constants? The values are detailed
>in foxpro.h
>--
>df    - (Microsoft FoxPro MVP) http://www.geocities.com/df_FoxPro/


>> I gave this the college try but even if I type the name of the window
>> into the code it will not bring the window forward. I've tried this
>> with a 16 bit Windows program and the first 32 bit release of
>> Microsoft Works. It's out there, Alt+Tab shows it and the 3 finger
>> salute is necessary to close it, but I can't make it visible.

--
John

(Spam avoidance: Actual address has one S.)


Sun, 09 Mar 2003 03:00:00 GMT  
 ShellExecute
John,

When you open the application it becomes an independent task running. The
user would normally close that app once they are done with it. Look at the
SendMessage() API call if you want to send a message to the other
application requesting it to shutdown.
--
df    - (Microsoft FoxPro MVP) http://www.geocities.com/df_FoxPro/

Quote:

> David,

> I'll look into the other constants. In the meantime, I don't think
> ShellExecute is completely working properly.

> I've had a problem bringing forward WinZip and MSPaint as well.
> They'll only work if they were opened first. Seems to be older 32 bit
> programs. Also, after the file is closed down, there is still a
> reference to the calling program when you look at the Task Manager
> with Ctrl+Alt+Del. This happened with IE5.

> Is there a way to get rid of them completely? Is this just the window
> left behind? Thanks so much for your continued follow up.



Mon, 10 Mar 2003 03:00:00 GMT  
 ShellExecute
John,

Every little bit matters *g* Glad you got it working.
--
df    - (Microsoft FoxPro MVP) http://www.geocities.com/df_FoxPro/

Quote:

> David,

> I'm an idiot! I used 0 as the last parameter, which is to open a
> window and hide it. Duh! Setting it to 1 opens in it's last size, 3
> maximizes it. Sorry it took me so long and thanks for the continued
> follow up.



Mon, 10 Mar 2003 03:00:00 GMT  
 ShellExecute
Here's some text for your web site. Maybe you have it already. If not,
my little thanks for you help. The first set shows some common errors
that are returned, the next shows common window sizes.

declare long ShellExecute ...
local merror,mtext
merror=ShellExecute(GetDesktopWindow(),'open',cFilename,cParameter,sys(2023),1)
*clear dlls     && optional
if merror<33 && otherwise it's the window handle
mtext=iif(merror=2 or merror=3,'File was not found!',;
        iif(merror=5,'Network sharing error!',;
        iif(merror=8,'Insufficient memory!',;
        iif(merror=11 or merror=20,'Invalid Exe or Dll file!',;
        'Unspecified error '+str(merror,2,0)))))
messagebox(mtext,16,'Error')
endif

Last parameter for ShellExecute()
      0  Hides the window and passes activation to another window.
      1  Activates and displays a window. If the window is minimized
or maximized, Windows restores it to its original size and position.
      2  Activates a window and displays it as an icon.
      3  Activates a window and displays it as a maximized window.
      4  Displays a window in its most recent size and position. The
window that is currently active remains active.
      5  Activates a window and displays it in its current size and
position.
      7  Displays a window as an icon. The window that is currently
active remains active.

On Thu, 21 Sep 2000 01:53:34 GMT, "David Frankenbach"

Quote:

>Every little bit matters *g* Glad you got it working.
>--
>df    - (Microsoft FoxPro MVP) http://www.geocities.com/df_FoxPro/


>> I'm an idiot! I used 0 as the last parameter, which is to open a
>> window and hide it. Duh! Setting it to 1 opens in it's last size, 3
>> maximizes it. Sorry it took me so long and thanks for the continued
>> follow up.

--
John

(Spam avoidance: Actual address has one S.)


Mon, 10 Mar 2003 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Pb with Shellexecute

2. ShellExecute

3. ShellExecute with long names...

4. ShellExecute/Print

5. Shellexecute

6. shellexecute

7. Shellexecute and opening blank word document

8. How do I use ShellExecute and WaitForSingleObject ?

9. ShellExecute & VFP7

10. ShellExecute Question

11. ShellExecute API function

12. ShellExecute Done?

 

 
Powered by phpBB® Forum Software