This is a migrated thread and some comments may be shown as answers.

RadForm maximize to fullscreen issue

20 Answers 1020 Views
Form
This is a migrated thread and some comments may be shown as answers.
Xander
Top achievements
Rank 1
Xander asked on 28 Apr 2011, 01:50 PM

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

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 29 Apr 2011, 03:06 PM
Hello Xander,

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
0
Xander
Top achievements
Rank 1
answered on 29 Apr 2011, 07:17 PM
Hi, thanks for answer.
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 29 Apr 2011, 10:02 PM
Hello again 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

 
0
Xander
Top achievements
Rank 1
answered on 02 May 2011, 08:29 AM
Hello Emanuel,
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 02 May 2011, 10:18 AM
Hello 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
0
Xander
Top achievements
Rank 1
answered on 02 May 2011, 11:16 AM
Hi Emanuel,
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 02 May 2011, 02:14 PM
Hello again,

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
0
Xander
Top achievements
Rank 1
answered on 03 May 2011, 11:45 AM
Well, this is not real solution. And sure, I can use standard form, but why to buy your components, when I then need to use stanadr form and can use theming and all your advanced features.

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.
0
Emanuel Varga
Top achievements
Rank 1
answered on 03 May 2011, 11:59 AM
Hello again,

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
0
Xander
Top achievements
Rank 1
answered on 03 May 2011, 12:19 PM
Hello Emanuel,
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 03 May 2011, 12:25 PM
Hello again 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
0
Svett
Telerik team
answered on 03 May 2011, 02:54 PM
Hi Xander,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Xander
Top achievements
Rank 1
answered on 11 May 2011, 01:50 PM
Thanks for your response.
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;
}
}
0
Svett
Telerik team
answered on 12 May 2011, 09:37 AM
Hi Xander,

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.

Kind regards,
Svett
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Xander
Top achievements
Rank 1
answered on 12 May 2011, 12:13 PM
Hi Swett,
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
0
Xander
Top achievements
Rank 1
answered on 12 May 2011, 12:17 PM
Hi Emanuel,
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
0
Muthu
Top achievements
Rank 1
answered on 20 Jul 2013, 11:53 AM
Hi All,
       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?
0
Paul
Telerik team
answered on 25 Jul 2013, 06:03 AM
Hi Muthu,

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
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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 >>
0
Muthu
Top achievements
Rank 1
answered on 26 Jul 2013, 06:38 AM
Hi Paul,
          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
0
Paul
Telerik team
answered on 30 Jul 2013, 03:52 PM
Hello Muthu,

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
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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 >>
Tags
Form
Asked by
Xander
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Xander
Top achievements
Rank 1
Svett
Telerik team
Muthu
Top achievements
Rank 1
Paul
Telerik team
Share this question
or