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