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. List 2.0 checkbox and togglebutton

List 2.0 checkbox and togglebutton

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpcomquestionlearning
3 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.
  • B Offline
    B Offline
    bennyrascal
    wrote on last edited by
    #1

    Have revisited a C++ program i wrote about 6 years ago. It used the THREED vbx controls. Am now using Visual C++ 6.0 and i can not develop with them as they need a licence. Originally got them from buying the SAMS Visual C++ 1.5 book and CD. Anyway, i decided to replace them with an ocx that is more available. When i did an 'insert activex control', the Microsoft Forms 2.0 controls were available. Had no probs replacing my command buttons and frames but the check boxes have been a nightmare. Then i thought the toggle button might look better and tried it. Still a nightmare. Where my problem lies is in seeing the state of the checkbox and/or toggle button. Thought the following line would differentiate between depressed and not depressed: if (m_ToggleButton1Control.GetValue == false) However, it always returns true. i use other properties that work: {m_ToggleButton1Control.SetForeColor(olive_note);} The 'value' is defined as a VARIANT of which i can not find any documentation. Can anyone help??? benny

    R 1 Reply Last reply
    0
    • B bennyrascal

      Have revisited a C++ program i wrote about 6 years ago. It used the THREED vbx controls. Am now using Visual C++ 6.0 and i can not develop with them as they need a licence. Originally got them from buying the SAMS Visual C++ 1.5 book and CD. Anyway, i decided to replace them with an ocx that is more available. When i did an 'insert activex control', the Microsoft Forms 2.0 controls were available. Had no probs replacing my command buttons and frames but the check boxes have been a nightmare. Then i thought the toggle button might look better and tried it. Still a nightmare. Where my problem lies is in seeing the state of the checkbox and/or toggle button. Thought the following line would differentiate between depressed and not depressed: if (m_ToggleButton1Control.GetValue == false) However, it always returns true. i use other properties that work: {m_ToggleButton1Control.SetForeColor(olive_note);} The 'value' is defined as a VARIANT of which i can not find any documentation. Can anyone help??? benny

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      bennyrascal wrote: if (m_ToggleButton1Control.GetValue == false) Should work, if m_ToggleButton1Control is of type bool (or even BOOL), and if you used UpdateData (or corresponding message) with parameter TRUE. ~RaGE();

      B 1 Reply Last reply
      0
      • R Rage

        bennyrascal wrote: if (m_ToggleButton1Control.GetValue == false) Should work, if m_ToggleButton1Control is of type bool (or even BOOL), and if you used UpdateData (or corresponding message) with parameter TRUE. ~RaGE();

        B Offline
        B Offline
        bennyrascal
        wrote on last edited by
        #3

        Thanks Can't use true as i get a compiler error: D:\Development\C++\Source\CheckBoxes\CheckBoxesDlg.cpp(195) : warning C4805: '==' : unsafe mix of type 'struct tagVARIANT (__thiscall CMdcToggleButton::*)(void)' and type 'const bool' in operation When using the class wizard to add a member variable the only choice i have is a category of control and a variable type of CMdcToggleButton. There are no other choices. If i use the standard checkBox then i get the categories of control and of value and the value bit works. As far as the updatedata, Here is the actual code: void CCheckBoxesDlg::OnClickToggleButton1() { UpdateData(TRUE); m_ToggleButton1Control.UpdateData(TRUE); m_ToggleButton1Control.GetValue(); if (m_ToggleButton1Control.GetValue == false) {m_ToggleButton1Control.SetForeColor(olive_note);} else {m_ToggleButton1Control.SetForeColor(red_note);} } As you can see i even did the update two different ways as an experiment. A similar function for a simple checkbox works perfectly: void CCheckBoxesDlg::OnClickFormsCheckBox1() { UpdateData(TRUE); if (m_FormsCheckBox1Control.GetValue == 0) { m_CommandButtonControl.SetForeColor(blue_note); m_CommandButtonControl.SetCaption("FormsCheckBox set on"); m_FormsCheckBox1Control.SetBackColor(blue_note); } else { m_CommandButtonControl.SetForeColor(yellow_note); m_CommandButtonControl.SetCaption("FormsCheckBox set off"); m_FormsCheckBox1Control.SetBackColor(yellow_note); } } Again thanks for any help as i'm baffled. benny

        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