News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Draw Text

Started by hfheatherfox07, August 18, 2012, 04:38:20 AM

Previous topic - Next topic

hfheatherfox07

Hi,
I was wondering is the re a way to center Multilines with DrawText Vertically?
It seems that DT_VCENTER only works with single lines :(

szText          db 'Text Line1',13,10
     db 'Text Line2',13,10
             db 'Text Line2', 0

This wont work
invoke  DrawText,        ps.hdc, addr szText,-1, addr rcClient,
                                 DT_VCENTER or DT_CENTER or DT_NOPREFIX
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

jj2007

No. You need two invokes, the first with DT_CALCRECT.

hfheatherfox07

@ jj2007
I don't understand what you mean ?

Have different data values ?
Like


szText          db 'Text Line1',13,10
szText 1     db 'Text Line2',13,10
szText 2       db 'Text Line2', 0
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

I have tried this ...does not seem right?

invoke  DrawText,        ps.hdc, addr szHello,-1, addr rcClient,
                                DT_CALCRECT or  DT_VCENTER
                               
invoke  DrawText,        ps.hdc, addr szHello,-1, addr rcClient,
                            DT_CENTER
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

jj2007

"If the function succeeds, the return value is the height of the text."

- invoke DrawText, ... DT_CALCRECT
- mov edx, heightofbox
- sub edx, eax
- sar edx, 1
- add rc.top, edx
- invoke DrawText, ... DT_whatever

hfheatherfox07

@jj2007 
Nice!!!  :t

That worked Great ..... The " heightofbox" is actually pixels from the top to go down

I will add a little Demo in case some one else runs into this
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

Thank You Again jj2007 !  :t

Here is that example in case some one else runs into this  :biggrin:

Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.