Thread: MFC display text in a window

  1. #1
    Pichaz
    Guest

    Question MFC display text in a window

    How do you display text within a window using the MS Foundation Classes?

  2. #2
    Registered User Ray Schmidt's Avatar
    Join Date
    Feb 2003
    Posts
    17
    Try using something like:

    pDC->TextOut(0,0,"Hello Wrold");

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    162
    first you have to get permission from the O/S to output to the screen, so, do this:
    Code:
    CDC* pDC;
    	pDC = GetDC();
    	InvalidateRect (0);
    	OnDraw(pDC);
    after that, you have your pointer, and youve called OnDraw...to output anything you have to go thru OnDraw....anyways, after that, you can directly output from OnDraw, or you can call another class's function and output from there..to do that, just send the pDC pointer to it...ya, so then, just do

    Code:
    pDC -> TextOut (x, y, "Hello");
    the first 2 parameteres are the start x and y pixels on the screen...0, 0 would be the top corner, and so on.....the 3rd MUST be a string...if your trying to output numbers, you have to first convert it to a string, then output it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. My text doesn't display
    By joeprogrammer in forum Game Programming
    Replies: 11
    Last Post: 02-23-2006, 10:01 PM
  3. Can't display text from file
    By newbie543 in forum C Programming
    Replies: 1
    Last Post: 09-03-2005, 08:05 PM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM