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
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
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