28 #define _WIN32_WINDOWS 0x0501 29 #define _WIN32_WINNT 0x0501 30 #include <SFML/Window/Win32/WindowImplWin32.hpp> 31 #include <SFML/Window/WindowSettings.hpp> 32 #include <SFML/Window/WindowStyle.hpp> 34 #include <SFML/Window/glext/wglext.h> 35 #include <SFML/Window/glext/glext.h> 41 #define XBUTTON1 0x0001 44 #define XBUTTON2 0x0002 46 #ifndef MAPVK_VK_TO_VSC 47 #define MAPVK_VK_TO_VSC (0) 58 unsigned int WindowImplWin32::ourWindowCount = 0;
59 const char* WindowImplWin32::ourClassNameA =
"SFML_Window";
60 const wchar_t* WindowImplWin32::ourClassNameW = L
"SFML_Window";
61 WindowImplWin32* WindowImplWin32::ourFullscreenWindow = NULL;
68 WindowImplWin32::WindowImplWin32() :
73 myKeyRepeatEnabled(true),
77 if (ourWindowCount == 0)
78 RegisterWindowClass();
85 if (HasUnicodeSupport())
87 myHandle = CreateWindowW(ourClassNameW, L
"", WS_POPUP | WS_DISABLED, 0, 0, myWidth, myHeight, NULL, NULL, GetModuleHandle(NULL), NULL);
91 myHandle = CreateWindowA(ourClassNameA,
"", WS_POPUP | WS_DISABLED, 0, 0, myWidth, myHeight, NULL, NULL, GetModuleHandle(NULL), NULL);
93 ShowWindow(myHandle, SW_HIDE);
98 WindowSettings Params(0, 0, 0);
99 CreateContext(VideoMode(myWidth, myHeight, 32), Params);
110 WindowImplWin32::WindowImplWin32(WindowHandle Handle, WindowSettings& Params) :
115 myKeyRepeatEnabled(true),
119 myHandle =
static_cast<HWND
>(Handle);
125 GetClientRect(myHandle, &Rect);
126 myWidth = Rect.right - Rect.left;
127 myHeight = Rect.bottom - Rect.top;
131 CreateContext(Mode, Params);
134 SetWindowLongPtr(myHandle, GWLP_USERDATA, reinterpret_cast<long>(
this));
135 myCallback = SetWindowLongPtr(myHandle, GWLP_WNDPROC, reinterpret_cast<long>(&WindowImplWin32::GlobalOnEvent));
143 WindowImplWin32::WindowImplWin32(VideoMode Mode,
const std::string& Title,
unsigned long WindowStyle, WindowSettings& Params) :
148 myKeyRepeatEnabled(true),
152 if (ourWindowCount == 0)
153 RegisterWindowClass();
156 HDC ScreenDC = GetDC(NULL);
157 int Left = (GetDeviceCaps(ScreenDC, HORZRES) - Mode.Width) / 2;
158 int Top = (GetDeviceCaps(ScreenDC, VERTRES) - Mode.Height) / 2;
159 int Width = myWidth = Mode.Width;
160 int Height = myHeight = Mode.Height;
161 ReleaseDC(NULL, ScreenDC);
164 DWORD Win32Style = WS_VISIBLE;
167 Win32Style |= WS_POPUP;
171 if (WindowStyle &
Style::Titlebar) Win32Style |= WS_CAPTION | WS_MINIMIZEBOX;
172 if (WindowStyle &
Style::Resize) Win32Style |= WS_THICKFRAME | WS_MAXIMIZEBOX;
173 if (WindowStyle &
Style::Close) Win32Style |= WS_SYSMENU;
180 RECT Rect = {0, 0, Width, Height};
181 AdjustWindowRect(&Rect, Win32Style,
false);
182 Width = Rect.right - Rect.left;
183 Height = Rect.bottom - Rect.top;
187 if (HasUnicodeSupport())
190 int NbChars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, Title.c_str(),
static_cast<int>(Title.size()), WTitle,
sizeof(WTitle) /
sizeof(*WTitle));
191 WTitle[NbChars] = L
'\0';
192 myHandle = CreateWindowW(ourClassNameW, WTitle, Win32Style, Left, Top, Width, Height, NULL, NULL, GetModuleHandle(NULL),
this);
196 myHandle = CreateWindowA(ourClassNameA, Title.c_str(), Win32Style, Left, Top, Width, Height, NULL, NULL, GetModuleHandle(NULL),
this);
201 SwitchToFullscreen(Mode);
205 CreateContext(Mode, Params);
213 GetClientRect(myHandle, &ActualRect);
214 myWidth = ActualRect.right - ActualRect.left;
215 myHeight = ActualRect.bottom - ActualRect.top;
222 WindowImplWin32::~WindowImplWin32()
232 DestroyWindow(myHandle);
238 if (ourWindowCount == 0)
240 if (HasUnicodeSupport())
242 UnregisterClassW(ourClassNameW, GetModuleHandle(NULL));
246 UnregisterClassA(ourClassNameA, GetModuleHandle(NULL));
253 SetWindowLongPtr(myHandle, GWLP_WNDPROC, myCallback);
261 bool WindowImplWin32::IsContextActive()
263 return wglGetCurrentContext() != NULL;
270 void WindowImplWin32::ProcessEvents()
276 while (PeekMessage(&Message, NULL, 0, 0, PM_REMOVE))
278 TranslateMessage(&Message);
279 DispatchMessage(&Message);
288 void WindowImplWin32::Display()
290 if (myDeviceContext && myGLContext)
291 SwapBuffers(myDeviceContext);
298 void WindowImplWin32::SetActive(
bool Active)
const 302 if (myDeviceContext && myGLContext && (wglGetCurrentContext() != myGLContext))
303 wglMakeCurrent(myDeviceContext, myGLContext);
307 if (wglGetCurrentContext() == myGLContext)
308 wglMakeCurrent(NULL, NULL);
316 void WindowImplWin32::UseVerticalSync(
bool Enabled)
318 PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT =
reinterpret_cast<PFNWGLSWAPINTERVALEXTPROC
>(wglGetProcAddress(
"wglSwapIntervalEXT"));
319 if (wglSwapIntervalEXT)
320 wglSwapIntervalEXT(Enabled ? 1 : 0);
327 void WindowImplWin32::ShowMouseCursor(
bool Show)
330 myCursor = LoadCursor(NULL, IDC_ARROW);
341 void WindowImplWin32::SetCursorPosition(
unsigned int Left,
unsigned int Top)
343 POINT Pos = {Left, Top};
344 ClientToScreen(myHandle, &Pos);
345 SetCursorPos(Pos.x, Pos.y);
352 void WindowImplWin32::SetPosition(
int Left,
int Top)
354 SetWindowPos(myHandle, NULL, Left, Top, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
361 void WindowImplWin32::SetSize(
unsigned int Width,
unsigned int Height)
365 RECT Rect = {0, 0, Width, Height};
366 AdjustWindowRect(&Rect, GetWindowLong(myHandle, GWL_STYLE),
false);
367 Width = Rect.right - Rect.left;
368 Height = Rect.bottom - Rect.top;
370 SetWindowPos(myHandle, NULL, 0, 0, Width, Height, SWP_NOMOVE | SWP_NOZORDER);
377 void WindowImplWin32::Show(
bool State)
379 ShowWindow(myHandle, State ? SW_SHOW : SW_HIDE);
386 void WindowImplWin32::EnableKeyRepeat(
bool Enabled)
388 myKeyRepeatEnabled = Enabled;
395 void WindowImplWin32::SetIcon(
unsigned int Width,
unsigned int Height,
const Uint8* Pixels)
402 std::vector<Uint8> IconPixels(Width * Height * 4);
403 for (std::size_t i = 0; i < IconPixels.size() / 4; ++i)
405 IconPixels[i * 4 + 0] = Pixels[i * 4 + 2];
406 IconPixels[i * 4 + 1] = Pixels[i * 4 + 1];
407 IconPixels[i * 4 + 2] = Pixels[i * 4 + 0];
408 IconPixels[i * 4 + 3] = Pixels[i * 4 + 3];
412 myIcon = CreateIcon(GetModuleHandle(NULL), Width, Height, 1, 32, NULL, &IconPixels[0]);
417 SendMessage(myHandle, WM_SETICON, ICON_BIG, (LPARAM)myIcon);
418 SendMessage(myHandle, WM_SETICON, ICON_SMALL, (LPARAM)myIcon);
422 std::cerr <<
"Failed to set the window's icon" << std::endl;
430 void WindowImplWin32::RegisterWindowClass()
432 if (HasUnicodeSupport())
434 WNDCLASSW WindowClass;
435 WindowClass.style = 0;
436 WindowClass.lpfnWndProc = &WindowImplWin32::GlobalOnEvent;
437 WindowClass.cbClsExtra = 0;
438 WindowClass.cbWndExtra = 0;
439 WindowClass.hInstance = GetModuleHandle(NULL);
440 WindowClass.hIcon = NULL;
441 WindowClass.hCursor = 0;
442 WindowClass.hbrBackground = 0;
443 WindowClass.lpszMenuName = NULL;
444 WindowClass.lpszClassName = ourClassNameW;
445 RegisterClassW(&WindowClass);
449 WNDCLASSA WindowClass;
450 WindowClass.style = 0;
451 WindowClass.lpfnWndProc = &WindowImplWin32::GlobalOnEvent;
452 WindowClass.cbClsExtra = 0;
453 WindowClass.cbWndExtra = 0;
454 WindowClass.hInstance = GetModuleHandle(NULL);
455 WindowClass.hIcon = NULL;
456 WindowClass.hCursor = 0;
457 WindowClass.hbrBackground = 0;
458 WindowClass.lpszMenuName = NULL;
459 WindowClass.lpszClassName = ourClassNameA;
460 RegisterClassA(&WindowClass);
468 void WindowImplWin32::SwitchToFullscreen(
const VideoMode& Mode)
471 DevMode.dmSize =
sizeof(DEVMODE);
472 DevMode.dmPelsWidth = Mode.Width;
473 DevMode.dmPelsHeight = Mode.Height;
474 DevMode.dmBitsPerPel = Mode.BitsPerPixel;
475 DevMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
478 if (ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
480 std::cerr <<
"Failed to change display mode for fullscreen" << std::endl;
485 SetWindowLong(myHandle, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
486 SetWindowLong(myHandle, GWL_EXSTYLE, WS_EX_APPWINDOW);
489 SetWindowPos(myHandle, HWND_TOP, 0, 0, Mode.Width, Mode.Height, SWP_FRAMECHANGED);
490 ShowWindow(myHandle, SW_SHOW);
493 ourFullscreenWindow =
this;
500 void WindowImplWin32::CreateContext(
const VideoMode& Mode, WindowSettings& Params)
503 myDeviceContext = GetDC(myHandle);
504 if (myDeviceContext == NULL)
506 std::cerr <<
"Failed to get device context of window -- cannot create OpenGL context" << std::endl;
512 if (Params.AntialiasingLevel > 0)
515 PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB =
reinterpret_cast<PFNWGLCHOOSEPIXELFORMATARBPROC
>(wglGetProcAddress(
"wglChoosePixelFormatARB"));
516 if (wglChoosePixelFormatARB)
519 int IntAttributes[] =
521 WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
522 WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
523 WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
524 WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
525 WGL_SAMPLE_BUFFERS_ARB, (Params.AntialiasingLevel ? GL_TRUE : GL_FALSE),
526 WGL_SAMPLES_ARB, Params.AntialiasingLevel,
533 float FloatAttributes[] = {0, 0};
534 bool IsValid = wglChoosePixelFormatARB(myDeviceContext, IntAttributes, FloatAttributes,
sizeof(Formats) /
sizeof(*Formats), Formats, &NbFormats) != 0;
535 if (!IsValid || (NbFormats == 0))
537 if (Params.AntialiasingLevel > 2)
540 std::cerr <<
"Failed to find a pixel format supporting " 541 << Params.AntialiasingLevel <<
" antialiasing levels ; trying with 2 levels" << std::endl;
543 Params.AntialiasingLevel = IntAttributes[11] = 2;
544 IsValid = wglChoosePixelFormatARB(myDeviceContext, IntAttributes, FloatAttributes,
sizeof(Formats) /
sizeof(*Formats), Formats, &NbFormats) != 0;
547 if (!IsValid || (NbFormats == 0))
550 std::cerr <<
"Failed to find a pixel format supporting antialiasing ; antialiasing will be disabled" << std::endl;
551 Params.AntialiasingLevel = 0;
556 if (IsValid && (NbFormats > 0))
558 int BestScore = 0xFFFF;
559 for (UINT i = 0; i < NbFormats; ++i)
562 PIXELFORMATDESCRIPTOR Attribs;
563 Attribs.nSize =
sizeof(PIXELFORMATDESCRIPTOR);
564 Attribs.nVersion = 1;
565 DescribePixelFormat(myDeviceContext, Formats[i],
sizeof(PIXELFORMATDESCRIPTOR), &Attribs);
568 int Color = Attribs.cRedBits + Attribs.cGreenBits + Attribs.cBlueBits + Attribs.cAlphaBits;
569 int Score = EvaluateConfig(Mode, Params, Color, Attribs.cDepthBits, Attribs.cStencilBits, Params.AntialiasingLevel);
572 if (Score < BestScore)
575 BestFormat = Formats[i];
583 std::cerr <<
"Antialiasing is not supported ; it will be disabled" << std::endl;
584 Params.AntialiasingLevel = 0;
592 PIXELFORMATDESCRIPTOR PixelDescriptor;
593 ZeroMemory(&PixelDescriptor,
sizeof(PIXELFORMATDESCRIPTOR));
594 PixelDescriptor.nSize =
sizeof(PIXELFORMATDESCRIPTOR);
595 PixelDescriptor.nVersion = 1;
596 PixelDescriptor.iLayerType = PFD_MAIN_PLANE;
597 PixelDescriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
598 PixelDescriptor.iPixelType = PFD_TYPE_RGBA;
599 PixelDescriptor.cColorBits =
static_cast<BYTE
>(Mode.BitsPerPixel);
600 PixelDescriptor.cDepthBits =
static_cast<BYTE
>(Params.DepthBits);
601 PixelDescriptor.cStencilBits =
static_cast<BYTE
>(Params.StencilBits);
602 PixelDescriptor.cAlphaBits = Mode.BitsPerPixel == 32 ? 8 : 0;
605 BestFormat = ChoosePixelFormat(myDeviceContext, &PixelDescriptor);
608 std::cerr <<
"Failed to find a suitable pixel format for device context -- cannot create OpenGL context" << std::endl;
614 PIXELFORMATDESCRIPTOR ActualFormat;
615 ActualFormat.nSize =
sizeof(PIXELFORMATDESCRIPTOR);
616 ActualFormat.nVersion = 1;
617 DescribePixelFormat(myDeviceContext, BestFormat,
sizeof(PIXELFORMATDESCRIPTOR), &ActualFormat);
618 Params.DepthBits = ActualFormat.cDepthBits;
619 Params.StencilBits = ActualFormat.cStencilBits;
622 if (!SetPixelFormat(myDeviceContext, BestFormat, &ActualFormat))
624 std::cerr <<
"Failed to set pixel format for device context -- cannot create OpenGL context" << std::endl;
629 myGLContext = wglCreateContext(myDeviceContext);
630 if (myGLContext == NULL)
632 std::cerr <<
"Failed to create an OpenGL context for this window" << std::endl;
637 HGLRC CurrentContext = wglGetCurrentContext();
639 wglShareLists(CurrentContext, myGLContext);
645 if (Params.AntialiasingLevel > 0)
646 glEnable(GL_MULTISAMPLE_ARB);
653 void WindowImplWin32::Cleanup()
656 if (ourFullscreenWindow ==
this)
658 ChangeDisplaySettings(NULL, 0);
659 ourFullscreenWindow = NULL;
671 wglDeleteContext(myGLContext);
676 ReleaseDC(myHandle, myDeviceContext);
677 myDeviceContext = NULL;
685 void WindowImplWin32::ProcessEvent(UINT Message, WPARAM WParam, LPARAM LParam)
688 if (myHandle == NULL)
705 if (LOWORD(LParam) == HTCLIENT)
715 Evt.Type = Event::Closed;
725 GetClientRect(myHandle, &Rect);
726 myWidth = Rect.right - Rect.left;
727 myHeight = Rect.bottom - Rect.top;
730 Evt.Type = Event::Resized;
731 Evt.Size.Width = myWidth;
732 Evt.Size.Height = myHeight;
741 Evt.Type = Event::GainedFocus;
750 Evt.Type = Event::LostFocus;
758 if (myKeyRepeatEnabled || ((LParam & (1 << 30)) == 0))
761 Evt.Type = Event::TextEntered;
762 Evt.Text.Unicode =
static_cast<Uint32
>(WParam);
772 if (myKeyRepeatEnabled || ((HIWORD(LParam) & KF_REPEAT) == 0))
775 Evt.Type = Event::KeyPressed;
776 Evt.Key.Alt = HIWORD(GetAsyncKeyState(VK_MENU)) != 0;
777 Evt.Key.Control = HIWORD(GetAsyncKeyState(VK_CONTROL)) != 0;
778 Evt.Key.Shift = HIWORD(GetAsyncKeyState(VK_SHIFT)) != 0;
779 Evt.Key.Code = VirtualKeyCodeToSF(WParam, LParam);
790 Evt.Type = Event::KeyReleased;
791 Evt.Key.Alt = HIWORD(GetAsyncKeyState(VK_MENU)) != 0;
792 Evt.Key.Control = HIWORD(GetAsyncKeyState(VK_CONTROL)) != 0;
793 Evt.Key.Shift = HIWORD(GetAsyncKeyState(VK_SHIFT)) != 0;
794 Evt.Key.Code = VirtualKeyCodeToSF(WParam, LParam);
804 Evt.Type = Event::MouseWheelMoved;
805 Evt.MouseWheel.Delta =
static_cast<Int16
>(HIWORD(WParam)) / 120;
811 case WM_LBUTTONDOWN :
814 Evt.Type = Event::MouseButtonPressed;
815 Evt.MouseButton.Button = Mouse::Left;
816 Evt.MouseButton.X = LOWORD(LParam);
817 Evt.MouseButton.Y = HIWORD(LParam);
826 Evt.Type = Event::MouseButtonReleased;
827 Evt.MouseButton.Button = Mouse::Left;
828 Evt.MouseButton.X = LOWORD(LParam);
829 Evt.MouseButton.Y = HIWORD(LParam);
835 case WM_RBUTTONDOWN :
838 Evt.Type = Event::MouseButtonPressed;
839 Evt.MouseButton.Button = Mouse::Right;
840 Evt.MouseButton.X = LOWORD(LParam);
841 Evt.MouseButton.Y = HIWORD(LParam);
850 Evt.Type = Event::MouseButtonReleased;
851 Evt.MouseButton.Button = Mouse::Right;
852 Evt.MouseButton.X = LOWORD(LParam);
853 Evt.MouseButton.Y = HIWORD(LParam);
859 case WM_MBUTTONDOWN :
862 Evt.Type = Event::MouseButtonPressed;
863 Evt.MouseButton.Button = Mouse::Middle;
864 Evt.MouseButton.X = LOWORD(LParam);
865 Evt.MouseButton.Y = HIWORD(LParam);
874 Evt.Type = Event::MouseButtonReleased;
875 Evt.MouseButton.Button = Mouse::Middle;
876 Evt.MouseButton.X = LOWORD(LParam);
877 Evt.MouseButton.Y = HIWORD(LParam);
883 case WM_XBUTTONDOWN :
886 Evt.Type = Event::MouseButtonPressed;
887 Evt.MouseButton.Button = HIWORD(WParam) == XBUTTON1 ? Mouse::XButton1 : Mouse::XButton2;
888 Evt.MouseButton.X = LOWORD(LParam);
889 Evt.MouseButton.Y = HIWORD(LParam);
898 Evt.Type = Event::MouseButtonReleased;
899 Evt.MouseButton.Button = HIWORD(WParam) == XBUTTON1 ? Mouse::XButton1 : Mouse::XButton2;
900 Evt.MouseButton.X = LOWORD(LParam);
901 Evt.MouseButton.Y = HIWORD(LParam);
912 TRACKMOUSEEVENT MouseEvent;
913 MouseEvent.cbSize =
sizeof(TRACKMOUSEEVENT);
914 MouseEvent.hwndTrack = myHandle;
915 MouseEvent.dwFlags = TME_LEAVE;
916 TrackMouseEvent(&MouseEvent);
921 Evt.Type = Event::MouseEntered;
926 Evt.Type = Event::MouseMoved;
927 Evt.MouseMove.X = LOWORD(LParam);
928 Evt.MouseMove.Y = HIWORD(LParam);
936 myIsCursorIn =
false;
939 Evt.Type = Event::MouseLeft;
950 Key::Code WindowImplWin32::VirtualKeyCodeToSF(WPARAM VirtualKey, LPARAM Flags)
957 static UINT LShift = MapVirtualKey(VK_LSHIFT, MAPVK_VK_TO_VSC);
958 UINT scancode = (Flags & (0xFF << 16)) >> 16;
959 return scancode == LShift ? Key::LShift : Key::RShift;
963 case VK_MENU :
return (HIWORD(Flags) & KF_EXTENDED) ? Key::RAlt : Key::LAlt;
966 case VK_CONTROL :
return (HIWORD(Flags) & KF_EXTENDED) ? Key::RControl : Key::LControl;
971 case VK_APPS :
return Key::Menu;
981 case VK_OEM_5 :
return Key::BackSlash;
983 case VK_ESCAPE :
return Key::Escape;
984 case VK_SPACE :
return Key::Space;
985 case VK_RETURN :
return Key::Return;
986 case VK_BACK :
return Key::Back;
987 case VK_TAB :
return Key::Tab;
988 case VK_PRIOR :
return Key::PageUp;
989 case VK_NEXT :
return Key::PageDown;
990 case VK_END :
return Key::End;
991 case VK_HOME :
return Key::Home;
992 case VK_INSERT :
return Key::Insert;
993 case VK_DELETE :
return Key::Delete;
998 case VK_PAUSE :
return Key::Pause;
999 case VK_F1 :
return Key::F1;
1000 case VK_F2 :
return Key::F2;
1001 case VK_F3 :
return Key::F3;
1002 case VK_F4 :
return Key::F4;
1003 case VK_F5 :
return Key::F5;
1004 case VK_F6 :
return Key::F6;
1005 case VK_F7 :
return Key::F7;
1006 case VK_F8 :
return Key::F8;
1007 case VK_F9 :
return Key::F9;
1008 case VK_F10 :
return Key::F10;
1009 case VK_F11 :
return Key::F11;
1010 case VK_F12 :
return Key::F12;
1011 case VK_F13 :
return Key::F13;
1012 case VK_F14 :
return Key::F14;
1013 case VK_F15 :
return Key::F15;
1018 case VK_NUMPAD0 :
return Key::Numpad0;
1019 case VK_NUMPAD1 :
return Key::Numpad1;
1020 case VK_NUMPAD2 :
return Key::Numpad2;
1021 case VK_NUMPAD3 :
return Key::Numpad3;
1022 case VK_NUMPAD4 :
return Key::Numpad4;
1023 case VK_NUMPAD5 :
return Key::Numpad5;
1024 case VK_NUMPAD6 :
return Key::Numpad6;
1025 case VK_NUMPAD7 :
return Key::Numpad7;
1026 case VK_NUMPAD8 :
return Key::Numpad8;
1027 case VK_NUMPAD9 :
return Key::Numpad9;
1028 case 'A' :
return Key::A;
1029 case 'Z' :
return Key::Z;
1030 case 'E' :
return Key::E;
1031 case 'R' :
return Key::R;
1032 case 'T' :
return Key::T;
1033 case 'Y' :
return Key::Y;
1034 case 'U' :
return Key::U;
1035 case 'I' :
return Key::I;
1036 case 'O' :
return Key::O;
1037 case 'P' :
return Key::P;
1038 case 'Q' :
return Key::Q;
1039 case 'S' :
return Key::S;
1040 case 'D' :
return Key::D;
1041 case 'F' :
return Key::F;
1042 case 'G' :
return Key::G;
1043 case 'H' :
return Key::H;
1044 case 'J' :
return Key::J;
1045 case 'K' :
return Key::K;
1046 case 'L' :
return Key::L;
1047 case 'M' :
return Key::M;
1048 case 'W' :
return Key::W;
1049 case 'X' :
return Key::X;
1050 case 'C' :
return Key::C;
1051 case 'V' :
return Key::V;
1052 case 'B' :
return Key::B;
1053 case 'N' :
return Key::N;
1054 case '0' :
return Key::Num0;
1055 case '1' :
return Key::Num1;
1056 case '2' :
return Key::Num2;
1057 case '3' :
return Key::Num3;
1058 case '4' :
return Key::Num4;
1059 case '5' :
return Key::Num5;
1060 case '6' :
return Key::Num6;
1061 case '7' :
return Key::Num7;
1062 case '8' :
return Key::Num8;
1063 case '9' :
return Key::Num9;
1075 bool WindowImplWin32::HasUnicodeSupport()
1077 OSVERSIONINFO VersionInfo;
1078 ZeroMemory(&VersionInfo,
sizeof(VersionInfo));
1079 VersionInfo.dwOSVersionInfoSize =
sizeof(VersionInfo);
1081 if (GetVersionEx(&VersionInfo))
1083 return VersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT;
1095 LRESULT CALLBACK WindowImplWin32::GlobalOnEvent(HWND Handle, UINT Message, WPARAM WParam, LPARAM LParam)
1098 if (Message == WM_CREATE)
1101 long This =
reinterpret_cast<long>(
reinterpret_cast<CREATESTRUCT*
>(LParam)->lpCreateParams);
1104 SetWindowLongPtr(Handle, GWLP_USERDATA, This);
1108 WindowImplWin32*
Window =
reinterpret_cast<WindowImplWin32*
>(GetWindowLongPtr(Handle, GWLP_USERDATA));
1113 Window->ProcessEvent(Message, WParam, LParam);
1115 if (Window->myCallback)
1116 return CallWindowProc(reinterpret_cast<WNDPROC>(Window->myCallback), Handle, Message, WParam, LParam);
1120 if (Message == WM_CLOSE)
1123 static const bool HasUnicode = HasUnicodeSupport();
1124 return HasUnicode ? DefWindowProcW(Handle, Message, WParam, LParam) :
1125 DefWindowProcA(Handle, Message, WParam, LParam);
OS specific key (left side) : windows (Win and Linux), apple (MacOS), ...
Titlebar + resizable border + maximize button.
static VideoMode GetDesktopMode()
Get the current desktop video mode.
Title bar + fixed border.
Window()
Default constructor.
No border / title bar (this flag and all others are mutually exclusive)
Fullscreen mode (this flag and all others are mutually exclusive)
bool SetActive(bool Active=true) const
Activate of deactivate the window as the current target for rendering.
void Show(bool State)
Show or hide the window.
void ShowMouseCursor(bool Show)
Show or hide the mouse cursor.
OS specific key (right side) : windows (Win and Linux), apple (MacOS), ...