How to use %d in C++, particularly in DrawText() [duplicate]

故事扮演 提交于 2019-12-26 23:56:02

问题


so ive heard of %d, but i dont know how to use it. here is what i want to do:

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

at the "PLACE IN QUESTION" i want to display text and a variable like "text %d" or something, but I don't know the syntax, and how do I dictate what %d will represent when it is displayed?


回答1:


DrawText doesn't work like printf or something like that. I advise you to look at the MSDN: MSDN: DrawText

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

You need to make a conversion to LPCTSTR, you can have a look into Google, if I find a link i will give it to you, but it make long time i haven't do C++.

Edit: I found :

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

and then DrawText(XXX, t, XXX, ...);



来源:https://stackoverflow.com/questions/17518784/how-to-use-d-in-c-particularly-in-drawtext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!