有一个窗口将转换后的 int 变量输出为字符串,所有这些都在一个循环中重复(应该有 10 行,一个在另一个之下)。代码如下所示:
RECT rc;
HDC dcc = GetDC(global::hwndGeneral);
GetClientRect(global::hwndGeneral, &rc);
SetBkMode(dcc, TRANSPARENT);
SetTextColor(dcc, RGB(0, 0, 255));
for (int i = 0; i < 10; i++)
{
std::string x1 = std::to_string(math::vectorline[i].x1);
std::string y1 = std::to_string(math::vectorline[i].y1);
std::string x2 = std::to_string(math::vectorline[i].x2);
std::string y2 = std::to_string(math::vectorline[i].y2);
std::string n = std::to_string(i);
std::string hd = n + " Line: A(" + x1 + "," + y1 + ") B(" + x2 + "," + y2 + ") ; ";
TCHAR* b = 0;
b = new TCHAR[hd.size() + 1];
copy(hd.begin(), hd.end(), b);
b[hd.size()] = 0;
DrawText(dcc, (LPCWSTR)b, -1, &rc, DT_MODIFYSTRING | DT_PATH_ELLIPSIS);
//DrawText(dcc, (LPCWSTR)intToCHAR(math::vectorline[0].x2), -1, &rc, DT_MODIFYSTRING | DT_PATH_ELLIPSIS);
}
ReleaseDC(global::hwndGeneral, dcc);
但问题是文本是一个在另一个之上塑造的,因此,最后没有什么是清楚的。向 TCHAR* b 数组 (b[hd.size()] = '\n') 添加换行符也不起作用。DrawText() 函数中的换行方法有哪些?

