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. Calling UpdateData(FALSE) will screw my RadioButton-group selection

Calling UpdateData(FALSE) will screw my RadioButton-group selection

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
6 Posts 4 Posters 8 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.
  • A Offline
    A Offline
    andreir23
    wrote on last edited by
    #1

    Here's my problem: I have 2 radio buttons in my dialog-based MFCAppWizard-made application (first radio button has "Group" property and is mapped to m_Operation). Their names are: "Encode" and "Decode" By default (in OnInitDialog) I select the first radio button (otherwise none would be selected at startup) with: m_Operation = 0; I have 2 Static Text controls (IDC_SOURCE and IDC_DESTINATION) both mapped thru ClassWizard to m_Source (CString type) and m_Destination (CString also) At a certain point the user selects a file and the app will write something to m_Source: m_Source = "C:\\MyFile.txt"; But that won't make it visible in the main form so I: UpdateData(FALSE); And it becomes visible. But MY PROBLEM IS THAT IN THAT MOMENT THE RADIO BUTTON SELECTION SCREWS UP. How is that? If "Decode" was selected before UpdateData(2nd radio button - "1") then "Encode" will become selected (1st radio button - "0"). HOW CAN I AVOID THIS? Not calling UpdateData or UpdateData() or UpdateData(TRUE) will cause this: m_Source = "C:\\AnyFile.txt"; does not update visually the static text control in my app. Please help?! ;-) Andrei Rinea

    A D N 3 Replies Last reply
    0
    • A andreir23

      Here's my problem: I have 2 radio buttons in my dialog-based MFCAppWizard-made application (first radio button has "Group" property and is mapped to m_Operation). Their names are: "Encode" and "Decode" By default (in OnInitDialog) I select the first radio button (otherwise none would be selected at startup) with: m_Operation = 0; I have 2 Static Text controls (IDC_SOURCE and IDC_DESTINATION) both mapped thru ClassWizard to m_Source (CString type) and m_Destination (CString also) At a certain point the user selects a file and the app will write something to m_Source: m_Source = "C:\\MyFile.txt"; But that won't make it visible in the main form so I: UpdateData(FALSE); And it becomes visible. But MY PROBLEM IS THAT IN THAT MOMENT THE RADIO BUTTON SELECTION SCREWS UP. How is that? If "Decode" was selected before UpdateData(2nd radio button - "1") then "Encode" will become selected (1st radio button - "0"). HOW CAN I AVOID THIS? Not calling UpdateData or UpdateData() or UpdateData(TRUE) will cause this: m_Source = "C:\\AnyFile.txt"; does not update visually the static text control in my app. Please help?! ;-) Andrei Rinea

      A Offline
      A Offline
      abc876
      wrote on last edited by
      #2

      Associate a CStatic object with static text control and call staticobj.SetWindowText("text") to change the text of static control instead of calling UpdateData :) Muhammad Shoaib Khan http://geocities.com/lansolution

      1 Reply Last reply
      0
      • A andreir23

        Here's my problem: I have 2 radio buttons in my dialog-based MFCAppWizard-made application (first radio button has "Group" property and is mapped to m_Operation). Their names are: "Encode" and "Decode" By default (in OnInitDialog) I select the first radio button (otherwise none would be selected at startup) with: m_Operation = 0; I have 2 Static Text controls (IDC_SOURCE and IDC_DESTINATION) both mapped thru ClassWizard to m_Source (CString type) and m_Destination (CString also) At a certain point the user selects a file and the app will write something to m_Source: m_Source = "C:\\MyFile.txt"; But that won't make it visible in the main form so I: UpdateData(FALSE); And it becomes visible. But MY PROBLEM IS THAT IN THAT MOMENT THE RADIO BUTTON SELECTION SCREWS UP. How is that? If "Decode" was selected before UpdateData(2nd radio button - "1") then "Encode" will become selected (1st radio button - "0"). HOW CAN I AVOID THIS? Not calling UpdateData or UpdateData() or UpdateData(TRUE) will cause this: m_Source = "C:\\AnyFile.txt"; does not update visually the static text control in my app. Please help?! ;-) Andrei Rinea

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

        andreir23 wrote: But MY PROBLEM IS THAT IN THAT MOMENT THE RADIO BUTTON SELECTION SCREWS UP. How is that? If "Decode" was selected before UpdateData(2nd radio button - "1") then "Encode" will become selected (1st radio button - "0"). HOW CAN I AVOID THIS? Not calling UpdateData or UpdateData() or UpdateData(TRUE) will cause this: m_Source = "C:\\AnyFile.txt"; does not update visually the static text control in my app. Which is why UpdateData() should be used as little, if at all, as necessary. Use member control variables instead.


        A rich person is not the one who has the most, but the one that needs the least.

        A 1 Reply Last reply
        0
        • A andreir23

          Here's my problem: I have 2 radio buttons in my dialog-based MFCAppWizard-made application (first radio button has "Group" property and is mapped to m_Operation). Their names are: "Encode" and "Decode" By default (in OnInitDialog) I select the first radio button (otherwise none would be selected at startup) with: m_Operation = 0; I have 2 Static Text controls (IDC_SOURCE and IDC_DESTINATION) both mapped thru ClassWizard to m_Source (CString type) and m_Destination (CString also) At a certain point the user selects a file and the app will write something to m_Source: m_Source = "C:\\MyFile.txt"; But that won't make it visible in the main form so I: UpdateData(FALSE); And it becomes visible. But MY PROBLEM IS THAT IN THAT MOMENT THE RADIO BUTTON SELECTION SCREWS UP. How is that? If "Decode" was selected before UpdateData(2nd radio button - "1") then "Encode" will become selected (1st radio button - "0"). HOW CAN I AVOID THIS? Not calling UpdateData or UpdateData() or UpdateData(TRUE) will cause this: m_Source = "C:\\AnyFile.txt"; does not update visually the static text control in my app. Please help?! ;-) Andrei Rinea

          N Offline
          N Offline
          Nick Hodapp
          wrote on last edited by
          #4

          Add a handler for BN_CLICKED for each of your radio buttons. In the handler, set the m_Operation member to the button that was just clicked. It isn't otherwise being updated, which is why it reverts to the old setting when UpdateData(FALSE) is called. void CDlgtestDlg::OnRadio1() { m_Radio = 0; } void CDlgtestDlg::OnRadio2() { m_Radio = 1; } or you can add a single handler for this using ON_CONTROL_RANGE(BN_CLICKED ...) Nick This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2003 Microsoft Corporation. All rights reserved.

          1 Reply Last reply
          0
          • D David Crow

            andreir23 wrote: But MY PROBLEM IS THAT IN THAT MOMENT THE RADIO BUTTON SELECTION SCREWS UP. How is that? If "Decode" was selected before UpdateData(2nd radio button - "1") then "Encode" will become selected (1st radio button - "0"). HOW CAN I AVOID THIS? Not calling UpdateData or UpdateData() or UpdateData(TRUE) will cause this: m_Source = "C:\\AnyFile.txt"; does not update visually the static text control in my app. Which is why UpdateData() should be used as little, if at all, as necessary. Use member control variables instead.


            A rich person is not the one who has the most, but the one that needs the least.

            A Offline
            A Offline
            andreir23
            wrote on last edited by
            #5

            Allrighte... But if I don't use that darn UpdateData, I CANNOT UPDATE the static text. Let me put the problem in a simpler manner: You have a static text (in Delphi it was called "Label") How do you modify its content and then update it visually so the darn thing on the screen reflects what you wrote in it?! I mean I mapped thru ClassWizard a CString to that static text control named m_Source. If I just say m_Source = "My text!!"; nothing on the screen changes. Especially that darn static text. How exactly do you recommend me to do it? TIA! ;-)

            A 1 Reply Last reply
            0
            • A andreir23

              Allrighte... But if I don't use that darn UpdateData, I CANNOT UPDATE the static text. Let me put the problem in a simpler manner: You have a static text (in Delphi it was called "Label") How do you modify its content and then update it visually so the darn thing on the screen reflects what you wrote in it?! I mean I mapped thru ClassWizard a CString to that static text control named m_Source. If I just say m_Source = "My text!!"; nothing on the screen changes. Especially that darn static text. How exactly do you recommend me to do it? TIA! ;-)

              A Offline
              A Offline
              abc876
              wrote on last edited by
              #6

              andreir23 wrote: I mean I mapped thru ClassWizard a CString to that static text control named m_Source. Dont map a CString to that static text control. Map a CStatic to that static text control m_source( Just select Control in the combobox where u map a variable, it will autmatically show CStatic in the datatype field) Now if u just want to change the text of static control, and want other controls like radio to remain unchanged, just call this function m_source.SetWindowText("My Text!!"); It will modify its contents and update it visually.. Now to retrieve the text from static control call CString str; m_source.GetWindowText(str); OR U can also use SendMessage(m_source.GetSafeHwnd(),WM_SETTEXT,(WPARAM)0,(LPARAM)"My Text"); to achieve the same task *visually updating static text without chaning any other control. This will definately solve your problem.. :) Muhammad Shoaib Khan http://geocities.com/lansolution

              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