News:

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

question on facename member of the LOGFONT structure

Started by Rainstorm, November 18, 2008, 02:38:35 AM

Previous topic - Next topic

Rainstorm

hi.
the lfFaceName member of the LOGFONT structure is defined this way
QuoteTCHAR lfFaceName[LF_FACESIZE]

I tried to display it in this way     mov ebx, offset logfont.lfFaceName
    invoke wsprintf, esi, chr$("lfFaceName:  %s",13,10), ebx
    add esi, eax                         

but it doesn't seem to display, i tried a few other variations for teh format field too.
I checked the definition in the .inc file in masm too & it seems to be a BYTE buffer
what am i doing wrong ?

thanks!

Tedd

"add esi,eax" will cause esi to point to the END of the string.. So, if you're then using esi to display it, you'll get nothing - try displaying from the start of the string (or don't add the length) :P
No snowflake in an avalanche feels responsible.

Rainstorm

hiya tedd,
       sry, that was just part of the code I should have been clearer. - esi is a pointer to lf_displaybuff
I display the whole logfont structure like this in the WM_INITDIALOG msg. zipped the whole code below.
         .elseif uMsg == WM_INITDIALOG             
             invoke SetDlgItemText, hWndDlg, 100, addr lf_displaybuff

             jmp false_                             


also , some other questions, if am deleting a brush using DeleteObject, where/when would be the right place to do it in the wndproc ? anywhere other than before i use PostQuitMsg/DestroyWindow, cause that would be waiting till i quit the app/window.



thanks.!
===========

[attachment deleted by admin]

Tedd

Works fine for me -- I select a font (e.g. "Arial"), and then it displays the details, after scrolling down to the bottom I see the facename as Arial.


Quote from: Rainstorm on November 18, 2008, 03:26:00 PM
also , some other questions, if am deleting a brush using DeleteObject, where/when would be the right place to do it in the wndproc ? anywhere other than before i use PostQuitMsg/DestroyWindow, cause that would be waiting till i quit the app/window.
Delete any objects after you no longer need them - if you need it until the end of the program then don't delete it until then. The alternative is to repeatedly create-draw-destroy, but if you're always creating the same one, that seems a little wasteful.
No snowflake in an avalanche feels responsible.

Rainstorm

#4
seems to be working okay here too, think I was just hitting enter on the 'choosefont' dialog without selecting a font, thinking that a default selection was made. : /

just some other questions.

in the wsPrintf function there isn't a format modifier for 'byte' sized integer values, just word & dword, right ? (can you confirm that ?) - also there is a warning in the sdk about security issues using it & they mention 'buffer overflow' - is that a security thing.. or some problem in the functionality of the call ?

for the '-' modifier the sdy says..
QuotePad the output with blanks or zeros to the right to fill the field width, justifying output to the left. If this field is omitted, the output is padded to the left, justifying it to the right.
..if the default is 'padding the output to the left' - assuming that means padding from lower addresses upwards before the output it doesn't make sense. - shouldn't the 0's be padded to the right by default, trailing after the output ? - can anyone clarify this ?
- - - - - -
lastly, i've changed the background & text in the edit-control in the WM_CTLCOLOREDIT but the background colour doesn't get changed, except for the strip of color at the bottom of the editbox

many thanks!
=========


[attachment deleted by admin]

Tedd

Quote from: Rainstorm on November 20, 2008, 06:28:28 AM
in the wsPrintf function there isn't a format modifier for 'byte' sized integer values, just word & dword, right ? (can you confirm that ?)
You still have to push a whole dword per argument, even if you only want a bye (or a word) - so you'll need to mask out the upper bits and then push the full dword.

Quote
also there is a warning in the sdk about security issues using it & they mention 'buffer overflow' - is that a security thing.. or some problem in the functionality of the call ?
All string functions that don't check the length of their input data are subject to buffer overflows. If you provide a buffer that is too small, and someone passes in a very large string, it will overwrite the bytes following and this can be used to modify the rest of the program - within functions, buffers are often allocated on the stack, so you can overwrite the return address and redirect the code wherever you choose (if you know what you're doing.)

Quote
for the '-' modifier the sdy says..
QuotePad the output with blanks or zeros to the right to fill the field width, justifying output to the left. If this field is omitted, the output is padded to the left, justifying it to the right.
..if the default is 'padding the output to the left' - assuming that means padding from lower addresses upwards before the output it doesn't make sense. - shouldn't the 0's be padded to the right by default, trailing after the output ? - can anyone clarify this ?
Default padding would be "0001" or "   1", opposite would be "1   " or "1   " - it doesn't make sense to add zeroes to the end :wink
No snowflake in an avalanche feels responsible.

KeepingRealBusy

QuoteDefault padding would be "0001" or "   1", opposite would be "1   " or "1   " - it doesn't make sense to add zeroes to the end
If the value you are displaying is a float or double, then it makes sense to pad it on the right with zeros, "6.023000" vs "6.023" to differentiate between "6.023000" and "6.023769" especially if this is multi-line columnar data..

Tedd

Good point.
Unfortunately, wsprintf doesn't handle floating point numbers.
No snowflake in an avalanche feels responsible.

Rainstorm

tedd, thx for clearing those things up.
tedd wrote..
QuoteDefault padding would be "0001" or "   1", opposite would be "1   " or "1   " - it doesn't make sense to add zeroes to the end
just confused a bit . am assuming in "0001",  1 is at the lowest address, cause if the first 0 is at the lowest address it would be read first, & i guess would stop reading after that since the '0' would indicate the end - is that right ?

thx a lot.

rainstorm

Tedd

Nooo, those are zero digits (30h) not null values (00h).
It's a string of digits "0","0","0","1" terminated with a null (like most other strings) -- db "0001",0
No snowflake in an avalanche feels responsible.

Rainstorm