Opening Dialog at last position

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Opening Dialog at last position

Post by migro » Sat Aug 30, 2014 5:19 pm

Hi,

I'm saving the last position of an dialog (left and top) befor closing it.
When starting up the dialog again I'm using:

Code: Select all

         SetDialogProperty>Dialog1,,Position,poDesigned
         SetDialogProperty>Dialog1,,Left,%strWinX%
         SetDialogProperty>Dialog1,,Top,%strWinY%
This works very well on a single monitor.
Is there a possibility, when the dialog was positioned at the second monitor before closing it, to get it opened again at the second monitor?
So far as I can see, values for "Left" will be ignorend when > as the screen's wide.
regards
migro

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Opening Dialog at last position

Post by JRL » Sat Aug 30, 2014 5:50 pm

I always use MoveWindow> just because it's one line. It seems to work on dual monitors.

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Re: Opening Dialog at last position

Post by migro » Sun Aug 31, 2014 1:31 pm

Thanks JRL,

very good idea - it works well.
regards
migro

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Opening Dialog at last position

Post by CyberCitizen » Thu Oct 30, 2014 1:21 am

I'm having the same issue with dual monitors. On a single monitor, not an issue, however if its on the second screen and I save its position & then attempt to set that position again with dialog properties it appears on the default monitor (not the second one) in the rough same position as it was saved when on the second monitor. I really didn't want to use Move Window as it doesn't look as professional.
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Opening Dialog at last position

Post by JRL » Thu Oct 30, 2014 4:23 am

I really didn't want to use Move Window as it doesn't look as professional.
In what way does it not look professional? Its virtually the same thing.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Caption = 'Macro Scheduler Dialog'
end
EndDialog>Dialog1

MoveWindow>Macro Scheduler Dialog,10,10

Show>Dialog1,

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Opening Dialog at last position

Post by CyberCitizen » Thu Oct 30, 2014 5:19 am

Dont you have to Show>Dialog1 before you can move it?

Awesome, I just tested it, thanks. I thought the Window had to be visible first for that to work.
FIREFIGHTER

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Opening Dialog at last position

Post by CyberCitizen » Thu Oct 30, 2014 6:15 am

I just tried this on my second monitor, still pops the Dialog onto my primary screen.

They are running a screen res of 1680 x 1050 so 2077 should put it onto the second screen.

Dialog>Dialog1
object Dialog1: TForm
Caption = 'Macro Scheduler Dialog'
end
EndDialog>Dialog1
MoveWindow>Macro Scheduler Dialog,2077,115
Show>Dialog1,
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Opening Dialog at last position

Post by JRL » Thu Oct 30, 2014 9:40 pm

Dont you have to Show>Dialog1 before you can move it?
A dialog exists as soon as the dialog block is read. You can do about anything to it except interface with it before you show it.

I'm wondering what would happen if you run this script, move this dialog to where you want your other dialog to end up, take the coordinates from this dialog and use them in the MoveWindow> line of the other script. Does the other dialog go where its told to go? Sorry, I don't have a dual monitor to test with.

Code: Select all

If>Flag={"Flag"}

Dialog>Dialog1
object Dialog1: TForm
  Caption = 'CustomDialog'
  object Label1: TLabel
    Left = 64
    Top = 48
  end
end
EndDialog>Dialog1

  AddDialogHandler>Dialog1,,OnClose,
  Let>Flag=0
  Show>Dialog1
Else
  Let>Flag=1
EndIf

Label>Loop
  GoSub>GetPos
  If>Flag=1
    Exit>0
  EndIf
Goto>Loop

SRT>GetPos
  GetWindowPos>CustomDialog,PosX,PosY
  SetDialogProperty>Dialog1,Label1,Caption,%posx%%comma%%posy%
END>GetPos

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Opening Dialog at last position

Post by CyberCitizen » Thu Oct 30, 2014 11:27 pm

Hi,

Sorry no it doesn't, it gives the correct cords, but when you attempt to move it, it doesn't work.

Unless the dialog is already shown. If the window is visible you can move it from side to side, however while its not shown you can't always ends up on the primary monitor.
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Opening Dialog at last position

Post by JRL » Fri Oct 31, 2014 4:24 am

If the dialog can move to second monitor locations after the Show>. Perhaps you could start with the dialog Alphablended to 1, then when the Dialog is first displayed it is invisible yet on the screen. Move the dialog then turn off Alphablend and the dialog should appear in the specified location without ever visibly appearing in its unspecified monitor one location.

If the dialog was non modal this could be done with the lines in the MoveIt subroutine placed anywhere between the Show> line and the idle loop. the following should work for a modal dialog.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Caption = 'Macro Scheduler Dialog'
  Alphablend = True
  AlphablendValue = 1
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,,OnShow,MoveIt

Show>Dialog1,

SRT>MoveIt
  MoveWindow>Macro Scheduler Dialog,2077,100
  SetDialogProperty>Dialog1,,Alphablend,False
END>MoveIt

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts