Jump to content
robben1970

how to fix the monitor where an external application has to appear

Recommended Posts

Hello

i have a pc with more monitors and i can execute a delphi program in any of them.

The main program could launch an external program by ShellExecute

 

ShellExecute(Handle,'open', Pchar(progname), nil, nil, SW_SHOWNORMAL) ;

 

but i want that the external program being showed on the same monitor where actually main program has been executed.

How to get it? Or there's another way than ShellExecute?

Thans for your support

 

 

Share this post


Link to post
Guest

hi @robben1970

 

I think this property would be given by the operating system, which controls where the windows would be opened on the standard screen.
In your case, perhaps, it would be interesting to use the customization that is allowed by MSWindows to edit some properties of the batch files, for example.
You can then create a ".BAT" file and edit its screen properties using the "right-button -> properties" and determine, for example, the location on the screen. Or, run this file once, and place it on the desired display. So, MSWindows will archive this information to this .bat file, do you understand?

 

Another way, via code, would be:

  • Find the running window
  • And, use the SetWindowPos (,,,,,) function of the MSWindows API, to determine the position of the window on the display.
  • To do this, you would need to use other functions, such as:
    • FindWindow (vbNullString, TextCaptionXXX) -> to find the window by its caption
    • retval = GetClassName (lHwnd, lpClassName, 256) to find the window class to use in SetWindowPos ()

 

but I don't have two monitors to test the latter method.

 

hug

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×