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. How to set default radio button in MFC

How to set default radio button in MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
7 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.
  • V Offline
    V Offline
    Vaclav
    wrote on last edited by
    #1

    I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav

    J P D V 5 Replies Last reply
    0
    • V Vaclav

      I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav

      J Offline
      J Offline
      Jitendra gangwar
      wrote on last edited by
      #2

      I think you should do all this in OnInitDialog() in place of OnCreate. Jitendra.

      V 1 Reply Last reply
      0
      • V Vaclav

        I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav

        P Offline
        P Offline
        Priyank Bolia
        wrote on last edited by
        #3

        1.) CButton* pRadio = (CButton*)GetDlgItem(ID_OF_RADIO_BUTTON); radioState = pRadio->SetCheck(1); 2.) CButton m_RadioButton; //Declare in .h file int m_bRadio; //In Constructor m_bRadio = 1; //Write in DoDataExchange function DDX_Control(pDX, ID_OF_RADIO_BUTTON, m_RadioButton); DDX_Radio(pDX, ID_OF_RADIO_BUTTON, m_bRadio); http://www.priyank.in/

        1 Reply Last reply
        0
        • V Vaclav

          I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Vaclav wrote: ...in OnCreate. Why not OnInitialUpdate()?


          "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

          1 Reply Last reply
          0
          • V Vaclav

            I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav

            V Offline
            V Offline
            Vaclav
            wrote on last edited by
            #5

            Thanks for all the suggestions. Here is an update on my problem: 1. OnInitUpdate does not get executed. Don't know why. 2. If I do this, CButton* pRadio = (CButton*)GetDlgItem(ID_OF_RADIO_BUTTON); radioState = pRadio->SetCheck(1); and put in in OnCreate I 'll get assertion failure because the m_hWnd is still null at that point of program execution. I think that is the root of my problem - no m_hWnd. The above code seems to duplicate variable CButton already defined in the accompanining dialog resource anyway. Do I understand it correctly that you have used two variables associted with CButton - the control itself and than the state? PS The following code as is cannot work because SetCheck "returns" void. radioState = pRadio->SetCheck(1); Vaclav

            1 Reply Last reply
            0
            • J Jitendra gangwar

              I think you should do all this in OnInitDialog() in place of OnCreate. Jitendra.

              V Offline
              V Offline
              Vaclav
              wrote on last edited by
              #6

              Sorry, my code does not have OnInitDialog as much as it should. I'll look into that. Thanks Vaclav

              1 Reply Last reply
              0
              • V Vaclav

                I have a property page with radio buttons group derived from CFormView and cannot figure out how to set default radio button - either in the "dialog" or at run time. My variables are CButton and SetCheck(1) asserts in OnCreate. Thanks for your help Vaclav

                V Offline
                V Offline
                Vaclav
                wrote on last edited by
                #7

                Problem solved! I did not read the fine print - poor excuse! I can set the default radio button ( SetCheck(1)) in any page AFTER the PropertyView OnCreate is finished with AddPage ! Thanks for all you suggestions, it helped. Vaclav

                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