Link to home
Start Free TrialLog in
Avatar of simongod
simongod

asked on

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.

**********
//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;
      while(!rec.IsEOF())
      {
            //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);
                        
            x++;
            rec.MoveNext();
      }
*******

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

ASKER CERTIFIED SOLUTION
Avatar of jhance
jhance

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of simongod
simongod

ASKER

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.
it worked thanks