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

Last change on this file since 937 was 122, checked in by roman, 12 years ago

Added bitmap static

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2008-2012
3// Created by Roman Ryltsov roman@alax.info
4//
5// $Id: AtlDialogSample.cpp 122 2012-09-10 21:03:55Z 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        MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
26        COMMAND_ID_HANDLER(IDCANCEL, OnCommand)
27        COMMAND_ID_HANDLER(IDOK, OnCommand)
28END_MSG_MAP()
29
30private:
31        CWindow m_PictureStatic;
32        HBITMAP m_hPictureBitmap;
33
34public:
35// CMainDialog
36
37// Window Message Handlers
38        LRESULT OnInitDialog(UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
39        {
40                m_PictureStatic = GetDlgItem(IDC_PICTURE);
41                m_hPictureBitmap = LoadBitmap(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDB_PICTURE));
42                ATLASSERT(m_hPictureBitmap);
43                m_PictureStatic.SendMessage(STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) m_hPictureBitmap);
44                ATLVERIFY(CenterWindow());
45                return 0;
46        }
47        LRESULT OnDestroy(UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
48        {
49                ATLVERIFY(DeleteObject(m_hPictureBitmap));
50                return 0;
51        }
52        LRESULT OnCommand(UINT, INT nIdentifier, HWND, BOOL& bHandled)
53        {
54                ATLVERIFY(EndDialog(nIdentifier));
55                return 0;
56        }
57};
58
59////////////////////////////////////////////////////////////
60// CAtlDialogSampleModule
61
62class CAtlDialogSampleModule : 
63        public CAtlExeModuleT<CAtlDialogSampleModule>
64{
65public:
66
67DECLARE_LIBID(LIBID_AtlDialogSampleLib)
68
69DECLARE_REGISTRY_APPID_RESOURCEID(IDR_ATLDIALOGSAMPLE, "{418A34EE-6628-4C68-B75F-71C52A156648}")
70
71public:
72// CAtlDialogSampleModule
73        HRESULT PreMessageLoop(INT nShowCommand)
74        {
75                _ATLTRY
76                {
77                        ATLENSURE_SUCCEEDED(__super::PreMessageLoop(nShowCommand));
78                }
79                _ATLCATCH(Exception)
80                {
81                        return Exception;
82                }
83                return S_OK;
84        }
85        VOID RunMessageLoop()
86        {
87                CMainDialog Dialog;
88                Dialog.DoModal();
89        }
90};
91
92CAtlDialogSampleModule _AtlModule;
93
94////////////////////////////////////////////////////////////
95// Main
96
97extern "C" int WINAPI _tWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpCmdLine*/, int nShowCmd)
98{
99        return _AtlModule.WinMain(nShowCmd);
100}
101
Note: See TracBrowser for help on using the repository browser.