- PR -

【C#】Formのデスクトップ右下表示について

1
投稿者投稿内容
Makoto
大ベテラン
会議室デビュー日: 2004/03/31
投稿数: 133
投稿日時: 2005-05-09 16:43
いつもお世話になっております。

C#の処理で教えてください。

Formの表示位置をデスクトップ右下に表示したいのですが、
どのように実施したらよいでしょうか?
下記のような方法でデスクトップ座標指定で表示できるのはわかるのですが、
現在のPCの画面サイズを取得する方法がわかりません。
  
  //MSDNより抜粋
  Rectangle tempRect = new Rectangle(50,50,100,100);
  this.DesktopBounds = tempRect;

PCの画面サイズを取得できれば、
『PCの画面サイズ』から『APの画面幅と画面高さ』
を引くことで『APの左上の位置』を決定できると思うのですが...

ご存知の方、いらっしゃいましたらよろしくお願いいたします。
Makoto
大ベテラン
会議室デビュー日: 2004/03/31
投稿数: 133
投稿日時: 2005-05-09 17:09
自己レスです。
下記でできました。
ただ、まずいことにタスクバー上にFormがかぶってしまいます...
何か処理が間違っているのでしょうか?
(MSDNには、タスクバーを除くって書いてあるんですが...)

ご存知の方いらっしゃいましたら、お願い致します。

//参考:http://homepage3.nifty.com/midori_no_bike/CS/
// 『スクリーンのサイズを取得 』

//表示位置を右下固定にする設定を判断する!
int ScreenWidth = Screen.PrimaryScreen.Bounds.Width;
int Screenheigth = Screen.PrimaryScreen.Bounds.Height;
int AppWidth = this.Width;
int AppHeight = this.Height;

int AppLeftXPos = ScreenWidth - AppWidth;
int AppLeftYPos = Screenheigth - AppHeight;

Rectangle tempRect = new Rectangle(AppLeftXPos,AppLeftYPos,AppWidth,AppHeight);
this.DesktopBounds = tempRect;

//↓でも同様。
//this.SetBounds(AppLeftXPos,AppLeftYPos,AppWidth,AppHeight);
//this.SetDesktopBounds(AppLeftXPos,AppLeftYPos,AppWidth,AppHeight);
Makoto
大ベテラン
会議室デビュー日: 2004/03/31
投稿数: 133
投稿日時: 2005-05-09 17:12
度々、自己レスです。
下記のように変更したところ、解決しました。

int ScreenWidth = Screen.PrimaryScreen.Bounds.Width;
int Screenheigth = Screen.PrimaryScreen.Bounds.Height;
 ↓
int ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width;
int Screenheigth = Screen.PrimaryScreen.WorkingArea.Height;
にしざき
ぬし
会議室デビュー日: 2003/06/30
投稿数: 304
投稿日時: 2005-05-09 17:13
試していませんが、
PrimaryScreen.Bounds のかわりに PrimaryScreen.WorkingArea
を使用したらどうでしょうか。

と書いていたら、ご自身でも見つけたようですね。

[ メッセージ編集済み 編集者: にしざき 編集日時 2005-05-09 17:14 ]
1

スキルアップ/キャリアアップ(JOB@IT)