Results 1 to 6 of 6

Thread: [RESOLVED]Using RoundRect AND DrawText

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    46

    [RESOLVED]Using RoundRect AND DrawText

    Hello,

    I am using the following code to draw two red round rectangles outlined with a solid white pen in the canter of my black client window. The problem I have is that I would like to also centre my text with in the round rectangles horizontally and vertically. From what I can tell the API DrawText function would allow me to do just this using ‘DT_CENTER | DT_VCENTER’ however, this API call requires that I have a structure of type RECT how do I acquire that from my round rectangles?

    Thanks in advance for any help in this matter,

    Code:
            case WM_PAINT:
            {
                PAINTSTRUCT ps;
                RECT rect;
                HDC hdc;
    			
    
                hdc = BeginPaint(hwnd, &ps);
    
                SelectObject(hdc, GetStockObject(WHITE_PEN));
                SelectObject (hdc, hBrush1);
                RoundRect(hdc,10, 10, cxClient - 10, (cyClient - 10) / 2, 10, 10);
                RoundRect(hdc,10, (cyClient + 10) / 2, cxClient - 10, cyClient - 10 , 10, 10);
                SetBkColor(hdc, RGB(255,0,0));
                SetTextAlign(hdc,TA_CENTER);
                TextOut(hdc, cxClient / 2, 15, "TEXT", 4);
                TextOut(hdc, cxClient / 2, 55, "MORE TEXT", 9);
                //DrawText(hdc, "TEXT", 4, &rect, DT_CENTER | DT_VCENTER);
    
                EndPaint(hwnd, &ps);
                return 0;
            }
    Last edited by ISquishWorms; Oct 20th, 2002 at 04:59 PM.
    ISquishWorms

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width