WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Dialog Editor version 6.X
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Dialog Coordinates

 Keywords: dialog coordinates width height

Question:

what are the units of the dialog coordinates (x,y,width,height)

not virtual units, like boxes, is it

i figured out that full screen is about width=572, height=400

what is the dependence on screen resolution ?

Answer:

The numbers used for "x-origin", "y-origin", "box-width", "box-height", "x", "y", "width," and "height" are expressed in a unit of measure known as "Dialog Units."

Basically speaking:

1 width unit   =   1/4 width of system font.
1 height unit  =   1/8 height of system font.
4 units wide   =   Average width of the system font.
8 units high   =   Average height of the system font.
Dialog box sizes are related to system font sizes. There is a WinMetrics function in the WIL.HLP file to help you figure out what current Dialog unit size is.


You might want to check out article W14580 and see how it works to position the dialog in a corner.


Here's some code a user posted a while ago to make a splash screen centered at a constant size regardless of resolution. Basically, you get your screen size in dialog units by taking dimensions in pixels (WinMetrics 0 & 1, and dividing by pixels per dialog unit (WinMetrics -6 & -5).

ScreenWidth =WinMetrics(0)/WinMetrics(-6)                  ;Determine screen width in dialog units
ScreenHeight=WinMetrics(1)/WinMetrics(-5)                  ;Determine screen height in dialog units
;Message (ScreenWidth,ScreenHeight)
DlgWidth =ScreenWidth*0.663                                ;Make splash screen 2/3 width of screen
DlgHeight=ScreenHeight*0.5                                 ;Make splash screen 1/2 height of screen
DlgX=(ScreenWidth-DlgWidth)  /2                            ;Determine X co-ordinate for splash screen to be centered
DlgY=(ScreenHeight-DlgHeight)/2                            ;Determine Y co-ordinate for splash screen to be centered

TextWidth=162                                             
TextHeight=30
TextX=(DlgWidth-TextWidth)  /2                             ;Determine X co-ordinate for label to be centered
TextY=(DlgHeight-TextHeight)/2                             ;Determine Y co-ordinate for label to be centered

DlgCaption="Splash Test"                                   ;Get name of dialog window for later reference
DlgCount=5                                                ;Set length of display in seconds

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
;FixBox : Sets window style.                                                      ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
;Win   : window name                                                              ;
;flags : Use '&' to combine flags                                                 ;
;        ~262144    unresizable                                                   ;
;        ~65536     remove maximize                                               ;
;        ~131072    remove minimize                                               ;
;        ~12582912  remove caption                                                ;
;        ~524288    remove system menu                                            ;
;        2147483648 pop up mode                                                   ;
;        8388608    pop up mode with border                                       ;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
#DefineFunction FixBox(Win,Flags)                          ;Originally by Guido, with some liberties taken by Marc Worrel
hwnd=DllHwnd (Win)                                         ;Get window handle
User32 = StrCat(DirWindows(1),"USER32.DLL")
OldStyle=DllCall(User32, long:"GetWindowLongA",long:hwnd,long:-16)
NewStyle=OldStyle & Flags
Result = DllCall(User32,long:"SetWindowLongA",long:hwnd,long:-16,long:NewStyle)
;Display can glitch until window is refreshed, so convince it has moved by moving it to its own current position
CurPos = Arrayize(WinPosition(Win),",")                      
WinPlace (CurPos[0],CurPos[1],CurPos[2],CurPos[3],Win)
IntControl (54,Win,1,0,0)
Return (Result)
#EndFunction

#DefineSubRoutine   DlgCallback (DlgName,DlgEvent,DlgCtrlNo,param4,param5)
InitDialog = 0
TimerTick  = 1
   Switch DlgEvent
      Case InitDialog
         Count=DlgCount                                    ;Set initial count
         FixBox (DlgCaption,8388608)                       ;Get rid of window caption and create frame
         DialogProcOptions (DlgName,TimerTick,1000)        ;Set 1 second timer event
         Return (-2)
      Case TimerTick
         Count=Count-1
         If Count==0 Then Return (1)
         Return(-2)
   EndSwitch 
   Return(-2) 
#EndSubRoutine

frmSplashFormat=`WWWDLGED,6.1`
frmSplashCaption=DlgCaption
frmSplashX=DlgX
frmSplashY=DlgY
frmSplashWidth=DlgWidth
frmSplashHeight=DlgHeight
frmSplashNumControls=002
frmSplashProcedure=`DlgCallback`
frmSplashFont=`DEFAULT`
frmSplashTextColor=`DEFAULT`
frmSplashBackground=`DEFAULT,DEFAULT`
frmSplashConfig=123
frmSplash001=`201,155,034,014,PUSHBUTTON,DEFAULT,"OK",1,1,1,DEFAULT,DEFAULT,DEFAULT`
frmSplash002=`%TextX%,%TextY%,%TextWidth%,%TextHeight%,STATICTEXT,DEFAULT,"Insert text here",DEFAULT,2,DEFAULT,"Microsoft Sans Serif|24576|40|34","0|0|128",DEFAULT`
frmSplashButtonPushed=Dialog("frmSplash",1)


Article ID:   W15460
File Created: 2014:07:18:09:50:36
Last Updated: 2014:07:18:09:50:36