-2

所以我听说过 %d,但我不知道如何使用它。这是我想做的:

DrawText (hdcWindow, "PLACE IN QUESTION" , -1, &rc, DT_SINGLELINE);

在“PLACE IN QUESTION”处,我想显示文本和变量,如“text %d”或其他内容,但我不知道语法,以及如何规定 %d 在显示时代表什么?

4

1 回答 1

0

DrawText 不像 printf 或类似的东西。我建议你看看 MSDN: MSDN: DrawText

int DrawText(
  _In_     HDC hDC,
  _Inout_  LPCTSTR lpchText,
  _In_     int nCount,
  _Inout_  LPRECT lpRect,
  _In_     UINT uFormat
);

你需要转换到 LPCTSTR,你可以看看谷歌,如果我找到一个链接我会给你,但它让我很长时间没有做 C++。

编辑:我发现:

int number = 1;
CString t;
t.Format(_T("Text: %d"), number);

进而DrawText(XXX, t, XXX, ...);

于 2013-07-08T03:33:40.287 回答