unity中好像沒有這種方法,要用原生的方法,關鍵問題是要拿到窗體的控制代碼
如下所示,是我拿的別人的**,找到的是沒有父窗體的窗體控制代碼
public
delegate
bool
wndenumproc
(intptr hwnd,
uint lparam);[
dllimport
("user32.dll"
, setlasterror =
true)]
public
static
extern
bool
enumwindows
(wndenumproc lpenumfunc,
uint lparam);[
dllimport
("user32.dll"
, setlasterror =
true)]
public
static
extern
intptr
getparent
(intptr hwnd);[
dllimport
("user32.dll")]
public
static
extern
uint
getwindowthreadprocessid
(intptr hwnd,
refuint lpdwprocessid);[
dllimport
("kernel32.dll")]
public
static
extern
void
setlasterror
(uint dwerrcode)
;public
static
intptr
getprocesswnd()
}return
true;}
), pid)
;return
(!bresult && marshal.
getlastwin32error()
==0)? ptrwnd : intptr.zero;
}
拿到窗體的控制代碼之後,直接盡心設定
[
dllimport
("user32.dll")]
static
extern
bool
setwindowpos
(intptr hwnd,
int hwndinsertafter,
int x,
int y,
int cx,
int cy,
uint uflags)
;const
uint swp_showwindow =
0x0040
;setwindowpos
(getprocesswnd()
,0, startx, starty, screenwidth, screenheight, swp_showwindow)
;
MoveWindow改變指定視窗的位置和大小
movewindow vb宣告 declare function movewindow lib user32 alias movewindow byval hwnd as long,byval x as long,byval y as long,byval nwidth as long,byval ...
MOVEWINDOW改變指定視窗的位置和大小
vb宣告 declare function movewindow lib user32 alias movewindow byval hwnd as long,byval x as long,byval y as long,byval nwidth as long,byval nheight as ...
mfc動態改變對話方塊視窗大小和顯示位置
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!void cmainframe onchangesize c 1 2 3 4 5 6 crect cr getclientrect cr 獲取對話方塊客戶區域大小 clienttoscreen cr 轉換為熒幕座標 intx getsystemme...