無邊框窗體最大化,但是不檔住工作列

2021-03-31 08:56:31 字數 4225 閱讀 2709

個窗體,乙個模組:

窗體上兩個按鈕,窗體的borderstyle屬性為0,窗體**如下:

option explicit

private type rect

left as long

top as long

right as long

bottom as long

end type

private declare function getwindowrect lib "user32" (byval hwnd as long, lprect as rect) as long

private declare function findwindow lib "user32" alias "findwindowa" (byval lpclassname as string, byval lpwindowname as string) as long

private declare function findwindowex lib "user32" alias "findwindowexa" (byval hwnd1 as long, byval hwnd2 as long, byval lpsz1 as string, byval lpsz2 as string) as long

private declare function getdesktopwindow lib "user32" () as long

private sub ***mand1_click()

me.windowstate = 2

end sub

private sub ***mand2_click()

unload me

end sub

private sub form_load()

dim htaskbar as long

htaskbar = findwindow("shell_traywnd", vbnullstring)

debug.print htaskbar

dim rc as rect

dim i as long

i = getwindowrect(htaskbar, rc)

dim taskheight as long

taskheight = rc.bottom - rc.top '工作列高度

i = getwindowrect(getdesktopwindow, rc)

dim maxwidth as long

dim maxheight as long

maxwidth = rc.right - rc.left '獲取螢幕寬度

maxheight = rc.bottom - rc.top - taskheight '螢幕高度-工作列高度

lockwindow me.hwnd, , , maxwidth, maxheight

end sub

模組**:

option explicit

public type pointapi

x as long

y as long

end type

public type minmaxinfo

ptreserved as pointapi

ptmaxsize as pointapi

ptmaxposition as pointapi

ptmintracksize as pointapi

ptmaxtracksize as pointapi

end type

public declare sub copymemory lib "kernel32" alias "rtlmovememory" (destination as any, source as any, byval length as long)

public declare function callwindowproc lib "user32" alias "callwindowproca" (byval lpprevwndfunc as long, byval hwnd as long, byval msg as long, byval wparam as long, byval lparam as long) as long

public declare function setwindowlong lib "user32" alias "setwindowlonga" (byval hwnd as long, byval nindex as long, byval dwnewlong as long) as long

public declare function sendmessage lib "user32" alias "sendmessagea" (byval hwnd as long, byval wmsg as long, byval wparam as long, lparam as any) as long

public const wm_getminmaxinfo = &h24

public const gwl_wndproc = -4

global lpprevwndproc as long

public procold as long

public udtmmi as minmaxinfo

public function windowproc(byval hwnd as long, byval imsg as long, byval wparam as long, byval lparam as long) as long

select case imsg

case wm_getminmaxinfo

dim udtminmaxinfo as minmaxinfo

copymemory udtminmaxinfo, byval lparam, 40&

with udtminmaxinfo

.ptmaxsize.x = udtmmi.ptmaxsize.x

.ptmaxsize.y = udtmmi.ptmaxsize.y

.ptmaxposition.x = 0

.ptmaxposition.y = 0

.ptmaxtracksize.x = .ptmaxsize.x

.ptmaxtracksize.y = .ptmaxsize.y

.ptmintracksize.x = udtmmi.ptmintracksize.x

.ptmintracksize.y = udtmmi.ptmintracksize.y

debug.print .ptmaxsize.x & "," & .ptmaxsize.y

end with

copymemory byval lparam, udtminmaxinfo, 40&

windowproc = false

exit function

end select

windowproc = callwindowproc(procold, hwnd, imsg, wparam, lparam)

end function

public function lockwindow(hwnd as long, optional minwidth as long, optional minheight as long, optional maxwidth as long, optional maxheight as long) as boolean

with udtmmi

'指定窗體最小寬度

if minwidth = 0 then .ptmintracksize.x = 0 else .ptmintracksize.x = minwidth

'指定窗體最小高度

if minheight = 0 then .ptmintracksize.y = 0 else .ptmintracksize.y = minheight

'指定窗體最大寬度

if maxwidth = 0 then .ptmaxsize.x = screen.width / screen.twipsperpixelx else .ptmaxsize.x = maxwidth

'指定窗體最大高度

if maxheight = 0 then .ptmaxsize.y = screen.width / screen.twipsperpixelx else .ptmaxsize.y = maxheight

end with

procold = setwindowlong(hwnd, -4, addressof windowproc)

end function

無邊框窗體最大化,但是不檔住工作列

個窗體,乙個模組 窗體上兩個按鈕,窗體的borderstyle屬性為0,窗體 如下 option explicit private type rect left as long top as long right as long bottom as long end type private dec...

WPF學習 最大化有陰影的無邊框窗體

畫兩個按鈕,希望執行時只顯示乙個按鈕,另乙個按鈕隱藏。用到 visibility collapsed 隱藏按鈕,且不為它保留位置。horizontalalignment right template verticalalignment top width 45 height 42 最小化 最大化 關...

WPF視窗最大化 不覆蓋工作列

目的 讓視窗初始化時 最大化,只有最小化和關閉按鈕。許多軟體都是如此 分析 網上好多實現都是一大堆 直接使用win的api來獲取各種引數 實現 全屏設定 rect rc systemparameters.workarea 獲取工作區大小 this.left 0 設定位置 this.top 0 thi...