Thread: Can't draw text to window

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2023
    Posts
    2

    Can't draw text to window

    I'm just trying to output the value of a variable to a window.

    Here is the function I run after a WM_PAINT message:

    Code:
    void OnPaint(HWND hWnd,MACHINE *machine)
    {
        RECT  rect;
        PAINTSTRUCT ps;
        HDC hdc = BeginPaint(hWnd, &ps);
    
        GetClientRect(hWnd, &rect);
        SetTextColor(hdc, RGB(0xFF, 0x00, 0x00));
        SetBkMode(hdc, TRANSPARENT);
        rect.left = 10;
        rect.top = 40;
        char reg[10] = { 0 };
        DrawText(hdc,( LPTSTR )(_itoa_s(machine->cpu.AddressBus, reg, 16)), -1, &rect, DT_SINGLELINE | DT_NOCLIP);
        // SelectObject(hdc, oldPen);&reg
         //DeleteObject(hPen);
        EndPaint(hWnd, &ps);
    I also do UpdateWindow(GetDesktopWindow)); in my main loop. Debug confirms the my paint routine is being run as it should.

    Blank window is all I get

    EDIT: Just realized UpdateWindow is being called, but after the initial window draw, WM_PAINT doesn't seem to be being sent. How do I force a redraw of the client area?
    Last edited by MoosTone; 09-02-2023 at 07:00 PM. Reason: New info as per edit

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Impossible to draw in an XCB window using Cairo
    By levenstein in forum Linux Programming
    Replies: 5
    Last Post: 07-02-2016, 09:31 AM
  2. C++ - win32: how can i draw correctly a transparent text?
    By joaquim in forum Game Programming
    Replies: 0
    Last Post: 07-21-2015, 10:15 AM
  3. Draw an hyperlink on the window
    By Niara in forum Windows Programming
    Replies: 4
    Last Post: 06-25-2007, 01:08 PM
  4. Window 1 causing text on window 2
    By Thantos in forum Windows Programming
    Replies: 4
    Last Post: 08-17-2003, 11:29 PM
  5. Direct Draw and Text
    By Mecnels in forum Game Programming
    Replies: 1
    Last Post: 03-14-2003, 08:12 AM

Tags for this Thread