LIMA Factory
Top achievements
Rank 1
LIMA Factory
asked on 15 Jul 2016, 07:30 AM
Hello,
I encounter a strange behavior with my RadForm window:
When I maximize my Form, a boarder exists where the Form is not rendered and the background /application behind is visible and usable. See the attached screenshot.
If the form is not maximized everything is OK.
This issue occurred after updating from the previous version to the latest version, and this issue exists only on Computers that do not have Visual Studio Installed (standard users of the software). On the development machine the maximized state is OK too.
Do You have an idea how to solve this problem? Or do You have a workaround?
Thanks for your help!
Regards,
Ingo
2 Answers, 1 is accepted
0
Accepted
Hi Ingo,
Thank you for writing.
You have encountered a known issue which is already fixed in the development version of our controls. Here is the feedback item: FIX. RadForm - the form is clipped when maximized on Windows 7 with a disabled Aero.
Until we publicly release our next version you would need to use the following workaround:
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik by Progress
Thank you for writing.
You have encountered a known issue which is already fixed in the development version of our controls. Here is the feedback item: FIX. RadForm - the form is clipped when maximized on Windows 7 with a disabled Aero.
Until we publicly release our next version you would need to use the following 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(RadForm1 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);
}
}
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;
}
}
}
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
0
LIMA Factory
Top achievements
Rank 1
answered on 15 Jul 2016, 08:05 AM
Hello!
Thank You very much for Your quick answer and the workaround!
It works perfectly!
Regards,
Ingo