source: trunk/Utilities/AtlDialogSample/AtlDialogSample.cpp @ 71

Last change on this file since 71 was 71, checked in by roman, 12 years ago
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2008-2012
3// Created by Roman Ryltsov roman@alax.info
4//
5// $Id: AtlDialogSample.cpp 71 2012-06-25 18:18:53Z roman $
6
7#include "stdafx.h"
8#include "resource.h"
9#include <atlwin.h>
10#include "AtlDialogSample_i.h"
11
12using namespace ATL;
13
14////////////////////////////////////////////////////////////
15// CMainDialog
16
17class CMainDialog :
18        public CDialogImpl<CMainDialog>
19{
20public:
21        enum { IDD = IDD_MAIN };
22
23BEGIN_MSG_MAP(CMainDialog)
24        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
25        COMMAND_ID_HANDLER(IDCANCEL, OnCommand)
26        COMMAND_ID_HANDLER(IDOK, OnCommand)
27END_MSG_MAP()
28
29public:
30// CMainDialog
31
32// Window Message Handlers
33        LRESULT OnInitDialog(UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
34        {
35                ATLVERIFY(CenterWindow());
36                return 0;
37        }
38        LRESULT OnCommand(UINT, INT nIdentifier, HWND, BOOL& bHandled)
39        {
40                ATLVERIFY(EndDialog(nIdentifier));
41                return 0;
42        }
43};
44
45////////////////////////////////////////////////////////////
46// CAtlDialogSampleModule
47
48class CAtlDialogSampleModule : 
49        public CAtlExeModuleT<CAtlDialogSampleModule>
50{
51public:
52
53DECLARE_LIBID(LIBID_AtlDialogSampleLib)
54
55DECLARE_REGISTRY_APPID_RESOURCEID(IDR_ATLDIALOGSAMPLE, "{418A34EE-6628-4C68-B75F-71C52A156648}")
56
57public:
58// CAtlDialogSampleModule
59        HRESULT PreMessageLoop(INT nShowCommand)
60        {
61                _ATLTRY
62                {
63                        ATLENSURE_SUCCEEDED(__super::PreMessageLoop(nShowCommand));
64                }
65                _ATLCATCH(Exception)
66                {
67                        return Exception;
68                }
69                return S_OK;
70        }
71        VOID RunMessageLoop()
72        {
73                CMainDialog Dialog;
74                Dialog.DoModal();
75        }
76};
77
78CAtlDialogSampleModule _AtlModule;
79
80////////////////////////////////////////////////////////////
81// Main
82
83extern "C" int WINAPI _tWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpCmdLine*/, int nShowCmd)
84{
85        return _AtlModule.WinMain(nShowCmd);
86}
87
Note: See TracBrowser for help on using the repository browser.