News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

dialog sizing

Started by component, April 01, 2010, 08:01:59 PM

Previous topic - Next topic

component

Hi thereĀ  :dance:

this is the MainDlg.Rc file
i need to know which numbers to change the size to like the size of a full web page
this dialog is from Except.zip on donkey example site...
thanksĀ 
#define IDD_DLG1 1000
#define IDC_UDC1 1001
#define IDC_BTN1 1002
#define IDC_STC2 1004
#define IDC_EDT1 1003
#define IDC_STC1 1005
#define IDC_IMG1 1006
IDD_DLG1 DIALOGEX 6,6,280,144
CAPTION "Error"
FONT 8,"MS Sans Serif"
STYLE 0x10C00800
EXSTYLE 0x00000000
BEGIN
  CONTROL "",IDC_UDC1,"UDC_HyperLink",0x50000000,8,121,76,13,0x00000000
  CONTROL "OK",IDC_BTN1,"Button",0x50010000,118,101,58,19,0x00000000
  CONTROL "An exception has occured",IDC_STC2,"Static",0x50000201,34,5,240,11,0x00000000
  CONTROL "",IDC_EDT1,"Edit",0x50210844,4,40,272,56,0x00020000
  CONTROL "Details : (this will be copied to the clipboard)",IDC_STC1,"Static",0x50000000,4,25,270,11,0x00000000
  CONTROL "",IDC_IMG1,"Static",0x50000003,4,3,21,19,0x00000000
END

clive

Quote from: component
i need to know which numbers to change the size to like the size of a full web page

IDD_DLG1 DIALOGEX 6,6,280,144

If memory serves, 280 is width in screen units, the 144 is the height. Figure how big the window is now and how many times smaller it is than you want it to be.

-Clive
It could be a random act of randomness. Those happen a lot as well.

hutch--

Clive is right, they are called "dialog units" and from a quick look at the RC code, change the 4 decimal numbers to manually code size changes.

They are normal X/Y co-ordinates for the top left and bottom right corners of the dialog.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

donkey

Dialogs sizes are given in (as Hutch said) Dialog Units which are calculated using the font of the dialog (a dialog base unit is actually the average width of a character in pixels). You can convert them to screen units using MapDialogRect, the MSDN entry also contains the formula used for the calculation. Reversing the formulae to convert from pixels to dialog units is simple math. I use the following to calculate the dialog base units:

translated to MASM:
invoke GetDC,hDlg ; << any window will do just need a screen based DC
mov hDlgDC,eax
invoke CreateCompatibleDC,hDlgDC
mov hDC,eax
invoke ReleaseDC,hDlg,hDlgDC

; Convert Point/pixel font size
invoke GetDeviceCaps,hDC,LOGPIXELSY
mul DlgXTemplate.pointsize
mov ecx,72
mov edx,0
div ecx
neg eax

; Fill the logfont structure
mov lf.lfHeight,eax
mov lf.lfWidth,0
mov lf.lfEscapement,0
mov lf.lfOrientation,0
mov lf.lfWeight,700 ; Always Bold
mov lf.lfItalic,FALSE
mov lf.lfUnderline,FALSE
mov lf.lfStrikeOut,FALSE
mov lf.lfCharSet,DEFAULT_CHARSET
mov lf.lfOutPrecision,OUT_DEFAULT_PRECIS
mov lf.lfClipPrecision,CLIP_DEFAULT_PRECIS
mov lf.lfQuality,DEFAULT_QUALITY
invoke lstrcpy,ADDR lf.lfFaceName,DlgXTemplate.pfont

; create the font and select it
invoke CreateFontIndirect,ADDR lf
mov hFont,eax
invoke SelectObject,hDC,hFont
mov OldObject,eax

; get the average sizes and calculate the base units
invoke GetTextMetrics,hDC,ADDR tm
mov eax,tm.tmAveCharWidth
shl eax,9
mov DBUX,eax ; <<<< Dialog base unit X
mov eax,tm.tmHeight
shl eax,9
mov DBUY,eax ; <<<< Dialog base unit Y

; clean it up
invoke SelectObject,hDC,OldObject
invoke DeleteDC,hDC
invoke DeleteObject,hFont


Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable