// [!output DIALOG_IMPL] : implementation file // #include "stdafx.h" #include "[!output APP_HEADER]" #include "[!output DIALOG_HEADER]" [!if AUTOMATION] #include "[!output DIALOG_AUTO_PROXY_HEADER]" [!endif] #ifdef _DEBUG #define new DEBUG_NEW #endif [!if ABOUT_BOX] // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { [!if ACCESSIBILITY] EnableActiveAccessibility(); [!endif] } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() [!endif] // [!output DIALOG_CLASS] dialog [!if HTML_DIALOG] BEGIN_DHTML_EVENT_MAP([!output DIALOG_CLASS]) DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK) DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel) [!if CONTEXT_HELP] DHTML_EVENT_ONCLICK(_T("ButtonHelp"), OnButtonHelp) [!endif] END_DHTML_EVENT_MAP() [!endif] [!if AUTOMATION] IMPLEMENT_DYNAMIC([!output DIALOG_CLASS], [!output DIALOG_BASE_CLASS]); [!endif] [!output DIALOG_CLASS]::[!output DIALOG_CLASS](CWnd* pParent /*=NULL*/) [!if HTML_DIALOG] : CDHtmlDialog([!output DIALOG_CLASS]::IDD, [!output DIALOG_CLASS]::IDH, pParent) [!else] : [!output DIALOG_BASE_CLASS]([!output DIALOG_CLASS]::IDD, pParent) [!endif] { [!if ACCESSIBILITY] EnableActiveAccessibility(); [!endif] m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); [!if AUTOMATION] m_pAutoProxy = NULL; [!endif] } [!if AUTOMATION] [!output DIALOG_CLASS]::~[!output DIALOG_CLASS]() { // If there is an automation proxy for this dialog, set // its back pointer to this dialog to NULL, so it knows // the dialog has been deleted. if (m_pAutoProxy != NULL) m_pAutoProxy->m_pDialog = NULL; } [!endif] void [!output DIALOG_CLASS]::DoDataExchange(CDataExchange* pDX) { [!output DIALOG_BASE_CLASS]::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP([!output DIALOG_CLASS], [!output DIALOG_BASE_CLASS]) [!if ABOUT_BOX] ON_WM_SYSCOMMAND() [!endif] [!if CONTEXT_HELP && HELPSTYLE_WINHELP] ON_WM_DESTROY() [!endif] [!if AUTOMATION] ON_WM_CLOSE() [!endif] [!if !HTML_DIALOG] ON_WM_PAINT() ON_WM_QUERYDRAGICON() [!endif] //}}AFX_MSG_MAP END_MESSAGE_MAP() // [!output DIALOG_CLASS] message handlers BOOL [!output DIALOG_CLASS]::OnInitDialog() { [!output DIALOG_BASE_CLASS]::OnInitDialog(); [!if ABOUT_BOX] // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. _ASSERTE((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); _ASSERTE(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } [!endif] // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon [!if MAIN_FRAME_MAXIMIZED] ShowWindow(SW_MAXIMIZE); [!endif] [!if MAIN_FRAME_MINIMIZED] ShowWindow(SW_MINIMIZE); [!endif] // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } [!if ABOUT_BOX] void [!output DIALOG_CLASS]::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { [!output DIALOG_BASE_CLASS]::OnSysCommand(nID, lParam); } } [!endif] [!if CONTEXT_HELP && HELPSTYLE_WINHELP] void [!output DIALOG_CLASS]::OnDestroy() { WinHelp(0L, HELP_QUIT); [!output DIALOG_BASE_CLASS]::OnDestroy(); } [!endif] // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void [!output DIALOG_CLASS]::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { [!output DIALOG_BASE_CLASS]::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR [!output DIALOG_CLASS]::OnQueryDragIcon() { return static_cast(m_hIcon); } [!if AUTOMATION] // Automation servers should not exit when a user closes the UI // if a controller still holds on to one of its objects. These // message handlers make sure that if the proxy is still in use, // then the UI is hidden but the dialog remains around if it // is dismissed. void [!output DIALOG_CLASS]::OnClose() { if (CanExit()) [!output DIALOG_BASE_CLASS]::OnClose(); } void [!output DIALOG_CLASS]::OnOK() { if (CanExit()) [!output DIALOG_BASE_CLASS]::OnOK(); } void [!output DIALOG_CLASS]::OnCancel() { if (CanExit()) [!output DIALOG_BASE_CLASS]::OnCancel(); } BOOL [!output DIALOG_CLASS]::CanExit() { // If the proxy object is still around, then the automation // controller is still holding on to this application. Leave // the dialog around, but hide its UI. if (m_pAutoProxy != NULL) { ShowWindow(SW_HIDE); return FALSE; } return TRUE; } [!endif] [!if HTML_DIALOG] HRESULT [!output DIALOG_CLASS]::OnButtonOK(IHTMLElement* /*pElement*/) { OnOK(); return S_OK; } HRESULT [!output DIALOG_CLASS]::OnButtonCancel(IHTMLElement* /*pElement*/) { OnCancel(); return S_OK; } [!if CONTEXT_HELP] HRESULT [!output DIALOG_CLASS]::OnButtonHelp(IHTMLElement* /*pElement*/) { OnHelp(); return S_OK; } [!endif] [!endif]