I heard somebody said I must use these:

screen.x = resource.x * cxChar/4;
screen.y = resource.y * cyChar/8;
screen.width = resource.width * cxChar/4;
screen.height = resource.height * cyChar/8;

where cxChar and cyChar are the width and height of a system font character in pixels.

Is that right ?
I dont know how to get width & height of a system font char in pixel ( GetTextExtentPoint32 ? )

Thanks :)
Posted on 2003-12-31 14:00:39 by santa
CONTROL "",      IDC_SPLITTER, "VSplitterCtrl", 0, 116, 5, 2, 80 

The CONTROL statement will translate to the following code:
   invoke CreateWindow ("VSplitterCtrl", "", StyleFlags,  

116 * cxChar/4, 5 * cyChar/8,
2 * cxChar/4, 80 * cyChar/8,
hWndParent, IDC_SPLITTER, hInstance, NULL

where cxChar and cyChar are the width and height of a system font character in pixels.
Posted on 2003-12-31 18:44:51 by santa
Hi,

It's true that you have to convert dialog units to pixels (I do this in the resource editor part of WinAsm Studio). When I find the time (soon), I 'll post a better reply than this one!

Regards,

akyprian
Posted on 2004-01-01 06:19:23 by akyprian
This is from the Win32 Programmer's Reference:

GetDialogBaseUnits

The GetDialogBaseUnits function returns the dialog box base units used by Windows to create dialog boxes. Both Windows and applications use these units to convert the width and height of dialog boxes and controls from dialog units, as given in dialog box templates, to pixels, and vice versa.

LONG GetDialogBaseUnits(VOID)


Parameters

This function has no parameters.

Return Values

The return value is a 32-bit value that contains the dialog base units. The low-order word of the return value contains the horizontal dialog box base unit, and the high-order word contains the vertical dialog box base unit.

Remarks

The horizontal base unit is equal to the average width, in pixels, of the characters in the system font; the vertical base unit is equal to the height, in pixels, of the font. Furthermore, each horizontal base unit is equal to 4 horizontal dialog units; each vertical base unit is equal to 8 vertical dialog units. Therefore, to convert dialog units to pixels, an application applies the following formulas:

pixelX = (dialogunitX * baseunitX) / 4
pixelY = (dialogunitY * baseunitY) / 8


Similarly, to convert from pixels to dialog units, an application applies the following formulas:

dialogunitX = (pixelX * 4) / baseunitX
dialogunitY = (pixelY * 8) / baseunitY


The multiplication is performed before the division to avoid rounding problems if base units are not divisible by 4 or 8.


MY NOTE: Do not use GetDialogBaseUnits to calculate baseunitX and baseunitY If the Dialog does not use the system font. Use GetTextExtentPoint32 instead.

I hope this helps,

akyprian
Posted on 2004-01-02 05:28:54 by akyprian
Thanks , Akyprian :grin:

You help me much :alright:
Posted on 2004-01-02 14:20:21 by santa