📄 subject_20493.htm
字号:
<p>
序号:20493 发表者:A-bird 发表日期:2002-11-07 09:15:50
<br>主题:如何在对话框中显示控件(直接用代码写的)!!!
<br>内容:比说我要在一个指定的位置显示一个EDIT框,<BR>代码应该怎么写,写在哪里?<BR>其它控件是否也一样?<BR>求教!!!!!!!!!!!!!!!!!!!!
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:口水龙 回复日期:2002-11-07 09:19:03
<br>内容:CEdit::Create <BR>BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );<BR><BR>Return Value<BR><BR>Nonzero if initialization is successful; otherwise 0.<BR><BR>Parameters<BR><BR>dwStyle<BR><BR>Specifies the edit control’s style. Apply any combination of edit styles to the control. <BR><BR>rect<BR><BR>Specifies the edit control’s size and position. Can be a CRect object or RECT structure.<BR><BR>pParentWnd<BR><BR>Specifies the edit control’s parent window (usually a CDialog). It must not be NULL.<BR><BR>nID<BR><BR>Specifies the edit control’s ID.<BR><BR>Remarks<BR><BR>You construct a CEdit object in two steps. First, call the CEdit constructor, then call Create, which creates the Windows edit control and attaches it to the CEdit object. <BR><BR>When Create executes, Windows sends theWM_NCCREATE,WM_NCCALCSIZE,WM_CREATE, andWM_GETMINMAXINFO messages to the edit control. <BR><BR>These messages are handled by default by the OnNcCreate, OnNcCalcSize, OnCreate, and OnGetMinMaxInfo member functions in the CWnd base class. To extend the default message handling, derive a class from CEdit, add a message map to the new class, and override the above message-handler member functions. Override OnCreate, for example, to perform needed initialization for the new class.<BR><BR>Apply the following window styles to an edit control. <BR><BR>WS_CHILD Always<BR><BR><BR>WS_VISIBLE Usually<BR><BR><BR>WS_DISABLED Rarely<BR><BR><BR>WS_GROUP To group controls<BR><BR><BR>WS_TABSTOP To include edit control in the tabbing order <BR>Example<BR><BR>void CMyView::OnInitialUpdate() <BR>{<BR> CView::OnInitialUpdate();<BR> <BR> // dynamically create an edit control on the view<BR> CEdit* pEdit = new CEdit;<BR> pEdit->Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,<BR> CRect(10, 10, 100, 100), this, 1);<BR>}<BR><BR>CEdit Overview | Class Members | Hierarchy Chart<BR><BR>See Also CEdit::CEdit<BR><BR><BR>--------------------------------------------------------------------------------<BR>Send feedback to MSDN.Look here for MSDN Online resources. <BR>然后要对窗口进行UpdateWindow()就能显示出来了
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:月光 回复日期:2002-11-07 09:38:31
<br>内容:在OnInitDialog()中<BR>BOOL CMyDlg::OnInitDialog() <BR>{<BR> CDialog::OnInitDialog();<BR> /////////////////////////////////<BR> CRect rect1(40,26,0,0);<BR><BR> CEdit *m_pEditName=new CEdit;<BR> m_pEditName->Create(WS_CHILDWINDOW|ES_AUTOHSCROLL,rect1,<BR> this,IDC_EDIT_NAME);<BR> ::SetWindowLong(m_pEditName->GetSafeHwnd(), GWL_EXSTYLE,WS_EX_CLIENTEDGE);<BR> ::SetWindowPos(m_pEditName->GetSafeHwnd(), NULL, 0 ,0 ,200,18,SWP_SHOWWINDOW);<BR>///////////////////////////////////////////<BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -