or
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
;
}
}
}
Object r is List<CultureInfo>
DataTable dtLangs =
new
DataTable();
dtLangs.Columns.AddRange(
new
DataColumn[] {
new
DataColumn(
"ID"
),
new
DataColumn(
"Name"
)} );
AppSetting.Instance.Languages.Select( r => dtLangs.Rows.Add(r.TwoLetterISOLanguageName, r.DisplayName));
this
.ddlLanguage.DataSource = dtLangs;
this
.ddlLanguage.DisplayMember =
"Name"
;
this
.ddlLanguage.ValueMember =
"ID"
;
Dim
serveursource
As
String
=
"SRV-13-1;SRV-59-2"
Dim
f
As
Integer
Dim
words
As
String
() = serveursource.Split(
New
Char
() {
";"
c})
Dim
strRowFilter
As
String
Dim
filter
As
New
FilterDescriptor()
filter.PropertyName =
"Dest_Serveur"
filter.[Operator] = FilterOperator.IsEqualTo
filter.IsFilterEditor =
True
RadGridView1.EnableFiltering =
True
' Use For Each loop over words and display them
Dim
word
As
String
For
Each
word
In
words
If
word <>
""
Then
filter.Value = word
Me
.RadGridView1.FilterDescriptors.Add(filter)
f = 0
For
Each
rowInfo
As
GridViewRowInfo
In
RadGridView1.Rows
f += 1
Next
MsgBox(word &
"Nb of rows:"
&
Me
.RadGridView1.Rows.Count.ToString &
">>"
& f.ToString)
End
If
Next
DataTable tblSrc =
new
DataTable();
tblSrc.Columns.Add(
"Title"
);
tblSrc.Columns.Add(
"Time"
);
tblSrc.Columns.Add(
"PrimaryArtist"
);
tblSrc.Columns.Add(
"Album"
);
tblSrc.Columns.Add(
"PrimaryGenre"
);
tblSrc.Columns.Add(
"Rating"
);
tblSrc.Columns.Add(
"Status"
);
DataRow dr;
for
(
int
i = 0; i < 5; i++)
{
dr = tblSrc.NewRow();
dr[
"Title"
] =
"asd"
;
dr[
"Time"
] =
"asd"
;
dr[
"PrimaryArtist"
] =
"Add To PlayList"
;
dr[
"Album"
] =
"asd"
;
dr[
"PrimaryGenre"
] =
"asd"
;
dr[
"Rating"
] =
"asd"
;
dr[
"Status"
] =
"asd"
;
tblSrc.Rows.Add(dr);
}
//DataSet ds = APS.GetAllPodcastsByPublisherId(73);
this
.Gv_SongList.DataSource = tblSrc;
this
.FormElement.TitleBar.Visibility = ElementVisibility.Collapsed;