现在的位置: 首页 > 综合 > 正文

WinSDK方式动态更新控件文本

2013年12月06日 ⁄ 综合 ⁄ 共 706字 ⁄ 字号 评论关闭

今天为了实现动态更新控件文本的功能,快把百度番羽了个底朝天也没找到,最后忽然看到了一句话:SetDlgItemText,终于解决了。

就一句代码的事,整整耗了一个上午,还是对SDK不熟啊!!!

BOOL SetDlgItemText(
  HWND  hDlg,         // handle of dialog box
  int  nIDDlgItem,    // identifier of control
  LPCTSTR  lpString   // text to set
);
 
Parameters
hDlg 
    Identifies the dialog box that contains the control. 
nIDDlgItem 
    Identifies the control with a title or text that is to be set. 
lpString 
    Pointer to the null-terminated string that contains the text to be copied to the control. 
Return Values
    If the function succeeds, the return value is nonzero.
    If the function fails, the return value is zero. To get extended error information, call GetLastError. 
Remarks
    The SetDlgItemText function sends a WM_SETTEXT message to the specified control. 

使用方法很简单:

SetDlgItemText(hDlg,控件ID,“文字内容”);

抱歉!评论已关闭.