GcResizeのKeepAspectRatioプロパティがTrueの場合、フルスクリーン表示をしてもフォームがスクリーンの中央位置に表示されない
対象製品
PlusPak for Windows Forms 7.0J
状況
修正済み
詳細
フォームのStartPositionプロパティにCenterScreenが設定されていても、以下の条件をすべて満たす場合には、フォームはスクリーンの左上に接した状態で表示されます。
・GcResize.FullScreenModeプロパティにFullScreenまたはFullScreenWithTaskBarが設定されている。
・GcResize.KeepAspectRatioプロパティにTrueが設定されている。
・GcResize.FullScreenModeプロパティにFullScreenまたはFullScreenWithTaskBarが設定されている。
・GcResize.KeepAspectRatioプロパティにTrueが設定されている。
回避方法
この問題はService Pack 3(v7.0.2016.0428)で修正されました。
不具合を修正した最新のサービスパックは、アップデートページ からダウンロードできます。
Service Pack 3より前のバージョンでは次の方法で回避可能です。
下記のようにフルスクリーンモードの代替コードを実装します。
1. FullScreenModeプロパティをNoneに設定する。
2. フォームのコンストラクタもしくはLoadイベントに次のコードを追加する。
[Visual Basic]
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Dim area As Rectangle = Screen.FromControl(Me).WorkingArea
Dim midPoint As New Point((area.Left + area.Right) / 2, (area.Top + area.Bottom) / 2)
Dim controlRatio As Double = CDbl(Me.Width) / CDbl(Me.Height)
Dim areaRatio As Double = CDbl(area.Width) / CDbl(area.Height)
Dim x As Integer
Dim y As Integer
Dim width As Integer
Dim height As Integer
If controlRatio < areaRatio Then
height = area.Height
width = (area.Height * Me.Width) / Me.Height
x = (area.Width - width) ¥ 2
y = 0
Else
width = area.Width
height = (area.Width / Me.Width) * Me.Height
x = 0
y = (area.Height - height) ¥ 2
End If
Me.SetBounds(x, y, width, height)
[C#]
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Rectangle area = Screen.FromControl(this).WorkingArea;
Point midPoint = new Point((area.Left + area.Right) / 2, (area.Top + area.Bottom) / 2);
double controlRatio = (double)this.Width / (double)this.Height;
double areaRatio = (double)area.Width / (double)area.Height;
int x;
int y;
int width;
int height;
if (controlRatio < areaRatio)
{
height = area.Height;
width = (area.Height * this.Width) / this.Height;
x = (area.Width - width) / 2;
y = 0;
}
else
{
width = area.Width;
height = (area.Width / this.Width) * this.Height;
x = 0;
y = (area.Height - height) / 2;
}
this.SetBounds(x, y, width, height);
不具合を修正した最新のサービスパックは、アップデートページ からダウンロードできます。
Service Pack 3より前のバージョンでは次の方法で回避可能です。
下記のようにフルスクリーンモードの代替コードを実装します。
1. FullScreenModeプロパティをNoneに設定する。
2. フォームのコンストラクタもしくはLoadイベントに次のコードを追加する。
[Visual Basic]
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Dim area As Rectangle = Screen.FromControl(Me).WorkingArea
Dim midPoint As New Point((area.Left + area.Right) / 2, (area.Top + area.Bottom) / 2)
Dim controlRatio As Double = CDbl(Me.Width) / CDbl(Me.Height)
Dim areaRatio As Double = CDbl(area.Width) / CDbl(area.Height)
Dim x As Integer
Dim y As Integer
Dim width As Integer
Dim height As Integer
If controlRatio < areaRatio Then
height = area.Height
width = (area.Height * Me.Width) / Me.Height
x = (area.Width - width) ¥ 2
y = 0
Else
width = area.Width
height = (area.Width / Me.Width) * Me.Height
x = 0
y = (area.Height - height) ¥ 2
End If
Me.SetBounds(x, y, width, height)
[C#]
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Rectangle area = Screen.FromControl(this).WorkingArea;
Point midPoint = new Point((area.Left + area.Right) / 2, (area.Top + area.Bottom) / 2);
double controlRatio = (double)this.Width / (double)this.Height;
double areaRatio = (double)area.Width / (double)area.Height;
int x;
int y;
int width;
int height;
if (controlRatio < areaRatio)
{
height = area.Height;
width = (area.Height * this.Width) / this.Height;
x = (area.Width - width) / 2;
y = 0;
}
else
{
width = area.Width;
height = (area.Width / this.Width) * this.Height;
x = 0;
y = (area.Height - height) / 2;
}
this.SetBounds(x, y, width, height);
キーワード
PPWI10716