OSDN Git Service

add QPlayerEx.
[qtheora/main.git] / Tests / QPlayerEx / Main.cpp
1 // Main.cpp
2 // 2009/05/29
3
4 #include "StdAfx.h"
5
6 #include <crtdbg.h>
7
8 #include "TheoraDecoder.h"
9 #include "VorbisDecoder.h"
10
11 /* */
12
13 #include "MainDialog.h"
14
15 /* */
16
17 WTL::CAppModule _Module;
18
19 /* */
20
21 int DoProcess();
22
23 /* */
24
25 int WINAPI wWinMain(
26         HINSTANCE hInstance,
27         HINSTANCE /*hPrevInstance*/,
28         LPWSTR    /*lpCmdLine*/,
29         int       /*nCmdShow*/)
30 {
31         _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
32         // _CrtSetBreakAlloc(1);
33
34         HRESULT hRslt = OleInitialize(0);
35         if (FAILED(hRslt)) {
36                 return -1;
37         }
38
39         _Module.Init(0, hInstance);
40
41         int result = DoProcess();
42
43         _Module.Term();
44
45         OleUninitialize();
46
47         return result;
48 }
49
50 /* */
51
52 static bool DoInitialize();
53 static void DoUninitialize();
54 static int  DoMain();
55
56 int DoProcess()
57 {
58         int result = -1;
59
60         if (DoInitialize()) {
61                 result = DoMain();
62         }
63
64         DoUninitialize();
65
66         return result;
67 }
68
69 /* */
70
71 static bool DoInitialize()
72 {
73         if (!QT_Initialize()) {
74                 return false;
75         }
76
77         if (!QV_Initialize()) {
78                 return false;
79         }
80
81         return true;
82 }
83
84 static void DoUninitialize()
85 {
86 }
87
88 /* */
89
90 static int DoMain()
91 {
92         int result = -1;
93
94         WTL::CMessageLoop theLoop;
95         _Module.AddMessageLoop(&theLoop);
96
97         {
98                 MainDialog dlg;
99
100                 theLoop.AddMessageFilter(&dlg);
101
102                 HWND hwnd = dlg.Create(0);
103                 if (hwnd != 0) {
104                         dlg.ShowWindow(SW_NORMAL);
105                         dlg.UpdateWindow();
106
107                         result = theLoop.Run();
108                 }
109
110                 theLoop.RemoveMessageFilter(&dlg);
111         }
112
113         _Module.RemoveMessageLoop();
114
115         return result;
116 }
117
118 /* */
119