[求助] SetDlgItemText问题
大家好:<BR> 刚刚上路的新手,请大家多多关照!!<BR> 我有个问题,请问用SetDlgItemText时,如何不覆盖原来的内容!!<BR> 谢谢大家<BR><P>--------------------------------------------------------------------------------</P>
<P>The SetDlgItemText function sets the title or text of a control in a dialog box. </P>
<P>Syntax</P>
<P>BOOL SetDlgItemText( HWND hDlg,<BR> int nIDDlgItem,<BR> LPCTSTR lpString<BR>);<BR>Parameters</P>
<P>hDlg<BR>[in] Handle to the dialog box that contains the control. <BR>nIDDlgItem<BR>[in] Specifies the control with a title or text to be set. <BR>lpString<BR>[in] Pointer to the null-terminated string that contains the text to be copied to the control. <BR>Return Value</P>
<P>If the function succeeds, the return value is nonzero.</P>
<P>If the function fails, the return value is zero. To get extended error information, call GetLastError. </P>
<P><BR>Remarks</P>
<P>The SetDlgItemText function sends a WM_SETTEXT message to the specified control. </P>
<P>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.</P>
<P>Example</P>
<P>For an example, see Creating a Simple List Box. </P>
<P>Function Information</P>
<P>Header Declared in Winuser.h, include Windows.h <BR>Import library User32.lib <BR>Minimum operating systems Windows 95, Windows NT 3.1 <BR>Unicode Implemented as Unicode and ANSI versions on Windows NT, Windows 2000, Windows XP </P>
回复:(zbt123456)[求助] SetDlgItemText问题
<P>假如你要输入数据的 编辑框 的ID为IDC_EDIT1,你可以先在头文件里定义一个实例<BR>CEdit m_edit;<BR>然后再在<BR>void CMyDlg::DoDataExchange(CDataExchange* pDX)<BR>{<BR> CDialog::DoDataExchange(pDX);<BR> <FONT color=#f70909>DDX_Control(pDX,IDC_EDIT1,m_edit);//加入这一行<BR></FONT>}<BR>就可以用<BR>ReplaceSel(字符串);<BR>UpdateData(TRUE);<BR>就不会覆盖原来的内容了。<BR></P>页:
[1]
