mirror of https://github.com/buggins/dlangui.git
support fullscreen window creation on Win32 - #393
This commit is contained in:
parent
2ab32a5ecf
commit
43ae1fd608
|
@ -268,11 +268,27 @@ class Win32Window : Window {
|
||||||
ws |= WS_OVERLAPPED | WS_CAPTION | WS_CAPTION | WS_BORDER | WS_SYSMENU;
|
ws |= WS_OVERLAPPED | WS_CAPTION | WS_CAPTION | WS_BORDER | WS_SYSMENU;
|
||||||
//if (flags & WindowFlag.Fullscreen)
|
//if (flags & WindowFlag.Fullscreen)
|
||||||
// ws |= SDL_WINDOW_FULLSCREEN;
|
// ws |= SDL_WINDOW_FULLSCREEN;
|
||||||
|
Rect screenRc = getScreenDimensions();
|
||||||
|
Log.d("Screen dimensions: ", screenRc);
|
||||||
|
|
||||||
|
int x = CW_USEDEFAULT;
|
||||||
|
int y = CW_USEDEFAULT;
|
||||||
|
|
||||||
|
if (flags & WindowFlag.Fullscreen) {
|
||||||
|
// fullscreen
|
||||||
|
x = screenRc.left;
|
||||||
|
y = screenRc.top;
|
||||||
|
_dx = screenRc.width;
|
||||||
|
_dy = screenRc.height;
|
||||||
|
ws = WS_POPUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_hwnd = CreateWindowW(toUTF16z(WIN_CLASS_NAME), // window class name
|
_hwnd = CreateWindowW(toUTF16z(WIN_CLASS_NAME), // window class name
|
||||||
toUTF16z(windowCaption), // window caption
|
toUTF16z(windowCaption), // window caption
|
||||||
ws, // window style
|
ws, // window style
|
||||||
CW_USEDEFAULT, // initial x position
|
x, // initial x position
|
||||||
CW_USEDEFAULT, // initial y position
|
y, // initial y position
|
||||||
_dx, // initial x size
|
_dx, // initial x size
|
||||||
_dy, // initial y size
|
_dy, // initial y size
|
||||||
parenthwnd, // parent window handle
|
parenthwnd, // parent window handle
|
||||||
|
@ -343,6 +359,25 @@ class Win32Window : Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Rect getScreenDimensions() {
|
||||||
|
MONITORINFO monitor_info;
|
||||||
|
monitor_info.cbSize = monitor_info.sizeof;
|
||||||
|
HMONITOR hMonitor;
|
||||||
|
if (_hwnd) {
|
||||||
|
hMonitor = MonitorFromWindow(_hwnd, MONITOR_DEFAULTTONEAREST);
|
||||||
|
} else {
|
||||||
|
hMonitor = MonitorFromPoint(POINT(0,0), MONITOR_DEFAULTTOPRIMARY);
|
||||||
|
}
|
||||||
|
GetMonitorInfo(hMonitor,
|
||||||
|
&monitor_info);
|
||||||
|
Rect res;
|
||||||
|
res.left = monitor_info.rcMonitor.left;
|
||||||
|
res.top = monitor_info.rcMonitor.top;
|
||||||
|
res.right = monitor_info.rcMonitor.right;
|
||||||
|
res.bottom = monitor_info.rcMonitor.bottom;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
~this() {
|
~this() {
|
||||||
debug Log.d("Window destructor");
|
debug Log.d("Window destructor");
|
||||||
if (_drawbuf) {
|
if (_drawbuf) {
|
||||||
|
@ -448,7 +483,14 @@ class Win32Window : Window {
|
||||||
|
|
||||||
adjustPositionDuringShow();
|
adjustPositionDuringShow();
|
||||||
|
|
||||||
ShowWindow(_hwnd, SW_SHOWNORMAL);
|
if (_flags & WindowFlag.Fullscreen) {
|
||||||
|
Rect rc = getScreenDimensions();
|
||||||
|
SetWindowPos(_hwnd, HWND_TOPMOST, 0, 0, rc.width, rc.height, SWP_SHOWWINDOW);
|
||||||
|
_windowState = WindowState.fullscreen;
|
||||||
|
} else {
|
||||||
|
ShowWindow(_hwnd, SW_SHOWNORMAL);
|
||||||
|
_windowState = WindowState.normal;
|
||||||
|
}
|
||||||
if (_mainWidget)
|
if (_mainWidget)
|
||||||
_mainWidget.setFocus();
|
_mainWidget.setFocus();
|
||||||
SetFocus(_hwnd);
|
SetFocus(_hwnd);
|
||||||
|
@ -490,6 +532,10 @@ class Win32Window : Window {
|
||||||
ShowWindow(_hwnd, SW_SHOWNORMAL);
|
ShowWindow(_hwnd, SW_SHOWNORMAL);
|
||||||
res = true;
|
res = true;
|
||||||
break;
|
break;
|
||||||
|
case WindowState.fullscreen:
|
||||||
|
ShowWindow(_hwnd, SW_SHOWNORMAL);
|
||||||
|
res = true;
|
||||||
|
break;
|
||||||
case WindowState.minimized:
|
case WindowState.minimized:
|
||||||
ShowWindow(_hwnd, SW_SHOWMINIMIZED);
|
ShowWindow(_hwnd, SW_SHOWMINIMIZED);
|
||||||
res = true;
|
res = true;
|
||||||
|
|
Loading…
Reference in New Issue