How to reproduce:
1. Maximize a RadForm on a remote desktop machine using 2016.2.608 version
2. Maximize a RadForm on a Windows 7 machine with a disabled Aero using 2016.2.608 version
3. Maximize a RadForm on a Windows Server 2003 R2 using 2016.2.608 version
4. Maximize a RadForm on a Windows Server 2008 R2 using 2016.2.608 version
Workaround:
public partial class RadForm1 : RadForm
{
public RadForm1()
{
InitializeComponent();
}
//Workaround
protected override Telerik.WinControls.RootRadElement CreateRootElement()
{
return new MyFormRootElement(this);
}
}
public class MyFormRootElement : FormRootElement
{
private RadForm formControl;
public MyFormRootElement(RadForm radForm1) : base(radForm1)
{
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(RootRadElement);
}
}
protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
{
this.formControl = this.GetType().BaseType.GetField("formControl", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this) as RadForm;
if (e.Property == RadElement.BoundsProperty)
{
if ((this.Shape != null) && (this.formControl != null) &&
this.ApplyShapeToControl)
{
Rectangle oldBounds = (Rectangle)e.OldValue;
Rectangle newBounds = (Rectangle)e.NewValue;
if (oldBounds.Size != newBounds.Size)
{
CreateRegionFromShape(newBounds.Size);
}
}
}
else if ((e.Property == ShapeProperty) && this.ApplyShapeToControl)
{
ElementShape shape = e.NewValue as ElementShape;
if ((shape != null) && (this.ElementTree != null))
{
CreateRegionFromShape(this.Size);
}
}
else if (e.Property == ApplyShapeToControlProperty)
{
if ((bool)e.NewValue && this.Shape != null)
{
CreateRegionFromShape(this.Size);
}
else
{
this.ElementTree.Control.Region = null;
}
}
else
{
base.OnPropertyChanged(e);
}
}
private void CreateRegionFromShape(Size regionSize)
{
Region newRegion = null;
this.formControl = this.GetType().BaseType.GetField("formControl", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this) as RadForm;
if (this.formControl.WindowState != FormWindowState.Maximized || this.formControl.MaximumSize != Size.Empty)
{
Rectangle boundsRect = new Rectangle(Point.Empty, regionSize);
using (GraphicsPath path = this.Shape.CreatePath(boundsRect))
{
newRegion = new Region(path);
}
}
else if (!(IsWindows7 && !DWMAPIHelper.IsCompositionEnabled))
{
int borderLenght = DWMAPIHelper.IsCompositionEnabled ? SystemInformation.FixedFrameBorderSize.Height :
SystemInformation.FrameBorderSize.Height;
borderLenght += borderLenght;
if (!IsWindows8OrHigher)
{
borderLenght += 2;
}
else
{
borderLenght += 1;
}
Rectangle boundsRect = new Rectangle(new Point(borderLenght, borderLenght),
new Size(regionSize.Width - (borderLenght * 2), regionSize.Height - (borderLenght * 2)));
using (GraphicsPath path = new GraphicsPath())
{
path.AddRectangle(boundsRect);
newRegion = new Region(path);
}
}
Region region = this.formControl.Region;
if (!AreEqualRegions(region, newRegion))
{
this.formControl.Region = newRegion;
}
}
private bool IsWindows8OrHigher
{
get
{
OperatingSystem os = Environment.OSVersion;
return os.Platform == PlatformID.Win32NT &&
(os.Version.Major > 6 || (os.Version.Major == 6 && os.Version.Minor >= 2));
}
}
private bool IsWindows7
{
get
{
OperatingSystem os = Environment.OSVersion;
return os.Platform == PlatformID.Win32NT &&
((os.Version.Major == 6 && os.Version.Minor == 1) || os.Version.Major < 6);
}
}
private static bool AreEqualRegions(Region regionX, Region regionY)
{
if (regionX == null && regionY == null)
{
return true;
}
if (regionX == null || regionY == null)
{
return false;
}
byte[] regionDataX = regionX.GetRegionData().Data;
byte[] regionDataY = regionY.GetRegionData().Data;
int length = regionDataX.Length;
if (length != regionDataY.Length)
{
return false;
}
for (int i = 0; i < length; i++)
{
if (regionDataX[i] != regionDataY[i])
{
return false;
}
}
return true;
}
}
internal class DWMAPIHelper
{
[DllImport("dwmapi.dll")]
public static extern void DwmIsCompositionEnabled(ref bool isEnabled);
public static bool IsVista
{
get
{
return Environment.OSVersion.Version.Major >= 6;
}
}
public static bool IsCompositionEnabled
{
get
{
if (!IsVista)
{
return false;
}
bool enabled = false;
DwmIsCompositionEnabled(ref enabled);
return enabled;
}
}
}
}
To reproduce:
Create a RadForm and use the following code:
public Form1()
{
InitializeComponent();
var theme = new Telerik.WinControls.Themes.Windows7Theme();
ThemeResolutionService.ApplicationThemeName = theme.ThemeName;// "Windows7";
this.AllowTheming = false;
}
Start the application on Windows 7, you will see that the close/minimize/maximize buttons cannot be clicked.
Workaround:
Do not set the AllowTheming property or set it to true
How to reproduce:
public partial class Form1 : Form
{
Timer timer;
public Form1()
{
InitializeComponent();
timer = new Timer();
timer.Interval = 1000;
timer.Tick += new EventHandler(MyTimer_Tick);
timer.Start();
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
RadMessageBox.Show("Shown");
}
private void MyTimer_Tick(object sender, EventArgs e)
{
RadMessageBox.Show("Form closed");
this.Close();
}
}
Workaround: dispose the old instance
private void MyTimer_Tick(object sender, EventArgs e)
{
RadMessageBox.Instance.Dispose();
RadMessageBox.Show("Form closed");
this.Close();
}
Please refer to the attached sample project. Workaround: call the Close method in the Shown event.
Steps to reproduce:
1. Create Telerik WinForms Application and add two RadForm
2. Select one of forms and set the IsMdiContainer property to true
3. Select the child form. Open the Properties window and set the following properties at design time:
- WindowState to Maximized
- ThemeName to Windows8 or any other theme
4. Run the application and show the child form. The child form is cut off instead maximized.
Workaround:
1. Reset the WindowState property at design time
2. Subscribe to the Form`s Load event and set the WindowState property
private void RadForm2_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
}
To reproduce:
private void radButton1_Click(object sender, EventArgs e)
{
StringBuilder detailsText = new StringBuilder();
for (int i = 0; i < 10; i++)
{
detailsText.AppendLine("Line" + i);
}
detailsText.AppendLine("END");
RadMessageBox.Show("Message", "Caption Text", MessageBoxButtons.AbortRetryIgnore, detailsText.ToString());
}
Workaround: enlarge the details section in order to fit the text:
FieldInfo fi = typeof(RadMessageBoxForm).GetField("detailsSectionHeight", BindingFlags.NonPublic| BindingFlags.Instance);
fi.SetValue(RadMessageBox.Instance,200);
To reproduce:
1. Open a RadForm
2. Maximize the form.
3. Restore the form. Then we can see odd line on the bottom of title bar / top of the form. If you resize the form (make it bigger), new visible areas of form doesn't contain this weird line.
Workaround:
protected override void WndProc(ref Message m)
{
FormWindowState currentWindowState = this.WindowState;
base.WndProc(ref m);
if (currentWindowState == FormWindowState.Maximized && this.WindowState== FormWindowState.Normal)
{
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
}
}
Please refer to the attached project. Workaround: maximize the form in the Load event.
To reproduce:
- Create new project.
- Make the default form to inherit RadForm.
- Start the application and maximize the form.
- You will notice that a few pixels are displayed on the right monitor as well.
Workaround:
var screen = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
this.MaximumSize = new Size(screen.Width, screen.Height);
Second Workaround:
public Form1()
{
InitializeComponent();
this.SizeChanged += Form1_SizeChanged;
}
private void Form1_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
{
this.Region = null;
}
}
For the time being to show the grid I would recommend you to use an empty RadStatusStrip.
To reproduce:
Create a RadForm set Maxmize/Minimize box to false. Run it and try to drag the form by clicking on where the buttons used to be.
Workaround:
void MainForm_Load(object sender, EventArgs e)
{
this.FormElement.TitleBar.MaximizeButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
this.FormElement.TitleBar.MinimizeButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
}
Please refer to the attached screenshot. Workaround: use a RadForm without RadRibbonFormBehavior and hide the FormElement.TitleBar.
To reproduce:
public Form1()
{
InitializeComponent();
RadMessageBox.Instance.AutoSize = true;
}
private void radButton1_Click(object sender, EventArgs e)
{
string msg = string.Format("Test", (sender as RadButton).Name);
RadMessageBox.Show(msg, "Error");
}
Note that the size of RadMessageBox is adjusted automatically to display the whole content. Hence, it is not necessary to set the RadMessageBox.Instance.AutoSize property to true.
To reproduce: -Set RTL via the insane: RadMessageBox.Instance.RightToLeft = RightToLeft.Yes; - You will notice that layout is not changed when the messagebox is shown. Worlaround: - Use the RadMessageBox show method with the following parameters: RadMessageBox.Show(this, "test", "caption", MessageBoxButtons.OKCancel, icon, MessageBoxDefaultButton.Button1, RightToLeft.Yes);
RadMessageBox - has incorrect layouts when the message text is formatted with HTML like.
Workaround:
RadMessageBox.Show("Text");
RadMessageBox.Instance.Dispose();
If you are using themes, consider the following approach:
RadMessageBox.SetThemeName("Windows7");
RadMessageBox.Show("This is some long text that sometimes does not wrap as it should.");
var field = typeof(RadMessageBox).GetField("radMessageBoxForm", BindingFlags.NonPublic | BindingFlags.Static);
field.SetValue(null, null);
To reproduce:
public Form1()
{
InitializeComponent();
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
}
Although the user is not allowed to resize the form from the form's borders, it is possible to do it by the context menu.
Workaround:
[DllImport("user32.dll")]
static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable);
internal const UInt32 MF_DISABLED = 0x00000002;
internal const UInt32 SC_SIZE = 0xF000;
internal const UInt32 WM_INITMENUPOPUP = 0x0117;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_INITMENUPOPUP && (((int)m.LParam & 0x10000) != 0))
{
EnableMenuItem(m.WParam, SC_SIZE, MF_DISABLED);
}
base.WndProc(ref m);
}
To reproduce:
Use the following method to add a form with a textbox to a panel:
Private Sub AddPage(ByRef f As Form)
Try
pnlScreenContainer.SuspendUpdate()
f.TopLevel = False
f.Visible = False
f.Dock = DockStyle.Fill
pnlScreenContainer.Controls.Add(f)
f.Visible = True
f.BringToFront()
f.FormBorderStyle = Windows.Forms.FormBorderStyle.None
f.Show()
f.Activate()
Catch
End Try
pnlScreenContainer.ResumeUpdate()
End Sub
Workaround:
- Use RadTextBoxControl instead.
To reproduce: add a RadForm and start the application.
Workaround:
public partial class Form1 : RadForm
{
public Form1()
{
InitializeComponent();
}
protected override void OnLoad(Size desiredSize)
{
this.ElementTree.InitializeRootElement();
this.RootElement.ApplyShapeToControl = false;
base.OnLoad(desiredSize);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.RootElement.ApplyShapeToControl = true;
}
}
To reproduce: - Add RadMenu to a panel which is docked to the top. - Add an MDI child and maximize it. - You will notice that there is one more set of form buttons visible. Workaround: - Leave the menu outside of the panel.
To reproduce:
- Set the MaximizedBounds property so the form takes the entire right part of the screen, the change the windows state at runtime:
private void radButton1_Click(object sender, EventArgs e)
{
setFormMaximizedBounds(200);
}
private void radButton2_Click(object sender, EventArgs e)
{
setFormMaximizedBounds(-1);
}
private void setFormMaximizedBounds(int distance)
{
if (distance >= 0)
{
var ownerScreen = Screen.FromControl(this);
var workingArea = ownerScreen.WorkingArea;
var x = workingArea.X + distance;
var y = workingArea.Y;
var w = workingArea.Width - distance;
var h = workingArea.Height;
this.MaximizedBounds = new Rectangle(x, y, w, h);
}
else
{
this.MaximizedBounds = new Rectangle(0, 0, 0, 0);
}
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
this.WindowState = FormWindowState.Maximized;
}
}