how can I align the text to the bottom in an (multiline) editcontrol ?

default is aligned to the top:
+------------------+

|Hello |
|World! |
| |
| |
+------------------+
But I want it aligned to the bottom like this:
+------------------+

| |
| |
|Hello |
|World! |
+------------------+

Any ideas? I played around with EM_GETRECT and EM_SETRECT, but still cant get it right :(
Posted on 2003-01-02 16:52:09 by savage
You can perhaps get size of text (vertical), and use EM_SETRECTNP to set the top area (height of edit control - height of text).
Posted on 2003-01-02 18:39:34 by comrade
thnx guys, i have it working now. :alright:

I use EM_GETLINECOUNT and GetTextMetrics to calculate the total vertical height of the text.

But if I use a different font/size it doesnt align properly. I think its because GetTextMetrics doesnt return the size in pixels. Any other way to get the font's height in pixels? I've tried GetTextExtentPoint32 but it returns the same height as GetTextMetrics :(
Posted on 2003-01-03 16:49:38 by savage
GetTextExtentPoint32 works fine for me. I would suggest you use it in combination with GetDC(hEdit).
Posted on 2003-01-03 18:58:14 by comrade
Oops, I used WM_SETFONT the set the font of the editcontrol so I totally forgot to select the fonthandle into the devicecontext, thats why it kept returning the same values :o

:stupid:

But it works great now, thanks guys! :alright:
Posted on 2003-01-04 07:59:20 by savage