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. please help with my attempt to edit subitem of CListCtrl

please help with my attempt to edit subitem of CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 2 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.
  • L Offline
    L Offline
    lucy 0
    wrote on last edited by
    #1

    I'm trying to edit subitem of a CListCtrl object. Here's what I do: void CMyDialog::OnBeginLabelEditMyListCtrl(NMHDR* pNMHDR, LRESULT *pResult) { // based on current mouse position, find out which item and // iSubItem are being clicked by using m_myListCtrl.SubItemHitTest(&ht) // get the rect of the licked sub item by // m_myListCtrl.getSubItemRect(ht.iItem, ht.iSubItem, LVIR_LABEL, subRect); // try to put my variable CEdit m_edit at this location CEdit *plistEdit = m_myListCtrl.GetEditControl(); if ( plistEdit ) { m_edit.SubClassWindow(plistEdit->m_hWnd); <--- ERROR here } // coding to set *pResult } when running, the error message is: Error: Trying to use SubclassWindow with incorrect CWnd derived class. hWnd = $608D8 (nIDC=$0000) is not a CEdit. how come? both plistEdit and m_edit are of CEdit, why this error? Thanks for any help!

    L PJ ArendsP 2 Replies Last reply
    0
    • L lucy 0

      I'm trying to edit subitem of a CListCtrl object. Here's what I do: void CMyDialog::OnBeginLabelEditMyListCtrl(NMHDR* pNMHDR, LRESULT *pResult) { // based on current mouse position, find out which item and // iSubItem are being clicked by using m_myListCtrl.SubItemHitTest(&ht) // get the rect of the licked sub item by // m_myListCtrl.getSubItemRect(ht.iItem, ht.iSubItem, LVIR_LABEL, subRect); // try to put my variable CEdit m_edit at this location CEdit *plistEdit = m_myListCtrl.GetEditControl(); if ( plistEdit ) { m_edit.SubClassWindow(plistEdit->m_hWnd); <--- ERROR here } // coding to set *pResult } when running, the error message is: Error: Trying to use SubclassWindow with incorrect CWnd derived class. hWnd = $608D8 (nIDC=$0000) is not a CEdit. how come? both plistEdit and m_edit are of CEdit, why this error? Thanks for any help!

      L Offline
      L Offline
      lucy 0
      wrote on last edited by
      #2

      ok, got it. I declared m_edit in my header file, and called m_edit.Create() in the initialization routine. I shouldn't. that's how I got the assertion failure.

      1 Reply Last reply
      0
      • L lucy 0

        I'm trying to edit subitem of a CListCtrl object. Here's what I do: void CMyDialog::OnBeginLabelEditMyListCtrl(NMHDR* pNMHDR, LRESULT *pResult) { // based on current mouse position, find out which item and // iSubItem are being clicked by using m_myListCtrl.SubItemHitTest(&ht) // get the rect of the licked sub item by // m_myListCtrl.getSubItemRect(ht.iItem, ht.iSubItem, LVIR_LABEL, subRect); // try to put my variable CEdit m_edit at this location CEdit *plistEdit = m_myListCtrl.GetEditControl(); if ( plistEdit ) { m_edit.SubClassWindow(plistEdit->m_hWnd); <--- ERROR here } // coding to set *pResult } when running, the error message is: Error: Trying to use SubclassWindow with incorrect CWnd derived class. hWnd = $608D8 (nIDC=$0000) is not a CEdit. how come? both plistEdit and m_edit are of CEdit, why this error? Thanks for any help!

        PJ ArendsP Offline
        PJ ArendsP Offline
        PJ Arends
        wrote on last edited by
        #3

        What is the value of m_edit::m_hWnd before the call to m_edit.SubclassWindow()? m_edit is not allowed to have an window already attached to it before calling SubclassWindow. Look up CWnd::SubclassWindow in MSDN for more information.


        "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!


        Honoured as one of The Most Helpful Members of 2004

        Within you lies the power for good; Use it!

        L 1 Reply Last reply
        0
        • PJ ArendsP PJ Arends

          What is the value of m_edit::m_hWnd before the call to m_edit.SubclassWindow()? m_edit is not allowed to have an window already attached to it before calling SubclassWindow. Look up CWnd::SubclassWindow in MSDN for more information.


          "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!


          Honoured as one of The Most Helpful Members of 2004

          L Offline
          L Offline
          lucy 0
          wrote on last edited by
          #4

          yes, you are correct. As my previous post said, I shouldn't call m_edit.Create() in the initialization routine, that cause the assertion failure. Thank you!

          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