Dialog Units

 

 

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 can help you calculate pixels per Dialog unit size.

pixperunit_horz = WinMetrics(-5)

pixperunit_vert = WinMetrics(-6)

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 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 translates dialog units to pixels:

; Converts horizontal dialog units to pixels.  (x axis)

#DefineFunction ToPixelsHorizontal(du)

   Return int(du*winmetrics(-6))

#EndFunction

 

; Converts vertical dialog units to pixels. ( y axis)

#DefineFunction ToPixelsVertical(du)

Return int(du*winmetrics(-5))

#EndFunction

 

; Test data.

nDuX = 40  ; Horizontal dimension in dialog units.

nDuY = 11  ; Vertical dimension in dialog units.

 

; Test.

nPixelsX = ToPixelsHorizontal( nDuX )

nPixelsY = ToPixelsVertical( nDuY )

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

 

 

 

 

§         Dialog

§         Dialog Overview

§         Defining the Dialog

§         Defining the Dialog Controls

§         Dialog Control Types

§         Dynamic Dialogs

§         InternetExplorer Controls

§         Dialog Units

§         Dialog Fonts

 

Control Types

§         Calendar

§         Checkbox

§         ComControl

§         DropListbox

§         Editbox

§         FileListbox

§         Groupbox

§         Itembox

§         MenuBar

§         MenuItem

§         MultiLinebox

§         Picture

§         PictureButton

§         PushButton

§         RadioButton

§         ReportView

§         Spinner

§         StaticText

§         VaryText