刚刚上路的新手,请大家多多关照!!
我有个问题,请问用SetDlgItemText时,如何不覆盖原来的内容!!
谢谢大家
SetDlgItemText Function
--------------------------------------------------------------------------------
The SetDlgItemText function sets the title or text of a control in a dialog box.
Syntax
BOOL SetDlgItemText( HWND hDlg,
int nIDDlgItem,
LPCTSTR lpString
);
Parameters
hDlg
[in] Handle to the dialog box that contains the control.
nIDDlgItem
[in] Specifies the control with a title or text to be set.
lpString
[in] Pointer to the null-terminated string that contains the text to be copied to the control.
Return Value
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.
Windows 95/98/Me: SetDlgItemTextW is supported by the Microsoft® Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
Example
For an example, see Creating a Simple List Box.
Function Information
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1
Unicode Implemented as Unicode and ANSI versions on Windows NT, Windows 2000, Windows XP
假如你要输入数据的 编辑框 的ID为IDC_EDIT1,你可以先在头文件里定义一个实例
CEdit m_edit;
然后再在
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX,IDC_EDIT1,m_edit);//加入这一行
}
就可以用
ReplaceSel(字符串);
UpdateData(TRUE);
就不会覆盖原来的内容了。