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. Arrays of control

Arrays of control

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structureshelpquestion
4 Posts 4 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.
  • T Offline
    T Offline
    TV
    wrote on last edited by
    #1

    Hello, I'am doing a mfc dialog based program. In this one, I have a settings dialog box that should allow the user to select somethings through check boxes. The problem is that I've a lot of checkbox in this dialog (18 check box even more later!). I wanted to do array of controls in my settings dialog box (just like in VB). In order to do that I've short-circuited Class wizard to create an array of CButton member variables but I still have to enumerate each variable for each ID of each control with the DDX_Control(...) macro. There is also another problem. If the member variable is defined like this: CButton m_variable1; I can use the following statement: m_variable1.SetCheck(); But if I use the following declaration: CButton m_variable[18]; m_variable[0].SetCheck(); I'have a assertion failed. Can somebody give me a smart way to do such array of control? Thanks a lot. T. Varidel

    A H A 3 Replies Last reply
    0
    • T TV

      Hello, I'am doing a mfc dialog based program. In this one, I have a settings dialog box that should allow the user to select somethings through check boxes. The problem is that I've a lot of checkbox in this dialog (18 check box even more later!). I wanted to do array of controls in my settings dialog box (just like in VB). In order to do that I've short-circuited Class wizard to create an array of CButton member variables but I still have to enumerate each variable for each ID of each control with the DDX_Control(...) macro. There is also another problem. If the member variable is defined like this: CButton m_variable1; I can use the following statement: m_variable1.SetCheck(); But if I use the following declaration: CButton m_variable[18]; m_variable[0].SetCheck(); I'have a assertion failed. Can somebody give me a smart way to do such array of control? Thanks a lot. T. Varidel

      A Offline
      A Offline
      Alvaro Mendez
      wrote on last edited by
      #2

      The smart alternative: A list box of checkboxes, via the CCheckListBox class. Regards, Alvaro


      Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)

      1 Reply Last reply
      0
      • T TV

        Hello, I'am doing a mfc dialog based program. In this one, I have a settings dialog box that should allow the user to select somethings through check boxes. The problem is that I've a lot of checkbox in this dialog (18 check box even more later!). I wanted to do array of controls in my settings dialog box (just like in VB). In order to do that I've short-circuited Class wizard to create an array of CButton member variables but I still have to enumerate each variable for each ID of each control with the DDX_Control(...) macro. There is also another problem. If the member variable is defined like this: CButton m_variable1; I can use the following statement: m_variable1.SetCheck(); But if I use the following declaration: CButton m_variable[18]; m_variable[0].SetCheck(); I'have a assertion failed. Can somebody give me a smart way to do such array of control? Thanks a lot. T. Varidel

        H Offline
        H Offline
        Heywood
        wrote on last edited by
        #3

        You can do something like this: CButton* pButton[] = { &m_chk1, &m_chk2, &m_chk3, &m_chk4, }; pButton[n]->DoSomething(); or UINT array[] = { IDC_CONTROL1, IDC_CONTROL2, IDC_CONTROL3, IDC_CONTROL4, }; GetDlgItem(array[n)->DoSomething(); or use collection classes or STL; header file: vector m_wnds; then add your controls int OInitDialog: m_wnds.push_back(&m_chk1); m_wnds.push_back(&m_chk2; m_wnds.push_back(&m_chk3); m_wnds.push_back(&m_chk4); m_wnds.at(i)->DoSomething();

        1 Reply Last reply
        0
        • T TV

          Hello, I'am doing a mfc dialog based program. In this one, I have a settings dialog box that should allow the user to select somethings through check boxes. The problem is that I've a lot of checkbox in this dialog (18 check box even more later!). I wanted to do array of controls in my settings dialog box (just like in VB). In order to do that I've short-circuited Class wizard to create an array of CButton member variables but I still have to enumerate each variable for each ID of each control with the DDX_Control(...) macro. There is also another problem. If the member variable is defined like this: CButton m_variable1; I can use the following statement: m_variable1.SetCheck(); But if I use the following declaration: CButton m_variable[18]; m_variable[0].SetCheck(); I'have a assertion failed. Can somebody give me a smart way to do such array of control? Thanks a lot. T. Varidel

          A Offline
          A Offline
          Andreas Saurwein
          wrote on last edited by
          #4

          Redesign your app. 18 checkboxes in one dialog is just too much. And use a listview, a tree with checkboxes, whatever.


          I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge

          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