Hi,
I'm trying to implement F11 feature - full screen in my application.
It works like a charm for standard .NET Form, but for RadForm I have some inaccuracy.
Win7 x64 - on the top of the screen I see part of title bar which should be normally hidden by calling "targetForm.FormBorderStyle = FormBorderStyle.None;".
WinXP - on the top I still can see like 2px space from title bar, but more important is that it doesn't cover Windows taskbar in the bottom of the screen.
The Code is simple:
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls;
using
Telerik.WinControls.UI;
namespace
RadControlsWinFormsApp1
{
public
partial
class
RadForm1 : RadForm
{
public
FormState fs =
new
FormState();
public
RadForm1()
{
InitializeComponent();
}
private
void
radButton1_Click(
object
sender, EventArgs e)
{
fs.Maximize(
this
);
}
private
void
radButton2_Click(
object
sender, EventArgs e)
{
fs.Restore(
this
);
}
}
/// <summary>
/// Selected Win AI Function Calls
/// </summary>
public
class
WinApi
{
[System.Runtime.InteropServices.DllImport(
"user32.dll"
, EntryPoint =
"GetSystemMetrics"
)]
public
static
extern
int
GetSystemMetrics(
int
which);
[System.Runtime.InteropServices.DllImport(
"user32.dll"
)]
public
static
extern
void
SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter,
int
X,
int
Y,
int
width,
int
height,
uint
flags);
public
static
void
SetWinFullScreen(IntPtr hwnd)
{
SetWindowPos(hwnd, IntPtr.Zero, 0, 0, GetSystemMetrics(0), GetSystemMetrics(1), 64);
}
}
/// <summary>
/// Class used to preserve / restore state of the form
/// </summary>
public
class
FormState
{
private
FormWindowState winState;
private
FormBorderStyle brdStyle;
private
bool
topMost;
private
Rectangle bounds;
public
bool
IsMaximized =
false
;
public
void
Maximize(RadForm targetForm)
{
if
(!IsMaximized)
{
IsMaximized =
true
;
Save(targetForm);
targetForm.WindowState = FormWindowState.Maximized;
targetForm.FormBorderStyle = FormBorderStyle.None;
targetForm.TopMost =
true
;
WinApi.SetWinFullScreen(targetForm.Handle);
}
}
public
void
Save(RadForm targetForm)
{
winState = targetForm.WindowState;
brdStyle = targetForm.FormBorderStyle;
topMost = targetForm.TopMost;
bounds = targetForm.Bounds;
}
public
void
Restore(RadForm targetForm)
{
targetForm.WindowState = winState;
targetForm.FormBorderStyle = brdStyle;
targetForm.TopMost = topMost;
targetForm.Bounds = bounds;
IsMaximized =
false
;
}
}
}
When you replace RadForm by Form everything is all right on both OS :-(
Any idea, any help?
Thanks Zbyněk
20 Answers, 1 is accepted
I would advise against this behavior for a couple of reasons. First one, you haven't considered the location of the windows taskbar, what if the taskbar is on top? what if its to the left or right? what if it's on autohide?
The user won't be able to access the taskbar anymore.
Second issue i see here, why would you want to hide the minimize maximize & close buttons? Have you seen any applications lately that hide these buttons on maximized?
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
I can't agree with you. Have you ever tried to press F11 in Internet Explorer. That's functionality I wan't to achieve.
My application will run on PC and will display content on big TV screen, there is no intention to have task bar visible.
There is quite enough application which has similar functionality (Photoshop, ...).
It is not for the whole runtime, but it's a possibility for user to switch it on by hotkey for some action and when he is done switch it by another simple keystroke back to normal window.
And as you can see stanard win Form support it very good, in RadForm some optimization is needed. I use version 2011 without SP - 2011.1.315.0.
Thanks Xander
Ok, i totally agree if this is that kind of app, in my tests you just have to reverse 2 lines, set the border to none before setting the maximized state, like so:
public
void
Maximize(RadForm targetForm)
{
if
(!IsMaximized)
{
IsMaximized =
true
;
Save(targetForm);
targetForm.FormBorderStyle = FormBorderStyle.None;
targetForm.WindowState = FormWindowState.Maximized;
targetForm.TopMost =
true
;
WinApi.SetWinFullScreen(targetForm.Handle);
}
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
thanks for your hint.
From my observations and tests this only help to not see part of title bar, but the gap (5px high) is still on top of my screen (filled by black in my case, but you can find out that cursor is visible).
On WinXP is the same: gap on top of screen and taskbar - both still visible.
Thanks, Xander
Please try the following:
public
static
void
SetWinFullScreen(IntPtr hwnd)
{
SetWindowPos(hwnd, IntPtr.Zero, 0, -9, GetSystemMetrics(0), GetSystemMetrics(1), 64);
}
I believe that somehow 0 is not the TopMost point anymore... strange, maybe it's something related to winapi?
Anyway like this it should be ok.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
this would only shift the whole form up, which will fix the issue with gap on the top, but the bottom of screen will show the same gap only down. With standard form it behaves good, no issues on W7 even on WinXP.
Xander
Yes, but you can just increase the height with the same amount you decreased the location...
public
static
void
SetWinFullScreen(IntPtr hwnd)
{
SetWindowPos(hwnd, IntPtr.Zero, 0, -9, GetSystemMetrics(0), GetSystemMetrics(1)+9, 64);
}
Honestly I did not need to play with this before, but if you plan on using your application maximized and don't like these kind of workarounds why don't you just use a normal form as a container?
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
All that are just workarounds which cause on WinXP that taskbar is visible :-(
On Win7 it is a bit better, but anyway, there is some bug in RadForm causing trouble in setting windows position and boundaries via Windows API.
Why isn't this a solution? I'm not really sure what kind of solution can telerik offer when you are using WinAPI to present your form.
But coming back to the question at hand: Does this solve your problem or not?
Does the solution i've suggested cause problems on windows xp?
I'm just trying to help you achieve a satisfactory solution for this problem. In my point of view it's better to have a fully working workaround now rather than a clean workaround > 3months when the next version will probably come out.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
I agree that workaround now is better, but I was missing information that you want to fix it in next release.
I have tried all you suggested - moving window to top and add some pixels to height of the window.
This works good on Win7 (you can even add more pixels and Win7 will handle it so form will nto overflow the screen, but on WinXP which is main OS used in our company it casues that taskbar is fully visible.
Enhancement is then better than original code because taskbar on WinXP is fully visible, nto partially as before, but at the end it will not lead to universal solution to have full screen independent on OS.
I have tried also to hide taskbar via Windows API, to resolve this, but no way.
I'll try now find exact value for which it will work on WinXP, if they are exists, and I'll let you know.
I'm out of office for next 6 days, so I'll come back to you later.
Xander
First of, sorry but i don't work for telerik so i cannot confirm or infirm what they have planed to fix in future releases :(, i'm just trying to help as much as i can without being able to change the source code itself.
I will try to get my hands on a win xp computer and I hope to find good solution for windows xp.
Best Regards,
Emanuel Varga
Telerik WinForms MVP
I am enclosing a sample project that demonstrates how you can achieve the RadForm full screen feature. Notice that you need Visual Studio 2010 to see the project.
Regards,Svett
the Telerik team
The solution fixed the issue on Win7 with the top margin, but on WinXP it still not cover the bottom where task bar sits.
I have tried to set also padding.Bottom = 0, but no success.
public
override
System.Windows.Forms.Padding ClientMargin
{
get
{
Padding padding =
base
.ClientMargin;
if
(
this
.IsFullScreen)
{
padding.Top = 0;
padding.Bottom = 0;
}
return
padding;
}
}
I managed to reproduce the issue under Windows XP. I am not able to give you a work around due to complexity of the issue. We will address it in one of the next major releases. I have added it to our Public Issue Tracking System.
Your Telerik points have been updated for the report.
Svett
the Telerik team
hmm, quite pitty. It will take long time and my subscription exceed before it could be solved.
Anyway, thanks for your answer, I have to figure it out on my own.
Xander
I didn't know you are not Telerik employee, sorry for that.
On WinXP I'm able only to manage fullscreen with full taskbar visible. The bad thing is that taskbar is useless because the rest of screen is covered by my form,s o whatever action you perform on taskbar it is not visible.
Have to investigate more on my own or dismiss RadForm, because from Telerik there is no help till "one of next major releases" :-(
Xander
I have a MDI form and a Child form inside that. I am opening the child form in maximized mode. Properties are,
form1.windowsize = maximized.
Topmost = false
FormBorderStyle = sizable.
I found a gap on the top between MDI menu and Child form Title bar and later, I made,
form1.windowsize = maximized.
Topmost = true
FormBorderStyle = None.
But still it is not working fine. But a funny thing i,s it works fine in some systems and not in other systems. We are using same size of monitor and windows 7. How can I overcome this?
Thank you for writing.
I tried to reproduce your scenario but without success. Would you give more details on what systems you get the issue, so we can troubleshoot it? Could you also send me a sample project showing the behavior?
I have attached an image of what I got on my machine.
Regards,
Paul
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
tnx for reply.
Actually I have solved it.
I have one more thing, When I open two child forms in maximized mode, I am getting following errors,
"object reference not set to an instance of the object"
"Error Creating window handle"
Ex. I have a MDI, I open a child form 'form1' in maximized mode. This is success. When 'form1' remains open, I open one more form 'form2' in maximized mode. Here I am getting two errors
This problem will not come when I open in normal size. I have attached the snap as well. We are using version 2011.3.11.1116
Thank you for writing back.
I am sorry but I was not able to reproduce the issue you are reporting.
Could you send me a sample project so I can investigate it and supply solution?
Look forward to receiving a project.
Regards,
Paul
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>