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. Controls, variable and dialogs

Controls, variable and dialogs

Scheduled Pinned Locked Moved C / C++ / MFC
c++architecturequestion
4 Posts 3 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.
  • L Offline
    L Offline
    lor75
    wrote on last edited by
    #1

    Hello, i'm quite new to MFC programming and I would like if my software architecture can be simplified. Let's suppose to have an MFC program where I put a member variable in CView class. This variable is set by a control put in a dialog window called by a menù. I usually set a control variable in order to get the control value in order to avoid the GetdlgItem command. The value of the control is used to set a member variable inside tha class of the dialog window and then when i close the dialog I copy the value of the dialog's variable into the main window variable control variable -> member variable of the dialog window -> member variable of the main Cview window With this scheme I Have to use 3 variables for each controls and this is quite expensive. Can anyone suggest me a simpler way to get to synchronize the variable used by the main window with the value of a control inside a dialog window? Best regards.

    D F 2 Replies Last reply
    0
    • L lor75

      Hello, i'm quite new to MFC programming and I would like if my software architecture can be simplified. Let's suppose to have an MFC program where I put a member variable in CView class. This variable is set by a control put in a dialog window called by a menù. I usually set a control variable in order to get the control value in order to avoid the GetdlgItem command. The value of the control is used to set a member variable inside tha class of the dialog window and then when i close the dialog I copy the value of the dialog's variable into the main window variable control variable -> member variable of the dialog window -> member variable of the main Cview window With this scheme I Have to use 3 variables for each controls and this is quite expensive. Can anyone suggest me a simpler way to get to synchronize the variable used by the main window with the value of a control inside a dialog window? Best regards.

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

      As I understand your problem, two variables are needed: one used by the dialog class, and the other used by the view class.

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

      L 1 Reply Last reply
      0
      • D David Crow

        As I understand your problem, two variables are needed: one used by the dialog class, and the other used by the view class.

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        L Offline
        L Offline
        lor75
        wrote on last edited by
        #3

        Yes, two variables. But I don't know if there is a better way to get the same result.

        1 Reply Last reply
        0
        • L lor75

          Hello, i'm quite new to MFC programming and I would like if my software architecture can be simplified. Let's suppose to have an MFC program where I put a member variable in CView class. This variable is set by a control put in a dialog window called by a menù. I usually set a control variable in order to get the control value in order to avoid the GetdlgItem command. The value of the control is used to set a member variable inside tha class of the dialog window and then when i close the dialog I copy the value of the dialog's variable into the main window variable control variable -> member variable of the dialog window -> member variable of the main Cview window With this scheme I Have to use 3 variables for each controls and this is quite expensive. Can anyone suggest me a simpler way to get to synchronize the variable used by the main window with the value of a control inside a dialog window? Best regards.

          F Offline
          F Offline
          Freak30
          wrote on last edited by
          #4

          If you are worried about the memory needed to store several values twice, you could define a class or struct, create an object of it in your view class and pass the reference to this object to the dialog objects in their constructors. This way you only have 4 byte overhead per dialog.

          The good thing about pessimism is, that you are always either right or pleasently surprised.

          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