Use windows message to change text in CEdit with timeout control
来源:互联网 发布:户外烧烤 知乎 编辑:程序博客网 时间:2024/06/06 20:20
When using socket class, usually you have to send your data received from remote peer to upper CDialog class, the basic ways are:
1, pass the windows handle (this or m_hWnd)to socket class object’s component data in construct function.
2, get the main window handle, use the function AfxGetApp()->m_pMainWnd;
3, use a globe buffer to contain data.
And there is an easy way pass data to upper class, just use the CEdit pointer.
The code is as follows: and we added time control.
HWND hWnd = NULL; //the CEdit component window handle if (NULL == m_pMsgCtrl) return false; if (NULL = (hWnd = m_pMsgCtrl->GetSafeHwnd())//CEdit *m_pMsgCtrl; return false; DWORD dwResult = 0; // the same as returned value of SendMessage // get the length of text in CEdit // 1000L stands for 1 second, up to 15 seconds if (SendMessageTimeout(hWnd, WM_GETTEXTLENGTH, 0, 0, SMTO_NORMAL, { int nLen = (int) dwResult; // set the place to insert new string, just select the text. if (SendMessageTimeout(hWnd, EM_SETSEL, nLen, nLen, SMTO_NORMAL, { // send new string if (SendMessageTimeout(hWnd, EM_REPLACESEL, FALSE, (LPARAM)strText, SMTO_NORMAL, { } } }
It works the same as:
if (::IsWindow( m_pMsgCtrl->GetSafeHwnd() )) { int nLen = m_pMsgCtrl->GetWindowTextLength(); m_pMsgCtrl->SetSel(nLen, nLen); m_pMsgCtrl->ReplaceSel( strText ); }
- Use windows message to change text in CEdit with timeout control
- An easy way to change colour in text control
- How to change the timeout in FXCop
- How to Use Linux Commands in Windows with Cygwin
- How To Use Git Source Control with Xcode in iOS 7
- Vertical Text Centering in an Edit Control(CEdit 单行 垂直居中)
- Progress Control with Text
- Model change control with NHibernate
- how to use ocx control in console app.
- How to Use MFC Tab Control in Developing VC++ Applications
- How to use ValidationSummary control in asp.net
- How To Send SMS Text Message in iPhone Apps
- In order to use Login Control, CreateUser Control and so on in ASP.NET2.0.
- How to use Serial Port in Windows
- How to Use PeekMessage() Correctly in Windows
- How to use .NET Windows Control into the WPF Application
- Windows - How to change default system font in Windows 10
- Use Nid to Change dbname
- sharpoint网站集的迁移
- 利用AXIS开发Webservice(三) —— 如何传递JavaBean和你的对象
- PDF学习总结之PDF结构简介
- test if a string is a number
- Session 工作原理
- Use windows message to change text in CEdit with timeout control
- DesignOne介绍及下载
- 测试用例设计与管理思路经验总结
- 可能用到的一些方法积累
- spring总结
- mono试用手记
- InstallShield制作安装包实现自动化
- 右键菜单添加清空文件夹内容
- 通过ACM将wav转换成Windows GSM 6.10