Thread: TextOut()

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    8

    TextOut()

    For a windows program i'm making I need to get mutliple strings printed on the screen.

    Just wondering is there was an easier way then double BeginPain()

    Code:
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    PAINTSTRUCT paintStruct;							
    char string[] = "Testing";
    char string1[] = "Testing Two";
    HDC hDC;
    	
    switch (message)
    {
     case WM_CLOSE:
      PostQuitMessage(0);
      return 0;
      break;
    
     case WM_PAINT:					
      hDC = BeginPaint(hwnd, &paintStruct);
      SetTextColor(hDC, COLORREF(0x0000FF));	
      TextOut(hDC, 150, 150, string, sizeof(string)-1);	
      EndPaint(hwnd, &paintStruct);
      hDC = BeginPaint(hwnd, &paintStruct);
      SetTextColor(hDC, COLORREF(0xFF0000));
      TextOut(hDC, 150, 200, string1, sizeof(string)-1);
      EndPaint(hwnd, &paintStruct);
      return 0;
      break;
    
     default:
     break;
    }
    
    return (DefWindowProc(hwnd, message, wParam, lParam));
    }

  2. #2
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    Why are you calling BeginPaint/EndPaint twice? It needs to be only called once at the start, and once at the end. You can have as much drawing code in the middle as necessary.

    Code:
    case WM_PAINT:					
      hDC = BeginPaint(hwnd, &paintStruct);
      SetTextColor(hDC, COLORREF(0x0000FF));	
      TextOut(hDC, 150, 150, string, sizeof(string)-1);	
      SetTextColor(hDC, COLORREF(0xFF0000));
      TextOut(hDC, 150, 200, string1, sizeof(string)-1);
      EndPaint(hwnd, &paintStruct);
      return 0;
      break;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. TextOut() flickering
    By Xterria in forum Game Programming
    Replies: 6
    Last Post: 01-22-2004, 09:55 PM
  2. TextOut() Questions
    By Dipset in forum Windows Programming
    Replies: 2
    Last Post: 07-05-2003, 11:38 AM
  3. A small problem with TextOut()
    By Devil Panther in forum Windows Programming
    Replies: 4
    Last Post: 06-28-2003, 01:15 AM
  4. print TextOut
    By andrewjf9 in forum Windows Programming
    Replies: 2
    Last Post: 11-21-2002, 11:36 PM
  5. TextOut problem
    By Chimpsag in forum Windows Programming
    Replies: 1
    Last Post: 09-14-2002, 12:02 PM