mfc 设置弹出框文本

2025-04-16 23:52:38

1、主要依赖SetWindowText函数。首先给编辑框关联一个CEdit类型的变量。(右键编辑框,添加变量就可以)然后调用SetWindowText函数,传入CString类型的参数。

mfc 设置弹出框文本

2、函数原型:CWnd::SetWindowTextvoid SetWindowText(LPCTSTRlpszString );

mfc 设置弹出框文本

3、范例(来源于MSDN):Example// set the text i艘绒庳焰n 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);

mfc 设置弹出框文本
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢