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 Units Explained


Dialog units are apparently based on the system font, DPI, and screen resolution. System font is defined as the default font defined by Windows.

Note: 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.
The WinMetrics function in the Windows Interface Language help file can help you figure out what current Dialog unit size is.
pixperunit_horz = WinMetrics(-5)
pixperunit_vert = WinMetrics(-6)
Use WinMetrics to translate dialog units to pixels:
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)
This information can be used for calculations as follows:
DlgWidth = ScreenWidth*0.663 ;Make a dialog 2/3 width of screen
DlgHeight= ScreenHeight*0.5  ;Make a dialog 1/2 height of screen
DlgX=(ScreenWidth-DlgWidth) /2 ;Determine X co-ordinate for a dialog to be centered
DlgY=(ScreenHeight-DlgHeight)/2;Determine Y co-ordinate for a dialog to be centered
Here is some code that can translate dialog units to pixels on the fly, that also might be helpful:
; Converts horizontal dialog units to pixels.  (x axis)
#DefineFunction ToPixelsHorizontal(du)
	Return int(du*winmetrics(-6))
#EndFunction

; Converts virtical dialog units to pixels. ( y axis)
#DefineFunction ToPixelsVertical(du)
	Return int(du*winmetrics(-5))
#EndFunction


; Test data.
nDuX = 40  ; Horizontal dimension in du.
nDuY = 11  ; Vertical dimension in du.

; Test.
nPixelsX = ToPixelsHorizontal( nDuX )
nPixelsY = ToPixelsVertical( nDuY )

; Result.
Message("Dialog Units x = %nDuX%, y = %nDuy%", "Pixels x = %nPixelsX%, y = %nPixelsY%") 

Article ID:   W16918
File Created: 2007:07:03:14:27:04
Last Updated: 2007:07:03:14:27:04