0
votes

I have my Main Dialog and some minor dialogs opened by buttons in Main.

I got object X of class ABC declared as a member of Main Dialog. I want to edit (get and set values) object X from any dialog.

How can I do it? I read that it impossible to declare variable globally (tryed it in MyApp.h, or in MyApp class but there was linker error with redefinition)

The only solution that came to my main is to add to buttons:

CNewDialog newdialog;
newdialog.A=A;
newdialog.DoModal();
A=newdialog.A;

Will it work? Or is there any other solution?

On the other hand, there will be visible changes in Main Dialog only after closing newdialog and I don't want this.

2
The code should work as long as the other Ais declared globally -- where is the code you have given above placed? - Edward Clements

2 Answers

0
votes

I would use Common Configuration Facility designed using Singleton pattern to solve your task.

0
votes

The main dialog object can be accessed from anywhere by calling AfxGetMainWnd. Cast the returned pointer into a pointer to your main dialog class.