Announcement

Collapse
No announcement yet.

GetTextExtentPoint32, pixels or logical units?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GetTextExtentPoint32, pixels or logical units?

    I was re-reading SDK-information on the API function GetTextExtentPoint32. It states:

    lpSize
    [out] Pointer to a SIZE structure that receives the dimensions of the string, in logical units.


    I always was thinking that my apps, in which I use this function, were calculating pixel sizes. Qestion: what exactly are logical units? And how do I convert 'm to pixels?

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    Logical units means that it depends upon the DC.

    DC's have a mapping mode.

    The SetMapMode API function is used to set the current mapping mode of a DC. The %MM_TEXT flag means logical units are pixels.

    If an API function says it returns the coordinates as logical units, the return value depends upon the current mapping mode.

    Many times the default mapping mode is MM_TEXT, which is pixels, but you may want to force the mapping mode to MM_TEXT before you call GetTextExtentPoint32 if you want pixels.
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

    Comment


    • #3
      Thanks, Chris!

      Obviously my mapping mode is "pixels", because on my own computer my dialogs don't look weird. But from now on I'll force the MM_TEXT mode, just to be sure. Did not know that. Thank you very much!

      Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
      http://zijlema.basicguru.eu
      *** Opinions expressed here are not necessarily untrue ***

      Comment

      Working...
      X