如何在C++中使用%d,特别是在DrawText()中
How to use %d in C++, particularly in DrawText()
所以我听说过%d,但我不知道如何使用它。我想做的是:
DrawText (hdcWindow, "PLACE IN QUESTION" , -1, &rc, DT_SINGLELINE);
在"PLACE IN QUESTION"中,我想显示文本和一个变量,如"text%d"或者其他什么,但我不知道语法,我如何规定%d在显示时将代表什么?
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);
然后CCD_ 1
相关文章:
- 我刚刚安装了Visual Studio,遇到了一些错误,特别是WindowsSDKDir属性未定义.可能找不到某些生成工
- 平均循环值(特别是 HSL 配色方案中的色调)
- 如何通过函数参数使用 fstream(特别是 ofstream)
- 使用 C/C++ 以外的语言构建共享库,特别是 prolog
- 是否提供了在linux上交叉编译gtkmm(特别是v3)windows库/应用程序的说明
- GCC 地址清理器 - 将库功能列入黑名单(特别是 boost::test)
- std::bind通常适用于仅移动类型,特别是std::unique_ptr
- 当我可以将RNG传递给分发时,为什么要使用variate_generator?(特别是C++和Boost)
- 了解函数特征模板的工作原理.特别是,指向成员函数的指针是怎么处理的
- 如何在C++中使用%d,特别是在DrawText()中
- 如何在SWIG包装C++代码中向目标语言(特别是Python)添加替代构造函数
- 如何将c合并到c中(特别是lex)
- C++-占位符是如何工作的(特别是在boost::type_erasure中)
- 如何在xml树中反向行走节点,特别是libxml/c++
- 当您泄漏"device"和"device context"时会发生什么 - 特别是 d3d?
- 转换到另一个库(特别是c++)
- 我迷失在提升库中(特别是boost_program_options)
- msys/MinGW,即使安装了也找不到libpng,试图编译xpdf(特别是pdftopng)
- 并发与并行——特别是在c++中
- 矢量化/优化循环,用于宽寄存器(特别是Xeon Phi)的未对齐数据访问