Table of Contents Previous topic Next topic
Using the Custom AppWizard or Project Template->Tutorial - Creating an Extension with the AppWizard->Adding a Dialog Box to your Extension->Opening the Dialog Box
We will add the code that opens the dialog box to CExtensionState::CExtensionState() so that your dialog box will open automatically whenever your extension runs.
Open source file ExtensionState.cpp and add the two lines in bold:
#include "ExtensionState.h".
#include "resource.h"
#include "MessageDlg.h"
Add the following line in bold:
static int nExtensionCount; // = 0
class CMessageDlg* g_pMessageDlg; // = NULL
Modify CExtensionState::CExtensionState() adding the line in bold:
CExtensionState::CExtensionState()
{
ResetState();
nExtensionCount++;
g_pMessageDlg = new CMessageDlg;
}
Modify CExtensionState::~CExtensionState() adding the two lines in bold:
CExtensionState::~CExtensionState()
{
nExtensionCount--;
if (nExtensionCount == 0)
{
// close all dialogs when no CExtensionState instances left
if (g_pMessageDlg)
g_pMessageDlg->DestroyWindow();
}
}