maybe a stupid Question,but need help!
-
I want to attach a CEdit to A CView,how can i do that,thanks. just now i've tried another method, i creat a CEditView and use CEditView::GetEditCtrl,which return a reference of CEdit&,but i cannot replace the Standard CEdit to the special CMyEdit derived from that. help,either way is ok for me now,thanks.... Josephvan thanks for your attention
-
I want to attach a CEdit to A CView,how can i do that,thanks. just now i've tried another method, i creat a CEditView and use CEditView::GetEditCtrl,which return a reference of CEdit&,but i cannot replace the Standard CEdit to the special CMyEdit derived from that. help,either way is ok for me now,thanks.... Josephvan thanks for your attention
CFormView is the only way I know how to do that. That makes it look more like a dialog though, so might not be what you are looking for.
-
I want to attach a CEdit to A CView,how can i do that,thanks. just now i've tried another method, i creat a CEditView and use CEditView::GetEditCtrl,which return a reference of CEdit&,but i cannot replace the Standard CEdit to the special CMyEdit derived from that. help,either way is ok for me now,thanks.... Josephvan thanks for your attention
You can add a CEdit to a CView-derived class (call it CMyView) easily. In the MyView.h file, add a CEdit member varaible (call it m_ctlEdit). In the MyView.cpp file, add message handlers for WM_CREATE (i.e., OnCreate) and WM_SIZE (i.e., OnSize). Add code like this:
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; DWORD dwStyle = WS_CHILD | WS_VISIBLE; // and any other styles you want if ( !m_ctlEdit.Create( dwStyle, CRect(1,2,3,4), this, 0x1245 /* arbitrary ctl ID */ ) ) { return -1; } return 0; } void CMyView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); CRect rc; GetClientRect( &rc ); m_ctlEdit.SetWindowPos( this, 0, 0, rc.Width(), rc.Height(), SWP_NOZORDER ); }
This will fill the view with the edit, which might not be what you want, but it's easy to adjust. Mike