Crazy Eddie's GUI System  ${CEGUI_VERSION}
Win32AppHelper.h
1 /***********************************************************************
2  created: 17/10/2004
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _Win32AppHelper_h_
28 #define _Win32AppHelper_h_
29 
30 #if defined( __WIN32__ ) || defined( _WIN32 )
31 # define WIN32_LEAN_AND_MEAN
32 # include <windows.h>
33 
34 #include <dinput.h>
35 
36 // undefine Microsoft macro evilness
37 # undef min
38 # undef max
39 #endif
40 
41 #ifdef _MSC_VER
42 # pragma comment(lib, "dinput8.lib")
43 # pragma comment(lib, "dxguid.lib")
44 #endif
45 
47 
48 
54 {
55 public:
57  {
58  DirectInputState() : directInput(0), keyboardDevice(0)
59  {}
60 
61  LPDIRECTINPUT8 directInput;
62  LPDIRECTINPUTDEVICE8 keyboardDevice;
63  };
64 
65  static HWND createApplicationWindow(int width, int height);
66  static void mouseEnters(void);
67  static void mouseLeaves(void);
68  static bool initialiseDirectInput(HWND window, Win32AppHelper::DirectInputState& dis);
69  static void cleanupDirectInput(Win32AppHelper::DirectInputState& dis);
70  static void doDirectInputEvents(const Win32AppHelper::DirectInputState& dis);
71  static bool doWin32Events(bool& idle);
72  static LRESULT CALLBACK wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
73 
74  static void setSamplesFramework(SamplesFrameworkBase* samplesFramework);
75 
76  /*************************************************************************
77  Constants
78  *************************************************************************/
79  // name of the application, used for class and window creation
80  static const TCHAR APPLICATION_NAME[];
81 
82  // error strings displayed during initialisation
83  static const TCHAR REGISTER_CLASS_ERROR[];
84  static const TCHAR CREATE_WINDOW_ERROR[];
85 
86  // other error strings used
87  static const TCHAR CREATE_D3D_ERROR[];
88  static const TCHAR CREATE_DEVICE_ERROR[];
89 
90 private:
91  static bool s_mouseInWindow;
92 
93  static SamplesFrameworkBase* s_samplesFramework;
94 };
95 
96 #endif // end of guard _Win32AppHelper_h_
This is a base class that is intended to be used for all sample applications. Here we take care of co...
Definition: SamplesFrameworkBase.h:43
Definition: Win32AppHelper.h:56
All static utility class containing helper / common functions used for the Win32 apps.
Definition: Win32AppHelper.h:53