Obtains the screen size except the taskbar height (width ).
Type rect
Left as long
Top as long
Right as long
Bottom as long
End type
Private declare function findwindow lib "USER32" alias "find0000wa" (byval lpclassname as string, byval lpwindowname as string) as long
Private declare function getwindowrect lib "USER32" (byval hwnd as long, byref lprect as rect) as Boolean
Public sub XX () 'gets the screen size except the taskbar height (width)
Dim re as rect
Dim Kuan as long, Gao as long
Getwindowrect findwindow ("shell_traywnd", vbnullstring), Re
If Re. Top = 0 and RE. Left = 0 and RE. Right <Re. Bottom then 'taskbar on the left
Kuan = screen. width/screen. twipsperpixelx + RE. Right. Note that +
Gao = screen. Height/screen. twipsperpixely
End if
If Re. Top = 0 and RE. Left = 0 and RE. Right> re. Bottom then 'taskbar on top
Kuan = screen. width/screen. twipsperpixelx
Gao = screen. Height/screen. twipsperpixely + RE. Bottom 'note that +
End if
If Re. Top <> 0 and RE. Left = 0 then 'the taskbar is below
Kuan = screen. width/screen. twipsperpixelx
Gao = screen. Height/screen. twipsperpixely-(Re. Bottom-Re. Top-
End if
If Re. Top = 0 and RE. Left <> 0 then 'the taskbar is on the right.
Kuan = screen. width/screen. twipsperpixelx-(Re. Right-Re. Left-
Gao = screen. Height/screen. twipsperpixely
End if
Debug. Print Kuan, Gao
End sub
This code can be used to determine the status and size of the taskbar. It is very good. Sometimes, if the screen resolution is directly obtained, the taskbar will be included.
========================================================== ==============================================
. Version 2
. Dll command find0000wa, integer type
. Parameter A, text type
. Parameter B, text type
. Dll command getwindowrect, logical type
. Parameter A, integer
. Parameter B, rect, transfer address
. Version 2
. Data Type rect
. Member left, integer
. Member top, integer type
. Member right, integer
. Member bottom, integer type
. Version 2
. Assembly window assembly 1
. Subroutine _ button 1 _ clicked
. Local variable re, rect
. Local variable Kuan, integer type
. Local variable Gao, integer type
. Local variable Wei, text type
Kuan = screen width ()
Gao = screen height ()
Getwindowrect (find0000wa ("shell_traywnd", ""), Re)
. If the true (Re. Top = 0 and re. Left = 0 and RE. Right <Re. Bottom) 'taskbar is on the left
Wei = "left"
Kuan = Kuan + RE. Right
. If it really ends
. If the true (Re. Top = 0 and re. Left = 0 and RE. Right> re. Bottom) 'taskbar is on the top
Wei = "TOP"
Gao = Gao + RE. Bottom
. If it really ends
. If the true (Re. Top = 0 and RE. Left = 0) 'taskbar is below
Wei = "bottom"
Gao = Gao-(Re. Bottom-Re. Top)
. If it really ends
. If the true (Re. Top = 0 and RE. Left = 0) 'taskbar is on the right
Wei = "right"
Kuan = Kuan-(Re. Right-Re. Left)
. If it really ends
Label 1. Title = "Taskbar in" + Wei + ", the size after removing the taskbar is:" + to text (Kuan) + "X" + to text (GAO)