1 | //////////////////////////////////////////////////////////// |
---|
2 | // Copyright (C) Roman Ryltsov, 2008-2011 |
---|
3 | // Created by Roman Ryltsov roman@alax.info |
---|
4 | // |
---|
5 | // $Id: ShowHresult.cpp 92 2012-08-16 17:01:42Z roman $ |
---|
6 | |
---|
7 | #include "stdafx.h" |
---|
8 | #include "resource.h" |
---|
9 | #include "ShowHresult_i.h" |
---|
10 | #include "NotifyIconWindow.h" |
---|
11 | |
---|
12 | //////////////////////////////////////////////////////////// |
---|
13 | // CShowHresultModule |
---|
14 | |
---|
15 | class CShowHresultModule : |
---|
16 | public CAtlExeModuleT<CShowHresultModule>, |
---|
17 | public CWtlExeModuleT<CShowHresultModule> |
---|
18 | { |
---|
19 | public: |
---|
20 | |
---|
21 | //DECLARE_LIBID(LIBID_AlaxInfoShowHresult) |
---|
22 | |
---|
23 | //DECLARE_REGISTRY_APPID_RESOURCEID(IDR_MODULE, "{...}") |
---|
24 | |
---|
25 | public: |
---|
26 | // CShowHresultModule |
---|
27 | CShowHresultModule() throw() |
---|
28 | { |
---|
29 | AtlTraceSetDefaultSettings(); |
---|
30 | _W(CExceptionFilter::Initialize()); |
---|
31 | _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this); |
---|
32 | } |
---|
33 | ~CShowHresultModule() throw() |
---|
34 | { |
---|
35 | _Z4(atlTraceRefcount, 4, _T("this 0x%p\n"), this); |
---|
36 | CExceptionFilter::Terminate(); |
---|
37 | } |
---|
38 | HRESULT PreMessageLoop(INT nShowCommand) throw() |
---|
39 | { |
---|
40 | _ATLTRY |
---|
41 | { |
---|
42 | TraceModuleVersion(); |
---|
43 | __E(AtlInitCommonControls(ICC_WIN95_CLASSES | ICC_DATE_CLASSES | ICC_COOL_CLASSES)); |
---|
44 | //__C(CWtlExeModule::Initialize()); |
---|
45 | __C(__super::PreMessageLoop(nShowCommand)); |
---|
46 | } |
---|
47 | _ATLCATCH(Exception) |
---|
48 | { |
---|
49 | _C(Exception); |
---|
50 | } |
---|
51 | return S_OK; |
---|
52 | } |
---|
53 | VOID RunMessageLoop() throw() |
---|
54 | { |
---|
55 | Lock(); |
---|
56 | { |
---|
57 | CNotifyIconWindow Window; |
---|
58 | __E(Window.Create()); |
---|
59 | __super::RunMessageLoop(); |
---|
60 | if(Window.IsWindow()) |
---|
61 | _W(Window.DestroyWindow()); |
---|
62 | } |
---|
63 | if(GetLockCount() == 1) |
---|
64 | { |
---|
65 | m_dwTimeOut = 0L; |
---|
66 | m_dwPause = 0L; |
---|
67 | } |
---|
68 | Unlock(); |
---|
69 | } |
---|
70 | HRESULT PostMessageLoop() throw() |
---|
71 | { |
---|
72 | _ATLTRY |
---|
73 | { |
---|
74 | _V(__super::PostMessageLoop()); |
---|
75 | //CWtlExeModule::Terminate(); |
---|
76 | } |
---|
77 | _ATLCATCH(Exception) |
---|
78 | { |
---|
79 | _C(Exception); |
---|
80 | } |
---|
81 | return S_OK; |
---|
82 | } |
---|
83 | }; |
---|
84 | |
---|
85 | CShowHresultModule _AtlModule; |
---|
86 | |
---|
87 | //////////////////////////////////////////////////////////// |
---|
88 | // Main |
---|
89 | |
---|
90 | extern "C" int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, INT nShowCommand) |
---|
91 | { |
---|
92 | return _AtlModule.WinMain(nShowCommand); |
---|
93 | } |
---|
94 | |
---|