News:

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

Textmetric structure, questions

Started by Rainstorm, March 06, 2008, 02:47:09 PM

Previous topic - Next topic

Rainstorm

hi.

i can't understand what the units that the elements of the textmetric are returned in,..mean.
fromthe SDK..
QuoteAll sizes are specified in logical units; that is, they depend on the current mapping mode of the display context.
logical units.. what does that mean ?

here's some code am having a prob with - the average character width & height return 0 : /

        .data
                    txtmetrics   TEXTMETRIC  <0>

==============================
         .elseif uMsg == WM_CREATE
              invoke GetDC, hwnd
              mov hdc, eax
              invoke GetTextMetrics, hwnd, addr txtmetrics
              invoke ReleaseDC, hwnd, hdc
              mov  edi,        txtmetrics.tmAveCharWidth
              fn MessageBox,0,ustr$(edi),"Title",MB_OK
              mov char_widthX, edi
              mov edi,         txtmetrics.tmHeight
              mov char_height, edi
              xor eax, eax
              ret
              ....
              other code
             .endif


donkey

This is explained by coordinate mapping. In the default mode 1 logical unit is equivalent to 1 pixel however this can be changed by a mapping mode using SetViewportExt and SetWindowOrg etc. Generally screen pixels are fine for most applications however you may want to change the mapping mode if your output is to say a 600 DPI printer since screen DC's are 96 DPI the width of 1 pixel would vary between the two devices. Using logical units you are able to separate the output using view ports to the screen and printer allowing you to more easily handle WYSIWYG.

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnargdi/html/msdn_mapping.asp
"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

Rainstorm

donkey, thanks for the pointer ..am getting the idea somewhat. logical units permits the app to handle stuff in those units.. while allowing it to work on diff devices- my output device would be the monitor.
..but why is the tmAveCharWidth,  0 ? - it seems there that its still in logical units & no function has converted it yet to display units, so in the msgbox it should display some number for the width.
I've not declared any font, & its using the default font of the Device Context.

[edit] i realise that the transformation to physical has already taken place when the values are placed in the TEXTMETRIC structure since the DC has a default mapping mode. still don't know why its returnin 0 though. - still got to do some reading on all this stuff