首页 > 电脑专区 > 电脑教程 >

mfc 设置弹出框文本

来源:互联网 2023-02-20 23:45:21 409

今天的这篇经验和大家聊一聊关于mfc 设置弹出框文本的问题,希望能够帮助到有需要的朋友。Xji办公区 - 实用经验教程分享!

方法/步骤

  • 1

    主要依赖SetWindowText函数。首先给编辑框关联一个CEdit类型的变量。(右键编辑框,添加变量就可以)然后调用SetWindowText函数,传入CString类型的参数。Xji办公区 - 实用经验教程分享!

    mfc 设置弹出框文本Xji办公区 - 实用经验教程分享!

  • 2

    函数原型:CWnd::SetWindowTextvoid SetWindowText(LPCTSTRlpszString );Xji办公区 - 实用经验教程分享!

    mfc 设置弹出框文本Xji办公区 - 实用经验教程分享!

  • 3

    范例(来源于MSDN):Example// set the text in IDC_MYEDITCWnd* pWnd = GetDlgItem(IDC_MYEDIT);pWnd->SetWindowText(_T("Hockey is best!"));// Get the text back. CString is convenient, becauseMFC// will automatically allocate enough memory to hold the// text--no matter how large it is.CString str;pWnd->GetWindowText(str);ASSERT(str == _T("Hockey is best!"));// TheLPTSTRoverride works, too, but it might be too short.// If we supply a buffer that's too small, we'll only get those// characters thatfit.TCHARsz[10];int nRet = pWnd->GetWindowText(sz, 10);// Nine characters, plus terminating nullASSERT(lstrcmp(sz, _T("Hockey is")) == 0);ASSERT(nRet == 9);// You can query the length of the text without the length of// the string using CWnd::GetWindowTextLength()nRet = pWnd->GetWindowTextLength();ASSERT(nRet == 15);Xji办公区 - 实用经验教程分享!

    mfc 设置弹出框文本Xji办公区 - 实用经验教程分享!

  • 3该信息非法爬取自百度经验
  • 注意事项

    • 以上内容和图片整理自互联网,为帮助到更多有需要的朋友所以整理在这里分享,同时如果侵犯版权,请联系网站进行删除,想要了解更多请到原网址进行查阅,原作者即为原网址名字。

    以上方法由办公区教程网编辑摘抄自百度经验可供大家参考!Xji办公区 - 实用经验教程分享!


    标签: 操作系统设置文本

    办公区 Copyright © 2016-2023 www.bgqu.net. Some Rights Reserved. 备案号:湘ICP备2020019561号统计代码