ISquishWorms
Oct 20th, 2002, 09:17 AM
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,
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;
}
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,
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;
}