Merge branch '138-toggle-free-look-with-hotkey' into 'main/atys-live'
[ryzomcore.git] / nel / src / misc / dummy_window.cpp
blob60fe517952f994943180e3f0771e09154d0a4454
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "stdmisc.h"
19 #include "nel/misc/dummy_window.h"
22 #ifdef NL_OS_WINDOWS
24 #ifdef DEBUG_NEW
25 #define new DEBUG_NEW
26 #endif
28 namespace NLMISC
32 static LRESULT CALLBACK nlDefaultWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
34 return DefWindowProc(hwnd, uMsg, wParam, lParam);
38 // ***************************************************************
39 CDummyWindow::CDummyWindow() : _HWnd(NULL)
43 // ***************************************************************
44 bool CDummyWindow::init(HINSTANCE hInstance, WNDPROC winProc)
46 release();
47 static const char *INVISIBLE_WINDOW_CLASS = "nl_invisible_wnd_class";
48 WNDCLASSEXA wc;
49 wc.cbSize = sizeof(WNDCLASSEXA);
50 if (!GetClassInfoExA(hInstance, INVISIBLE_WINDOW_CLASS, &wc))
52 wc.cbSize = sizeof(WNDCLASSEXA);
53 wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
54 wc.lpfnWndProc = nlDefaultWinProc;
55 wc.cbClsExtra = 0;
56 wc.cbWndExtra = 0;
57 wc.hInstance = hInstance;
58 wc.hIcon = NULL;
59 wc.hCursor = NULL;
60 wc.hbrBackground = NULL;
61 wc.lpszMenuName = NULL;
62 wc.lpszClassName = INVISIBLE_WINDOW_CLASS;
63 wc.hIconSm = NULL;
64 RegisterClassExA(&wc);
66 _HWnd = CreateWindowA(INVISIBLE_WINDOW_CLASS, "", WS_POPUP,
67 CW_USEDEFAULT,CW_USEDEFAULT,
68 CW_USEDEFAULT,CW_USEDEFAULT,
69 NULL, 0,
70 hInstance, 0);
71 if (_HWnd)
73 if (winProc) SetWindowLongPtrA(_HWnd, GWLP_WNDPROC, (LONG_PTR) winProc);
74 return true;
76 return false;
79 // ***************************************************************
80 void CDummyWindow::release()
82 if (_HWnd)
84 DestroyWindow(_HWnd);
85 _HWnd = NULL;
89 // ***************************************************************
90 CDummyWindow::~CDummyWindow()
92 release();
95 } // NLMISC
97 #endif // NL_OS_WINDOWS