Re: Modal Dialog Record and Replay
On Nov 16, 6:17 am, "Leo Violette" <l...@primenet.com> wrote:
Don't initialize your data in OnInitialize.
Maybe think of your dialog class, not as a dialog class that loads and sa=
data, but perhaps as a data storage class that "happens" to show a dialog=
Add a LoadData and SaveData method to your class that loads and saves the
data to/from member variables that aren't CWnd based (not control
These methods would be public and would be called instead of DoModal in t=
instince that you are in replay mode (whatever that means).
By doing this, you are adding a layer of abstraction between your GUI and
your datastorage/validation and other business logic.
Doing it this way is not the best design, but it is a step closer and wou=
be fairly easy to implement from where you are now with the code.
LoadData would load the data from wherever you store it into member
variables (not control variables).
SaveData would store the data from the member variables into your datasto=
OnInitDialog would check to see if LoadData was already called, if not, i=
would call it. Then, it would transfer the data loaded in member varia=
the control variables.
OnOK would transfer data from your control variables to the member
variables, then call SaveData.
Doing this makes it possible for your class to be access and its business
logic to be used regardless of whether or not you show it (call DoModal).
"Kuenga" <sagku...@gmail.com> wrote in message
How do we do record and replay of modal dialog in a large code base ?
I have created a new dialog class, say CFooDialog derived from CDialog
and overridden OnInitDialog and OnOk. In OnOk, the control values are
dumped into a file and in OnInitDialog the values are read from the
file and controls populated.
In replay mode I donot want the dialog box to be shown. For that I
have overridden DoModal and done the following
CSagDumpDialogApp *pApp = (CSagDumpDialogApp *)AfxGetApp();
But In replay mode, the control are not getting initialised, since it
is done by DoModal function.
So I want the dialog controls to be initialised but the dialog box
should not be shown to user ? How to do that ?
Thanks- Hide quoted text -
- Show quoted text -
Thanks for your time. My goal is to record the user actions and then
replay the action carried out by him/her. If user has launched some
dialog thru menu command, during replay( for this created a CDialogBar
with EditControl where user can type in the command) I donot want the
dialog box to be shown but carry out the action which dialog box used
to do. I understand the correct way is to separate the data from the
dialog controls and during replay I just set the data members. But I
am working on large code base with many CDialog and CPropertySheet and
it is time consuming to refactory whole code to separate the data from
the dialog control.
So I decided to create a new CDialog class and derive all dialog
classes from this, so that the dumping of data present in the dialog
box is done automatically.
When logged action is replayed through command line(thru text command
entered in EditControl in CDialogBar), the dialog box should not be
shown. so came up with the above strategy.
I hope I have made the problem statement clear.
I have overcome the DoModal problem thru following code:
COrMDIApp *pApp = (COrMDIApp *)AfxGetApp();
LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
HINSTANCE hInst = AfxGetResourceHandle();
HGLOBAL hDialogTemplate = m_hDialogTemplate;
if (m_lpszTemplateName != NULL)
hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName,
hDialogTemplate = LoadResource(hInst, hResource);
if (hDialogTemplate != NULL)
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
// return -1 in case of failure to load the dialog template resource
if (lpDialogTemplate == NULL)
// destroy modal window
// unlock/free resources as necessary
if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
if (m_lpszTemplateName != NULL)
Donot know it is good or bad. Will really appreciate if someone comes
up with a better way...