[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

dialog based project and radio buttons

i have a dialog based project.  I know how to open an access database.  What I want to be able to do is when I make a selection with my radio button and checkbox it will reflect what is displayed from my database inside of my listctrl.

Here is the code I have to open my database.

CDaoDatabase db;
CString Name = _T(""), Type = _T(""), Units = _T(""), XCord = _T(""), YCord = _T("");
COleVariant covVal;
CDaoRecordset rec(&db);

db.Open(_T("6se70.mdb"), TRUE, TRUE, _T(""));
      //put if statement here for radio and combobox selection
      rec.Open(dbOpenDynaset, _T("SELECT * FROM Parameter WHERE Parameter!Name LIKE 'n*'"), 0);
      m_database.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 83, -1);
      m_database.InsertColumn(1, _T("Type"), LVCFMT_LEFT, 60, -1);
      m_database.InsertColumn(2, _T("Units"), LVCFMT_LEFT, 60, -1);
      m_database.InsertColumn(3, _T("X Cord"), LVCFMT_LEFT, 55, -1);
      m_database.InsertColumn(4, _T("Y Cord"), LVCFMT_LEFT, 55, -1);
      int x=0;
            //Name Field
            rec.GetFieldValue(_T("Name"), covVal);
            strcpy(Name.GetBuffer(128), (char*)covVal.bstrVal);
            m_database.InsertItem(0, Name);
            //Type Field
            rec.GetFieldValue(_T("Type"), covVal);
            strcpy(Type.GetBuffer(128), (char*)covVal.bstrVal);
            m_database.SetItem(x, 1, LVIF_TEXT, Type, 0, 0, 0, 0);
            //Units Field
            rec.GetFieldValue(_T("Units"), covVal);
            strcpy(Units.GetBuffer(128), (char*)covVal.bstrVal);
            m_database.SetItem(x, 2, LVIF_TEXT, Units, 0, 0, 0, 0);
            //X Cord Field
            rec.GetFieldValue(_T("X Cord"), covVal);
            XCord.Format("%.3f", covVal.bstrVal);
            m_database.SetItem(x, 3, LVIF_TEXT, XCord, 0, 0, 0, 0);
            //Y Cord Field
            rec.GetFieldValue(_T("Y Cord"), covVal);
            YCord.Format("%.3f", covVal.bstrVal);
            m_database.SetItem(x, 4, LVIF_TEXT, YCord, 0, 0, 0, 0);

now when I choose a radio button and make a selection inside of a combobox it will make changes to the SELECT clause.  This is what I want it to do.  Please keep in mind that all of this code is performed inside of my OnInitDialog function.  Where do I put the code for the radio buttons and comboboxes and make it work, which is really what I want answered

  • 2
  • 2
1 Solution
Open the ClassWizard and add handlers for your radio buttons and comboboxes.

When your handlers get called you can do your processing.
simongodAuthor Commented:
I went to classwizard and made "member variables" is that what you mean?  where does the code go when I want to select an option in a combobox or radio button so that operation gets performed
No, that not what I meant.  Open the Class Wizard and choose MESSAGE MAPS.  Choose the Class Name that you are working with and then the Object ID for your radio button.  Choose the BN_CLICKED message and hit OK.  This will add a handler for you that will get called whenever that radio button is clicked.  Do the same for the combo box.
simongodAuthor Commented:
it worked thanks

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now