Subroutine for Placement of Dialogs

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Subroutine for Placement of Dialogs

Post by kpassaur » Tue Apr 07, 2009 8:34 am

On occasion it is useful for dialogs to be placed in different locations. So, I wrote this subroutine and dropped it in my Snippets - hopefully someone else will find it useful as well.



LibFunc>user32,GetSystemMetrics,screen_width,0
LibFunc>user32,GetSystemMetrics,screen_height,1

/*
This will allow a user to select the location of a Dialog Box by using, North,
South, Northwest, Southwest, Northeast, Southeast

It was written so that it is a Subroutine that can be called over and over again for different placements of different Dialogs

Enter DW for the Dialog Width and DH for the Dialog Height of the Dialog Box.

Change the Top and Left in the Dialog to be Top=%top% Left=%left%
Bottom will be the Screen_heigth - Dialog highth + 30 to compensate for the Task Bar
*/

Let>DW=449
Let>DH=147
Let>Placement=Northwest

GoSub>Dialoglocation

SRT>Dialoglocation
GoSub>%Placement%

SRT>North
Let>width={%DW%/2}
Let>screen_width={%screen_width% / 2}
Let>left={%screen_width% - %width%}
Let>left={Round(%left%)}
Let>top=0
END>North

SRT>South
Let>width={%DW%/2}
Let>screen_width={%screen_width% / 2}
Let>left={%screen_width% - %width%}
Let>left={Round(%left%)}
Let>dh=%DH%+30
Let>top={%screen_height% - %dh%}
END>South

SRT>Northwest
Let>top=0
Let>left=0
END>Northwest

SRT>Southeast
Let>dh=%DH%+30
Let>top={%screen_height% - %dh%}
Let>Left=0
END>Southeast

SRT>Southwest
Let>width=%DW%
Let>left={%screen_width% - %width%}
Let>left=%left%-5
Let>dh=%DH%+30
Let>top={%screen_height% - %dh%}
END>Southwest

SRT>Northwest
Let>width=%DW%
Let>left={%screen_width% - %width%}
Let>left=%left%-5
Let>dh=%DH%+30
Let>top=0
END>Northwest


Dialog>Dialog1
Caption=Menu Position
Width=449
Height=147
Top=%top%
Left=%left%
Max=0
Min=0
Close=1
Resize=0
Button=E&xit,184,59,65,23,2
Label=TEST Dialog Position,170,24,true
EndDialog>Dialog1
END>Dialoglocation


Label>Mainloop
Show>Dialog1,r
If>r=2,EOF
Goto>Mainloop

Label>EOF

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