Crossware

Table of Contents        Previous topic       Next topic       

Using the Custom AppWizard or Project Template->Tutorial - Creating an Extension with the AppWizard->Finalising Support for your Dialog Box->Supporting the Capture State Command

We will now add support for the Capture State and Restore State commands.

When the Capture State command is used, a new instance of CExtensionState is created.  This new instance requires a copy of the message and also needs to tell the dialog box that it is the currently active instance.

From within Microsoft Developer Studio add the following code (in bold) to ExtensionState.cpp:

CExtensionState::CExtensionState(CExtensionState* pState)
{
 m_nMachineCycles = pState->m_nMachineCycles;
 nExtensionCount++;
 g_pMessageDlg = pState->m_pMessageDlg;
 g_pMessageDlg->SetExtensionState(this);
}

When a captured state is restored, the instance of CExtensionState relevant to that state is also restored.  The dialog box needs to know that the active instance has changed.

Modify SetActiveState() in file ExtensionState.cpp adding the line in bold:

void CExtensionState::SetActiveState()
{
 // tell any dialogs that we have become the active CExtensionState
 g_pMessageDlg->SetExtensionState(this);
}