WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Metric of rc files - GetDialogBaseUnits, convert dialog units to pixels and vice-versa; what height and width should I use to get a square?

hare14
Quote Post


New Member
*

Group: Members
Posts: 1
Member No.: 827
Joined: 4-December 04


hey,
you have done a very good job with WinAsm Studio, and you share it! thank you!

For a project with winbinder, i am using WinAsm Studio for creating the rc.files.
Here my question:

How comes that the height and width numbers for square are different?
To get actual pixels (as shown in test dialog ) i have to multiply height with 1,498 and width with 1,625.

thanks again

hans
PMEmail Poster
Top
akyprian
Quote Post


Administrator
******

Group: Admins
Posts: 2307
Member No.: 1
Joined: 12-May 04


Thanks hare for the good words and the VERY good question (this is why I moved this topic to the FAQ forum).

Please bare in mind that this is how the Windows OS is designed and WinAsm Studio simply obeys the rules:

Each dialog box template contains measurements that specify the position, width, and height of the dialog box and the controls it contains. These measurements are device independent, so an application can use a single template to create the same dialog box for all types of display devices. This ensures that a dialog box will have the same proportions and appearance on all screens despite differing resolutions and aspect ratios between screens. Practically, this how one should make the tranformation from pixels to dialog units and vice versa:

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 * / 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 it helps. If you still have questions, please let me know

Antonis
PMEmail PosterUsers Website
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google