|
|
Home » Community » Newbie corner » FullScreen: why does not work?
FullScreen: why does not work? [message #28742] |
Tue, 14 September 2010 18:02 |
281264
Messages: 270 Registered: June 2010 Location: Spain
|
Experienced Member |
|
|
Please have a look to the attached example. While Maximize does work, FullScreen doesn’t. Why?
Cheers,
Javier
|
|
|
|
Re: FullScreen: why does not work? [message #30047 is a reply to message #28742] |
Sun, 05 December 2010 04:56 |
alendar
Messages: 47 Registered: January 2010 Location: Idaho, USA
|
Member |
|
|
I solved this with Win32 APIs. First I tried to use the U++ wrappers but I could not get them to work.
Here's the code:
bool isFullScreenModeActive;
virtual bool Key(dword key, int count) {
static dword style;
static Rect normalwindowrect;
switch (key) {
case K_F11:
if (!isFullScreenModeActive) {
// Get the current Top window's style bits
style = GetStyle();
// Strips the caption bit, which is the title bar
style = (style & ~WS_CAPTION);
// Save the "overlapped" or normal window shape
normalwindowrect = GetRect();
SetWindowLong(GetHWND(), GWL_STYLE, style);
// Get the full size of the screen
long cx = GetSystemMetrics(SM_CXSCREEN);
long cy = GetSystemMetrics(SM_CYSCREEN);
// Expand the window to full size
SetWindowPos(GetHWND(),HWND_TOP,0,0,cx,cy,SWP_SHOWWINDOW);
//or use Maximize(false) if you like a
//delayed resizing, even with zoom effects turned off
} else {
// Set the caption bit back so we can get our title bar back
style |= WS_CAPTION;
// Pass to windows (Style() method gets confused on SyncCaption0)
SetWindowLong(GetHWND(), GWL_STYLE, style);
// Return size to normal; key flag is SWP_FRAMECHANGED
SetWindowPos(GetHWND(),HWND_TOP,
normalwindowrect.left,
normalwindowrect.top,
normalwindowrect.Width(),
normalwindowrect.Height(), SWP_SHOWWINDOW|SWP_FRAMECHANGED);
}
// Track logically in our application
isFullScreenModeActive = !isFullScreenModeActive;
break;
}
return false;
}
This was on MS Windows XP Professional V 2002 SP 3
U++ 2791
This is a win32 only fix. This works on a TopWindow while your in it, so you don't have to use the constructor method.
I might try getting the virtual window size so I can zoom across multiple screens.
The trick to getting the title bar back after your zoom is the SWP_FRAMECHANGED flag. Without this Windoze doesn't know to rebuild the window frame after you added the WS_CAPTION bit back in.
You can use the TopWindow.Maximize() function, but for some reason it still tries to do effects when you pass a false bit, so I used the SetWindowPos instead for the zoom.
I haven't tried this with any windows besides a TopWindow.
This covers the taskbar on the bottom on my computer. Sometimes there is a delay in minimizing the taskbar.
Edit from 5 min later:
To go across all screens just change:
cx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
long cy = GetSystemMetrics(SM_CYSCREEN);
cy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
cd7651feeb698f6ac6cec1f6deda5e5b
[Updated on: Sun, 05 December 2010 05:03] Report message to a moderator
|
|
|
|
|
|
Toggle FullScreen on X11 [message #30297 is a reply to message #30055] |
Wed, 22 December 2010 12:54 |
oan1971
Messages: 7 Registered: April 2010
|
Promising Member |
|
|
Hello Koldo,
I am no X11 expert at all, but the following seems to work on Linux. I guess that the window manager needs to support "Extended Window Manager Hints" (see http://standards.freedesktop.org/wm-spec/wm-spec-latest.html #id2551694).
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class FullScreenTest : public TopWindow
{
public:
typedef FullScreenTest CLASSNAME;
FullScreenTest();
virtual bool Key(dword key, int count);
virtual void Paint(Draw& w);
void SetFullScreen(bool b);
};
FullScreenTest::FullScreenTest()
{
Title("FullScreenTest").Sizeable();
}
void FullScreenTest::Paint(Draw & w)
{
Rect r = GetView();
w.DrawRect(r, Blue);
}
bool FullScreenTest::Key(dword key, int count)
{
if (key == K_F11)
if (IsFullScreen())
SetFullScreen(false);
else
SetFullScreen(true);
}
void FullScreenTest::SetFullScreen(bool b)
{
Sizeable(!b);
FullScreen(b);
XEvent event;
event.xclient.type = ClientMessage;
event.xclient.serial = 0;
event.xclient.send_event = true;
event.xclient.message_type = XAtom("_NET_WM_STATE");
event.xclient.window = GetWindow();
event.xclient.format = 32;
event.xclient.data.l[0] = b;
event.xclient.data.l[1] = XAtom("_NET_WM_STATE_FULLSCREEN");
event.xclient.data.l[2] = 0;
event.xclient.data.l[3] = 0;
event.xclient.data.l[4] = 0;
XSendEvent(Xdisplay, Xroot, false, SubstructureRedirectMask | SubstructureNotifyMask, &event);
if (b)
SetRect(0, 0, Xwidth, Xheight);
}
GUI_APP_MAIN
{
FullScreenTest().Run();
}
Best regards,
Oliver
910eb20c14e026a87ffb2b0d38b9ddb7
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Thu Jun 13 05:10:20 CEST 2024
Total time taken to generate the page: 0.01843 seconds
|
|
|