Visual studio 2005 thinks that long long int is 64 bit. The difference between
[dasher.git] / Src / Win32 / WinMain.cpp
blob20a6ed1414540e8f11d6ab5099b1d287f0fda6b2
1 // WinMain.cpp
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2002 Iain Murray
6 //
7 /////////////////////////////////////////////////////////////////////////////
9 #include "WinCommon.h"
11 // Visual leak detector
12 // #ifdef _DEBUG
13 // #include "vld/vld.h"
14 // #endif
16 #include "Common/WinHelper.h"
17 #include "DasherWindow.h"
19 #include <commctrl.h>
21 using namespace Dasher;
23 #ifndef _WIN32_WCE
24 // Windows Event handler
25 VOID CALLBACK WEProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime);
26 #endif
29 Entry point to program on Windows systems
31 An interface to the Dasher library is created.
32 A GUI and settings manager are created and given to the Dasher interface.
33 Control is passed to the main GUI loop, and only returns when the main window closes.
35 static CDasherWindow *g_pDasherWindow = NULL;
37 #ifndef _WIN32_WCE
38 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
39 #else
40 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) {
41 #endif
43 #ifndef _WIN32_WCE
44 CoInitialize(NULL);
45 #endif
47 WinHelper::hInstApp = hInstance;
49 //SHInitExtraControls();
51 // We don't want to starve other interactive applications
52 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
54 #ifndef _WIN32_WCE
55 HWINEVENTHOOK hHook;
57 hHook = SetWinEventHook(EVENT_OBJECT_FOCUS, EVENT_OBJECT_FOCUS, NULL, WEProc,
58 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
59 #endif
61 int iRet = 0;
63 g_pDasherWindow = new CDasherWindow;
65 g_pDasherWindow->Create();
66 g_pDasherWindow->Show(nCmdShow);
67 g_pDasherWindow->UpdateWindow();
69 iRet = g_pDasherWindow->MessageLoop();
71 delete g_pDasherWindow;
72 g_pDasherWindow = NULL;
74 #ifndef _WIN32_WCE
75 if(hHook)
76 UnhookWinEvent(hHook);
77 #endif
79 #ifndef _WIN32_WCE
80 // Close the COM library on the current thread
81 CoUninitialize();
82 #endif
84 return iRet;
87 #ifndef _WIN32_WCE
88 VOID CALLBACK WEProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime) {
89 if(g_pDasherWindow)
90 g_pDasherWindow->HandleWinEvent(hWinEventHook, event, hwnd, idObject, idChild, dwEventThread, dwmsEventTime);
92 #endif