Skip to main content

[archive] Maximize a window in another application?

  • November 26, 2009
  • 7 replies
  • 0 views

[Migrated content. Thread originally posted on 26 November 2009]

Ooh, this one's a peach... :D

I have a Windows application written in another (obviously inferior) language. It writes a file which I believe contains its Window Handle, then minimizes its window and sits ticking away in the background.

Is there a way for my Acu application to cause this window to be maximized and gain focus?

7 replies

[Migrated content. Thread originally posted on 26 November 2009]

Ooh, this one's a peach... :D

I have a Windows application written in another (obviously inferior) language. It writes a file which I believe contains its Window Handle, then minimizes its window and sits ticking away in the background.

Is there a way for my Acu application to cause this window to be maximized and gain focus?
If you really have the window handle, you could try using the ShowWindow API call, I have never used it, but it might give you a starting point.

77  WND-SYS-HANDLE           PIC 9(9) COMP-5.

SET ENVIRONMENT "DLL-CONVENTION" TO 1. 
CALL "USER32.DLL".
CALL "ShowWindow" USING
       BY VALUE WND-SYS-HANDLE
       BY VALUE 3   | See values below
END-CALL.
CANCEL "USER32.DLL".

***************
* SW_HIDE = 0
* SW_MAXIMIZE = 3
* SW_MINIMIZE = 6
* SW_RESTORE = 9
* SW_SHOW = 5
* SW_SHOWDEFAULT = 10
* SW_SHOWMAXIMIZED = 3
* SW_SHOWMINIMIZED = 2
* SW_SHOWMINNOACTIVE = 7
* SW_SHOWNA = 8
* SW_SHOWNOACTIVATE = 4
* SW_SHOWNORMAL = 1

[Migrated content. Thread originally posted on 26 November 2009]

Ooh, this one's a peach... :D

I have a Windows application written in another (obviously inferior) language. It writes a file which I believe contains its Window Handle, then minimizes its window and sits ticking away in the background.

Is there a way for my Acu application to cause this window to be maximized and gain focus?
Mikalodeon, that works beautifully! Many thanks.

[Migrated content. Thread originally posted on 26 November 2009]

Ooh, this one's a peach... :D

I have a Windows application written in another (obviously inferior) language. It writes a file which I believe contains its Window Handle, then minimizes its window and sits ticking away in the background.

Is there a way for my Acu application to cause this window to be maximized and gain focus?
Mikalodeon, that works beautifully! Many thanks.

[Migrated content. Thread originally posted on 26 November 2009]

Ooh, this one's a peach... :D

I have a Windows application written in another (obviously inferior) language. It writes a file which I believe contains its Window Handle, then minimizes its window and sits ticking away in the background.

Is there a way for my Acu application to cause this window to be maximized and gain focus?
Glad to hear it, microsofts msdn is your friend. :-)

[Migrated content. Thread originally posted on 26 November 2009]

Ooh, this one's a peach... :D

I have a Windows application written in another (obviously inferior) language. It writes a file which I believe contains its Window Handle, then minimizes its window and sits ticking away in the background.

Is there a way for my Acu application to cause this window to be maximized and gain focus?
Glad to hear it, microsofts msdn is your friend. :-)

[Migrated content. Thread originally posted on 26 November 2009]

Ooh, this one's a peach... :D

I have a Windows application written in another (obviously inferior) language. It writes a file which I believe contains its Window Handle, then minimizes its window and sits ticking away in the background.

Is there a way for my Acu application to cause this window to be maximized and gain focus?
Glad to hear it, microsofts msdn is your friend. :-)

[Migrated content. Thread originally posted on 26 November 2009]

Ooh, this one's a peach... :D

I have a Windows application written in another (obviously inferior) language. It writes a file which I believe contains its Window Handle, then minimizes its window and sits ticking away in the background.

Is there a way for my Acu application to cause this window to be maximized and gain focus?
Just for completeness, I had a note from the guy who's working on this:

FYI, slight change, as this was only working when the other application was the previous window.

Added an extra call first :

CALL "SetForegroundWindow" using
BY VALUE WND-SYS-HANDLE
END-CALL

This brings the other application window to the front first and then I maximise. It is a function from
the same dll.