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. Showing virtual list/CListCtrl for CMyComboBox ? How to pass LVN_GETDISPINFO to form view ?

Showing virtual list/CListCtrl for CMyComboBox ? How to pass LVN_GETDISPINFO to form view ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialquestion
14 Posts 2 Posters 1 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.
  • A anand_study

    Hi I have CMyComboBox derived from CComboBox. Using it in CMyFormView in VC++6/MFC/Win98/2K project. In my invoice form, I need to have multiple combos with 40000+ products. Virtual list for combo can make it possible. (multi column virtual list for combobox) What I am trying to achieve is : - show dynamically created CListCtrl* m_pMyListCtrl (with LVS_OWNERDATA) instead of default ListBox of CMyComboBox - that CListCtrl in virtual mode should get data from CMyFormView - same member of CMyFormView (CArray of products) used to show data in virtual list (m_pMyListCtrl) Problem is how to pass-on LVN_GETDISPINFO message from m_pMyListCtrl to CMyFormView so as to get item info (m_pMyListCtrl is dynamically created virtual list control - member of CMyComboBox). I truly appreciate any idea or help. Thanks Anand

    N Offline
    N Offline
    Naveen
    wrote on last edited by
    #2

    overide the WindowProc() of the formview inside it check 1. message is WM_NOTIFY 2. if so check wParam is LVN_GETDISPINFO 3. if so cast the lparam to LPNMLVDISPINFO

    nave

    A 1 Reply Last reply
    0
    • N Naveen

      overide the WindowProc() of the formview inside it check 1. message is WM_NOTIFY 2. if so check wParam is LVN_GETDISPINFO 3. if so cast the lparam to LPNMLVDISPINFO

      nave

      A Offline
      A Offline
      anand_study
      wrote on last edited by
      #3

      Thank you for helping. In fact, I am trying to use list of following multi-column combo control in virtual mode. Multi column Combo box (2) (CodeGuru Article) http://www.codeguru.com/cpp/controls/combobox/multicolumncombos/article.php/c1819/ What I tried is: 1. Added LVS_OWNERDATA style to defaultListControlStyle 2. Added my new view (CFormView) 3. Added custom control in view and subclassed (as suggested in article) for Multi column Combo Still I am unable to pass-on LVS_GETDISPINFO to my form view. (i.e. I could use list of this combo in normal mode in my form but unable to use it in virtual mode) Please help...(Urgent help needed). How to pass-on LVS_GETDISPINFO to my form view ? I truly appreciate any idea/help. Anand

      N 1 Reply Last reply
      0
      • A anand_study

        Thank you for helping. In fact, I am trying to use list of following multi-column combo control in virtual mode. Multi column Combo box (2) (CodeGuru Article) http://www.codeguru.com/cpp/controls/combobox/multicolumncombos/article.php/c1819/ What I tried is: 1. Added LVS_OWNERDATA style to defaultListControlStyle 2. Added my new view (CFormView) 3. Added custom control in view and subclassed (as suggested in article) for Multi column Combo Still I am unable to pass-on LVS_GETDISPINFO to my form view. (i.e. I could use list of this combo in normal mode in my form but unable to use it in virtual mode) Please help...(Urgent help needed). How to pass-on LVS_GETDISPINFO to my form view ? I truly appreciate any idea/help. Anand

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #4

        can u tell me the step u used to create the virtual listctrl. I mean who is the parent of the list ctrl. U should do the procedures that i said in the previous post in that parent window

        nave

        A 1 Reply Last reply
        0
        • N Naveen

          can u tell me the step u used to create the virtual listctrl. I mean who is the parent of the list ctrl. U should do the procedures that i said in the previous post in that parent window

          nave

          A Offline
          A Offline
          anand_study
          wrote on last edited by
          #5

          Naveen, Thanks a lot for helping. What I tried is: 1. Downloaded sample from following article and unzipped Multi column Combo box (2) (CodeGuru Article) http://www.codeguru.com/cpp/controls/combobox/multicolumncombos/article.php/c1819/ 2. Removed code which displays Multi-column Combo in toolbar (from Mainframe.h and Mainframe.cpp) as I don't need that 3. Added LVS_OWNERDATA style to defaultListControlStyle 4. Created new dialog resource (Set style to Child and Border None), and added custome control IDC_CUSTOM1 (class MultiColumnComboBox) 5. Created new view class CMyTestView (derived from CFormView) 5. Added protected member to CMyTestView ->> CMultiColumnComboBox m_combo; 6. void CMyTestView::OnInitialUpdate() { CFormView::OnInitialUpdate(); // subclassed custom control (as suggested in article) m_combo.SubclassDlgItem(IDC_CUSTOM1); // add columns to list // do not insert items in list (as it is virtual) CListCtrl* pList = m_combo.GetListCtrl(); pList->InsertColumn(0, _T("Col 1"), LVCFMT_LEFT, 100); pList->InsertColumn(1, _T("Col 2"), LVCFMT_LEFT, 100); } 8. To make view class as parent of list control, In CMultiColumnComboBox::OnInit() (where ListControl is created) I replaced following line // if( m_pListCtrl->Create(WS_BORDER|WS_CHILD|defaultListControlStyle, Crect(0,0,0,0), GetDeskTopwindow(), IDLISTCTRL) ) with if( m_pListCtrl->Create(WS_BORDER|WS_CHILD|defaultListControlStyle, Crect(0,0,0,0), this->GetParent(), IDLISTCTRL) ) 7. Then tried as you suggested in CMyTestView. In view, I am getting LVN_GETDISPINFO notification I am setting item text but list is not getting even single item I am unable to get data through LVS_GETDISPINFO to list of combo in form view. (i.e. I could use list of this combo in normal mode in my form but unable to get data from view in list of combo in virtual list mode) Please help...(Urgent help needed). I truly appreciate any idea/help. Anand

          N 1 Reply Last reply
          0
          • A anand_study

            Naveen, Thanks a lot for helping. What I tried is: 1. Downloaded sample from following article and unzipped Multi column Combo box (2) (CodeGuru Article) http://www.codeguru.com/cpp/controls/combobox/multicolumncombos/article.php/c1819/ 2. Removed code which displays Multi-column Combo in toolbar (from Mainframe.h and Mainframe.cpp) as I don't need that 3. Added LVS_OWNERDATA style to defaultListControlStyle 4. Created new dialog resource (Set style to Child and Border None), and added custome control IDC_CUSTOM1 (class MultiColumnComboBox) 5. Created new view class CMyTestView (derived from CFormView) 5. Added protected member to CMyTestView ->> CMultiColumnComboBox m_combo; 6. void CMyTestView::OnInitialUpdate() { CFormView::OnInitialUpdate(); // subclassed custom control (as suggested in article) m_combo.SubclassDlgItem(IDC_CUSTOM1); // add columns to list // do not insert items in list (as it is virtual) CListCtrl* pList = m_combo.GetListCtrl(); pList->InsertColumn(0, _T("Col 1"), LVCFMT_LEFT, 100); pList->InsertColumn(1, _T("Col 2"), LVCFMT_LEFT, 100); } 8. To make view class as parent of list control, In CMultiColumnComboBox::OnInit() (where ListControl is created) I replaced following line // if( m_pListCtrl->Create(WS_BORDER|WS_CHILD|defaultListControlStyle, Crect(0,0,0,0), GetDeskTopwindow(), IDLISTCTRL) ) with if( m_pListCtrl->Create(WS_BORDER|WS_CHILD|defaultListControlStyle, Crect(0,0,0,0), this->GetParent(), IDLISTCTRL) ) 7. Then tried as you suggested in CMyTestView. In view, I am getting LVN_GETDISPINFO notification I am setting item text but list is not getting even single item I am unable to get data through LVS_GETDISPINFO to list of combo in form view. (i.e. I could use list of this combo in normal mode in my form but unable to get data from view in list of combo in virtual list mode) Please help...(Urgent help needed). I truly appreciate any idea/help. Anand

            N Offline
            N Offline
            Naveen
            wrote on last edited by
            #6

            can u show me the code u used in the CMyTestView for getting the LVN_GETDISPINFO notifications and setting the text..? Also i hope u have inserted two columns in the list ctrl...

            nave

            N 1 Reply Last reply
            0
            • N Naveen

              can u show me the code u used in the CMyTestView for getting the LVN_GETDISPINFO notifications and setting the text..? Also i hope u have inserted two columns in the list ctrl...

              nave

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #7

              pls asure CListCtrl::SetItemCountEx() has been called with proper value

              nave

              A 1 Reply Last reply
              0
              • N Naveen

                pls asure CListCtrl::SetItemCountEx() has been called with proper value

                nave

                A Offline
                A Offline
                anand_study
                wrote on last edited by
                #8

                Thanks Naveen for taking me into right direction. I did forget to set count for list with SetItemCountEx() I did it and now I am able to show 100000+ items in the virtual list of CMultiColumnComboBox. Thanks a lot for helping me. One Question..? I have custom control IDC_CUSTOM1 in dialog resource of my view. I have subclassed IDC_CUSTOM1 to CMultiColumnComboBox In my project value for IDC_CUSTOM1 is 1005 In MultiColumnComboBox.h value for IDLISTCTRL is 0x3E8 (i.e. 1000) View gets LVN_GETDISPINFO message directly from IDLISTCTRL (i.e. with control-id == IDLISTCTRL) But I need LVN_GETDISPINFO with id of custom control IDC_CUSTOM1 (i.e. with control-id == IDC_CUSTOM1) How to modify CMultiColumnComboBox::ParentWndProc or MultiColumnComboBox::ListCtrlWndProc so that I get LVN_GETDISPINFO with ID of parent custom control and not of ListCtrl ? So I can distinguish LVN_GETDISPINFO message in case of multiple combos. Because I need to use multiple combos IDC_CUSTOM1 , IDC_CUSTOM2, IDC_CUSTOM3 etc. and each of them in virtual mode. Thank You. Anand

                N 1 Reply Last reply
                0
                • A anand_study

                  Thanks Naveen for taking me into right direction. I did forget to set count for list with SetItemCountEx() I did it and now I am able to show 100000+ items in the virtual list of CMultiColumnComboBox. Thanks a lot for helping me. One Question..? I have custom control IDC_CUSTOM1 in dialog resource of my view. I have subclassed IDC_CUSTOM1 to CMultiColumnComboBox In my project value for IDC_CUSTOM1 is 1005 In MultiColumnComboBox.h value for IDLISTCTRL is 0x3E8 (i.e. 1000) View gets LVN_GETDISPINFO message directly from IDLISTCTRL (i.e. with control-id == IDLISTCTRL) But I need LVN_GETDISPINFO with id of custom control IDC_CUSTOM1 (i.e. with control-id == IDC_CUSTOM1) How to modify CMultiColumnComboBox::ParentWndProc or MultiColumnComboBox::ListCtrlWndProc so that I get LVN_GETDISPINFO with ID of parent custom control and not of ListCtrl ? So I can distinguish LVN_GETDISPINFO message in case of multiple combos. Because I need to use multiple combos IDC_CUSTOM1 , IDC_CUSTOM2, IDC_CUSTOM3 etc. and each of them in virtual mode. Thank You. Anand

                  N Offline
                  N Offline
                  Naveen
                  wrote on last edited by
                  #9

                  i think thats not possible. but there is turn around I hope u use a listctrl derived class object as virtual list(if not so, derive a class from clistctrl and use bject of that class as virault list ) Add a member variables in that class say m_nParentComboId; After u create the listctrl for a combo, set the correponding combos id into listctrl member variable(m_nParentComboId). So when ever u get a LVN_GET... message. check the m_nParentComboId to find which combox is associated with the list ctrl

                  nave

                  A 1 Reply Last reply
                  0
                  • N Naveen

                    i think thats not possible. but there is turn around I hope u use a listctrl derived class object as virtual list(if not so, derive a class from clistctrl and use bject of that class as virault list ) Add a member variables in that class say m_nParentComboId; After u create the listctrl for a combo, set the correponding combos id into listctrl member variable(m_nParentComboId). So when ever u get a LVN_GET... message. check the m_nParentComboId to find which combox is associated with the list ctrl

                    nave

                    A Offline
                    A Offline
                    anand_study
                    wrote on last edited by
                    #10

                    Nice idea to add m_nParentComboId for parent combo identification. I may do that. But One thing... In CMultiColumnComboBox::OnInit(), after creating list control, with ::SetWindowLong statement... it stores pointer to CMultiColumnComboBox as a long. ::SetWindowLong( m_pListCtrl->m_hWnd, GWL_USERDATA, long(this) ); (Whenever LVN_GETDISPINFO message comes in view from list ctrl) Can I get that value and use that value to identify control id or parent combo ? Thanks for all your help. I learnt nice tricks for handling virtual list. Anand

                    N 1 Reply Last reply
                    0
                    • A anand_study

                      Nice idea to add m_nParentComboId for parent combo identification. I may do that. But One thing... In CMultiColumnComboBox::OnInit(), after creating list control, with ::SetWindowLong statement... it stores pointer to CMultiColumnComboBox as a long. ::SetWindowLong( m_pListCtrl->m_hWnd, GWL_USERDATA, long(this) ); (Whenever LVN_GETDISPINFO message comes in view from list ctrl) Can I get that value and use that value to identify control id or parent combo ? Thanks for all your help. I learnt nice tricks for handling virtual list. Anand

                      N Offline
                      N Offline
                      Naveen
                      wrote on last edited by
                      #11

                      That too is a good idea. :) Later u can use GetWindowLong() to get retrive the pointer... Where r u from anand?I am from kerala->India

                      nave

                      A 2 Replies Last reply
                      0
                      • N Naveen

                        That too is a good idea. :) Later u can use GetWindowLong() to get retrive the pointer... Where r u from anand?I am from kerala->India

                        nave

                        A Offline
                        A Offline
                        anand_study
                        wrote on last edited by
                        #12

                        Naveen, Thanks a lot for helping. You always answered nicely, regularly and promptly. Are you working for CodeProject or what ? I am from Vadodara (Gujarat-India). Thanks again. Anand

                        N 1 Reply Last reply
                        0
                        • A anand_study

                          Naveen, Thanks a lot for helping. You always answered nicely, regularly and promptly. Are you working for CodeProject or what ? I am from Vadodara (Gujarat-India). Thanks again. Anand

                          N Offline
                          N Offline
                          Naveen
                          wrote on last edited by
                          #13

                          no no .. I am working in a company in kerala itself(NeST). Answering in CP is just a hobby...:)

                          nave

                          1 Reply Last reply
                          0
                          • N Naveen

                            That too is a good idea. :) Later u can use GetWindowLong() to get retrive the pointer... Where r u from anand?I am from kerala->India

                            nave

                            A Offline
                            A Offline
                            anand_study
                            wrote on last edited by
                            #14

                            Naveen, Thanks a lot for helping. You always answered nicely, regularly and promptly. Are you working for CodeProject ? I am from Vadodara (Gujarat-India) Thanks again. Anand

                            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