C WPF 中設定窗體顯示在其它窗體上的中間位置

2021-09-29 12:50:52 字數 1141 閱讀 3345

//首先在from1窗體介面載入完進行如下設定,使得from1窗體始終在其它窗體的最上面

this

.topmost =

true

;

//首先獲取當前窗體的左上角和右下角座標

point ptleftup =

newpoint(0

,0);

point ptrightdown =

newpoint

(this

.actualwidth,

this

.actualheight)

;//轉換獲取到這個視窗相對於螢幕兩個座標

ptleftup =

this

.pointtoscreen

(ptleftup)

; ptrightdown =

this

.pointtoscreen

(ptrightdown)

;獲取窗體在螢幕的實際寬高

widthman = ptrightdown.x - ptleftup.x;

heightman = ptrightdown.y - ptleftup.y;

this

.isenabled =

false

;//設定當前窗體不可操作

from1 settime =

newfrom1()

; windowstartuplocation = windowstartuplocation.manual;

widthman =

(this

.actualwidth)/2

+ ptleftup.x -

(settime.width)/2

; heightman =

(this

.actualheight)/2

+ ptleftup.y-

(settime.height)/2

;//設定窗體在當前窗體的最中間顯示

settime.left = widthman;

settime.top = heightman;

C 怎麼設定子窗體在主窗體中居中顯示

c 怎麼設定子窗體在主窗體中居中顯示 c 怎麼設定子窗體在主窗體中居中 顯示問題的開始是由c 傳傳看主群裡的印醒提出來的,下面我來說一下解決方案吧 其實表面上看是很簡單的 開始吧,現在有兩個窗體form1主窗體,form2子窗體 而且我相信大部分人都會這樣寫 在子窗體的load事件中 這樣寫this...

C 怎麼設定子窗體在主窗體中居中顯示

c 怎麼設定子窗體在主窗體中居中顯示 問題的開始是由c 傳傳看主群裡的印醒提出來的,下面我來說一下解決方案吧 其實表面上看是很簡單的 開始吧,現在有兩個窗體form1主窗體,form2子窗體 而且我相信大部分人都會這樣寫 在子窗體的load事件中 這樣寫this.startposition form...

窗體傳值中的顯示和關閉窗體

private showinfomsg form if this.form null 判斷是否例項化 form new showinfomsg form.show else if this.form.isdisposed 判斷子窗體是否關閉 from null 如果關閉先釋放資源 form new ...