Writing text in a control's window

Writing text in a control's window

Post by Nikhil Pate » Fri, 11 Jul 2003 06:09:15



Hi all,
    Is there a way to writing text at the center of a control's window using
the hwnd?

-Thanks...

-Nikhil

 
 
 

Writing text in a control's window

Post by Mike D Sutto » Fri, 11 Jul 2003 06:17:51


Quote:>     Is there a way to writing text at the center of a control's window
using
> the hwnd?

Call GetDC() on the window to get the DC handle associated with it, then
TextOut() onto that - Make sure you call ReleaseDC() when you're done to
prevent resource leaks.  To centre the text, first get the size of it using
the currently selected font object with GetTextExtentPoint32(), then
position the text drawing to render where the top left coordinate of the
texts bounds rectangle will be:

X = (Surface.Width - Text.Width) \ 2
Y = (Surface.Height - Text.Height) \ 2

You can find out more about the GetTextExtentPoint32() call here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdif...
Hope this helps,

    Mike

 - Microsoft Visual Basic MVP -

WWW: Http://www.mvps.org/EDais/

 
 
 

Writing text in a control's window

Post by Larry Serflate » Fri, 11 Jul 2003 07:05:59



>     Is there a way to writing text at the center of a control's window using
> the hwnd?

(Already answered in another group)

Please avoid posting the same message to several different groups.
If more than one group applies, then include them all on the To line
in a single message.  Multiposting means the messages and replies
stay in the groups you posted to.  Crossposting means the message
and replies are shared across all included groups.

Avoid multiposting, use crossposting sparingly.

It is better for all involved if all the replies are made visible in all the groups
you posted to.  Also, avoid posting to non-relavent groups, please....

LFS

 
 
 

1. Help: writing text to window--controlling text size

  Dear OpenGL users,
    I've got code from sgi (xfont.c) that opens and loads a font
and allows printing in an x-window; I've also read chapter 8 in the
"OpenGL Programming Guide." However, I need more control than OpenGL
seems to gives me (according to chapter 8).  Specifically, I need to control
the size of the text I want to write into a window (I'm writing a utility
that graphs results and it needs axis labels, etc...), and short of
loading a new font, there's seems to be no way to do this.  
Any hints about how I might proceed would be greatly appreciated.
Thanks for your time and trouble.

 - Cheers,
     Chris Currie

2. Texture maps

3. Help please with read / write from text control (VB4)

4. Help needed with nu splines!!!

5. Writing text to a window using glut or glx

6. Image Format for X App.

7. Writing text on a openGL window?

8. TImage resize after the form is resized

9. How to Write Unicode Text To a metafile in Windows 98

10. SGI's .rgb format read/write plug-in for windows

11. Can't enter text into deformation windows

12. How to add windows controls on top of mpeg playing window

13. Q: writing a prog. to control indy-cam