Thread: Adding a Text Control - HELP

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    1

    Question Adding a Text Control - HELP

    Greetings I have a small WIN32 program and I want to add some text in the white part on the main window. Please tell me how to add the control to the window and how to make the text say something. Thx!

  2. #2
    Registered User KonArtis's Avatar
    Join Date
    Mar 2003
    Posts
    34
    If you want to display text on the window, the easiest way is with the TextOut() function.

    Code:
    PAINTSTRUCT ps;
    int x=0, y=0;
    char szBuffer[]="Hello world";
    HDC hdc=BeginPaint(hwnd, &ps);
    
    SetBkMode(hdc, TRANSPARENT);  //Sets background transparent
    TextOut(hdc, x, y, szBuffer, strlen(szBuffer));
    
    EndPaint(hwnd, &ps);
    Remember to include <string.h> if you use strlen().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. Adding Text to an Edit
    By akrocks in forum Windows Programming
    Replies: 9
    Last Post: 03-17-2004, 11:45 AM
  4. Adding to text in an edit
    By JaWiB in forum Windows Programming
    Replies: 1
    Last Post: 02-29-2004, 03:21 PM
  5. Replies: 4
    Last Post: 06-22-2002, 12:23 PM