我是新手,正在尝试使用C++编写基于GDI的代码(由于技术原因不想使用GDI+)。
编辑:简化问题:
我需要在窗口中央绘制文本周围的矩形。 - 如何填充矩形坐标? - 谁能帮忙解决这一行 - Rectangle(x1,y1,x2,y2)?如何计算这些(x1,y1)和(x2,y2)值?
谢谢。
编辑:简化问题:
我需要在窗口中央绘制文本周围的矩形。 - 如何填充矩形坐标? - 谁能帮忙解决这一行 - Rectangle(x1,y1,x2,y2)?如何计算这些(x1,y1)和(x2,y2)值?
谢谢。
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rcClient);
SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
SetTextColor(hdc, RGB(255, 0, 0));
DrawText(hdc, wstring(s.begin(),s.end()).c_str(), -1, &rectResult, DT_SINGLELINE | DT_CALCRECT);
DrawText(hdc, wstring(s.begin(),s.end()).c_str(), -1, &rcClient, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
// Here I need help - How to I place the rectangle around the Text - which is drawn in the middle of the window?
// It looks like need to use - rectResult.bottom/top/left/right - but don't know how..
Rectangle(hdc, 0,0,100,100);