button按钮名称更改时,新名称为含变量的字符串,如何处理?

lanpishu1984 2009-08-14 03:12:21
CWnd* pWnd = GetDlgItem(IDC_BUTTON4);
int i;
i=..;
新名称为:第i次操作该按钮
pWnd->SetWindowText(_T("新名称"));
...全文
244 15 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
lanpishu1984 2009-08-15
  • 打赏
  • 举报
回复
谢谢大家,解决了,str.Format(_T("第%d次操作该按钮 "),i);
LPR_Pro 2009-08-14
  • 打赏
  • 举报
回复
定义个CString temp;
temp.Format("%d",i);
pWnd->SetWindowText("第" + temp + "次操作该按钮");
:Format((const wchar_t *) temp.GetBuffer(),...); // 强制转换
  • 打赏
  • 举报
回复
UP
chogimoga 2009-08-14
  • 打赏
  • 举报
回复
temp.Format(_T("%d"),i);
bohut 2009-08-14
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 lanpishu1984 的回复:]
引用 3 楼 allright1199 的回复:
定义个CString temp;
temp.Format("%d",i);
pWnd->SetWindowText("第" + temp + "次操作该按钮");


::Format(const wchar_t *,...)”: 不能将参数 1 从“const char [11]”转换为“const wchar_t *”
[/Quote]

你的i是什么类型的啊?
你把代码都贴出来吧,反正也没几句。
雪影 2009-08-14
  • 打赏
  • 举报
回复
CWnd* pWnd = GetDlgItem(IDC_BUTTON4); 
static int i = 0;//这里要设置成静态变量
i++;
CString str;
str.Format(_T("第%d次操作该按钮 "),i);
pWnd->SetWindowText(str);
homesos 2009-08-14
  • 打赏
  • 举报
回复

CWnd* pWnd = GetDlgItem(IDC_BUTTON4);
int i;
CString str;
//新名称为:第i次操作该按钮
str.Format(_T("第%d次操作该按钮 "),i);
pWnd->SetWindowText(str);
lanpishu1984 2009-08-14
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 allright1199 的回复:]
定义个CString temp;
temp.Format("%d",i);
pWnd->SetWindowText("第" + temp + "次操作该按钮");
[/Quote]

::Format(const wchar_t *,...)”: 不能将参数 1 从“const char [11]”转换为“const wchar_t *”
oktsl 2009-08-14
  • 打赏
  • 举报
回复
CString str;
str.Format("第%d次操作该按钮",i);
pWnd->SetWidowText(str);
yuhudie203 2009-08-14
  • 打赏
  • 举报
回复
CString str;
str.Format("第%d次操作该按钮",i);
pWnd->SetWidowText(str);
ljz888666555 2009-08-14
  • 打赏
  • 举报
回复

i++;
CString str;
str.Format(_T("%d次改了控件"),i);
GetDlgItem(IDC_BUTTON)->SetWindowText(str);
bohut 2009-08-14
  • 打赏
  • 举报
回复
相同贴吧??
CString str;
str.Format("第%次操作该按钮",i);
pWnd->SetWindowText(str);
allright1199 2009-08-14
  • 打赏
  • 举报
回复
定义个CString temp;
temp.Format("%d",i);
pWnd->SetWindowText("第" + temp + "次操作该按钮");
xylicon 2009-08-14
  • 打赏
  • 举报
回复
CWnd*  pWnd  =  GetDlgItem(IDC_BUTTON4); 
int i;
CString str;
//新名称为:第i次操作该按钮
str.Format(_T("第%d次操作该按钮 "),i);
pWnd->SetWindowText(str.GetBuffer(str.GetLength());
bluesky395 2009-08-14
  • 打赏
  • 举报
回复
CString text;
text.Format(_T("第 %d 次操作该按钮"),i);
SetDlgItemText(IDC_BUTTON4, text);

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧