From: rahul on
I have following entry in my .rc file for the owner drawn button
control
I think last four entries (66,17,120,13) are for the position and size
for the button (I think)


CONTROL
"",IDC_BUTTON_DIRECTION_FLYIN,"Button",BS_OWNERDRAW |
WS_TABSTOP,66,17,120,13

But I dont know what unit is used for these entries. it is not in
pixel . Might it be dialog unit.
Is ther any relation between pixel and this unit?
From: Oliver Regenfelder on
Hello,

rahul wrote:
> CONTROL
> "",IDC_BUTTON_DIRECTION_FLYIN,"Button",BS_OWNERDRAW |
> WS_TABSTOP,66,17,120,13

These coordinates are in dialog units.

Taken from the windows vista user experience guide:
A dialog unit (DLU) is a device-independent metric where one horizontal dialog unit equals one-fourth of the
average character width for the current font and one vertical dialog unit equals one-eighth of the character
height for the current font. Because characters are roughly twice as high as they are wide, a horizontal DLU is
roughly the same size as a vertical DLU, but it�s important to realize that DLUs are not a square unit.


So the corresponding pixel values depend on the font used
by the dialog (defined somewhere in the 'FONT' line).

The 'Windows Vista user experience guide' which can be downloaded
for free from MSDN (please search, I do not have it bookmarked)
has some details starting from page 601. There you will also
find some conversion tables between DLUs and pixels for
9pt Sageo (Vista standard Font) and 8 pt Tahoma (Windows XP
standard font). Be aware that the used font still depends on
what you set up in the resource file.

BTW: If you want to convert from DLUs to Pixels in the software,
then there are better ways than hardcoded translations. But for
that you would need to describe what you want to do.


Best regards,

Oliver
From: Mihai N. on

> But I dont know what unit is used for these entries. it is not in
> pixel . Might it be dialog unit.

As Oliver explained, dialog units



> Is ther any relation between pixel and this unit?

http://support.microsoft.com/kb/125681
Always calculated using the font of the dialog.
Safest thing: retrieve the font from the hdc of the dialog window.


--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

From: Joseph M. Newcomer on
As already answered, it is in DBUs and there is a mapping to pixels if you care. But a
deeper and more fundamental question: why should you care? (Note there are a couple
exotic reasons you might, but generally, for the last 20 years of Windows programming, I
have not cared in the slightest about the relationship between DBUs and pixels, and I can
probably give answers to specific concerns if I know what those concerns are)
joe

On Thu, 27 May 2010 02:20:24 -0700 (PDT), rahul <hyrahul64(a)gmail.com> wrote:

>I have following entry in my .rc file for the owner drawn button
>control
>I think last four entries (66,17,120,13) are for the position and size
>for the button (I think)
>
>
> CONTROL
>"",IDC_BUTTON_DIRECTION_FLYIN,"Button",BS_OWNERDRAW |
> WS_TABSTOP,66,17,120,13
>
>But I dont know what unit is used for these entries. it is not in
>pixel . Might it be dialog unit.
>Is ther any relation between pixel and this unit?
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm