问题描述
听说过%d,但我不知道如何使用它。
这里是我想要做的:
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);
我想显示文本和一个变量,如text%d
或者某些东西,但是我不知道语法,当我们显示的时候,我如何表示%d会代表什么?
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?
推荐答案
DrawText不工作像printf或类似的东西。
我建议你看看MSDN:
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
);
你需要转换到LPCTSTR,你可以看看谷歌,如果我发现链接我会给你,但它很久没有做C ++。
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++.
编辑:
我发现:
I found :
int number = 1;
CString t;
t.Format(_T("Text: %d"), number);
,然后 DrawText(XXX,t,XXX,...);
这篇关于如何在C ++中使用%d,特别是在DrawText()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!