Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. maybe a stupid Question,but need help!

maybe a stupid Question,but need help!

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    josephvan
    wrote on last edited by
    #1

    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

    M M 2 Replies Last reply
    0
    • J josephvan

      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

      M Offline
      M Offline
      Mike Danberg
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • J josephvan

        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

        M Offline
        M Offline
        Mike ONeill
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups