Click here to Skip to main content
15,885,978 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have added two dialogs in SDI.
Dialog 1: Position
Dialog 2: Velocity
Now i want to add a variable or function. How or where to add a variable or function which is accessible in both dialogs. what to do???

What I have tried:

I have added two dialogs in SDI. Now i want to a if file.
Dialog 1: Position
Dialog 2: Velocity
How to add a variable or function which is accessible in both dialogs. what to do???
Posted
Updated 3-Oct-18 23:23pm
v3
Comments
Richard MacCutchan 4-Oct-18 4:29am    
What exactly are you trying to achieve? You can add a variable in the constructor or any method of the CDialog class. Adding the same function to both would be a little more work.

You need some common data, possible is it as member in a permanent class object (like the app or document) or as global object. You can this achieve via some PostMessage architecture and send the data as parameters, or as global model object which is accessable via pointers to both dialogs.
 
Share this answer
 
Assuming the dialogs share same parent window, any public method of such parent window is accessible to both.
E.g. suppose the parent window (say MainWindow) implements a public method (say getMass()), then, in any of dialogs you may write:
C++
MainWindow *pmw = reinterpret_cast<MainWindow *> (GetParent());
int mass = pmw->getMass();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900