这是一个网站上的东西,你看看吧,再对应一下MsdnConst ABS_AUTOHIDE = &H1
Const ABS_ONTOP = &H2
Const ABM_GETSTATE = &H4
Const ABM_GETTASKBARPOS = &H5
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long ' message specific
End Type
Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
Private Sub Form_Paint()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim ABD As APPBARDATA, Ret As Long
'Get the taskbar's position
SHAppBarMessage ABM_GETTASKBARPOS, ABD
'Get the taskbar's state
Ret = SHAppBarMessage(ABM_GETSTATE, ABD)
If (Ret And ABS_AUTOHIDE) Then Me.Print "Autohide option is on"
If (Ret And ABS_ONTOP) Then Me.Print "Always on top option is on"
Me.Print "Taskbar coordinates: (" + Trim(Str(ABD.rc.Left)) + "," + Trim(Str(ABD.rc.Top)) + ")-(" + Trim(Str(ABD.rc.Right)) + "," + Trim(Str(ABD.rc.Bottom)) + ")"
End Sub
Const ABS_ONTOP = &H2
Const ABM_GETSTATE = &H4
Const ABM_GETTASKBARPOS = &H5
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long ' message specific
End Type
Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
Private Sub Form_Paint()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim ABD As APPBARDATA, Ret As Long
'Get the taskbar's position
SHAppBarMessage ABM_GETTASKBARPOS, ABD
'Get the taskbar's state
Ret = SHAppBarMessage(ABM_GETSTATE, ABD)
If (Ret And ABS_AUTOHIDE) Then Me.Print "Autohide option is on"
If (Ret And ABS_ONTOP) Then Me.Print "Always on top option is on"
Me.Print "Taskbar coordinates: (" + Trim(Str(ABD.rc.Left)) + "," + Trim(Str(ABD.rc.Top)) + ")-(" + Trim(Str(ABD.rc.Right)) + "," + Trim(Str(ABD.rc.Bottom)) + ")"
End Sub
如何製作簡單的工作列 這首先得向Windows註冊一個工作列的區域,Windows才會空出一個區域,在視窗最大化時才不會蓋住 程式如下
'以下程式在Form中 需要4個Command1(就是Command1的陣列)
'-----------------------------------------------------------------------------------------------------
Private Const ABM_NEW = &H0
Private Const ABM_REMOVE = &H1
Private Const ABM_SETPOS = &H3
Private Const ABM_ACTIVATE = &H6Private Const ABE_LEFT = 0
Private Const ABE_TOP = 1
Private Const ABE_RIGHT = 2
Private Const ABE_BOTTOM = 3Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePrivate Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long
End TypePrivate Declare Function SHAppBarMessage Lib "shell32.dll" _
(ByVal dwMessage As Long, _
pData As APPBARDATA) As Long
Dim pData As APPBARDATAPrivate Sub Command1_Click(Index As Integer)
If Index = 0 Then 'Left
pData.rc.Left = -2
pData.rc.Top = -2
pData.rc.Right = Me.Width / Screen.TwipsPerPixelX
pData.rc.Bottom = Me.Height / Screen.TwipsPerPixelY
pData.uEdge = ABE_LEFT '設定位置在左方
ElseIf Index = 1 Then 'Top
pData.rc.Left = -2
pData.rc.Top = -2
pData.rc.Right = Me.Width / Screen.TwipsPerPixelX
pData.rc.Bottom = Me.Height / Screen.TwipsPerPixelY
pData.uEdge = ABE_TOP '設定位置在上方
ElseIf Index = 2 Then 'Right
pData.rc.Left = (Screen.Width - Me.Width) \ Screen.TwipsPerPixelX
pData.rc.Top = -2
pData.rc.Right = Screen.Width \ Screen.TwipsPerPixelX
pData.rc.Bottom = Me.Height \ Screen.TwipsPerPixelY
pData.uEdge = ABE_RIGHT '設定位置在右方
ElseIf Index = 3 Then 'Bottom
pData.rc.Left = -2
pData.rc.Top = (Screen.Height - Me.Height) \ Screen.TwipsPerPixelY
pData.rc.Right = Me.Width \ Screen.TwipsPerPixelX
pData.rc.Bottom = Screen.Height \ Screen.TwipsPerPixelY
pData.uEdge = ABE_BOTTOM '設定位置在下方
End IfSHAppBarMessage ABM_SETPOS, pData
SHAppBarMessage ABM_ACTIVATE, pData
DoEventsMe.Top = pData.rc.Top * Screen.TwipsPerPixelY
Me.Left = pData.rc.Left * Screen.TwipsPerPixelXEnd SubPrivate Sub Form_Load()
pData.cbSize = Len(pData)
pData.hwnd = Me.hwnd
pData.uCallbackMessage = 123
SHAppBarMessage ABM_NEW, pData
Command1(0).Caption = "Left"
Command1(1).Caption = "Top"
Command1(2).Caption = "Right"
Command1(3).Caption = "Bottom"End SubPrivate Sub Form_Terminate()
SHAppBarMessage ABM_REMOVE, pData
End Sub
WINSHELLAPI UINT APIENTRY SHAppBarMessage(
DWORD dwMessage,
PAPPBARDATA pData
); Sends an appbar message to the system. Returns a message-dependent value. For more information, see the Microsoft Platform SDK documentation for the appbar message sent.
dwMessage
Appbar message value to send. This parameter can be one of the following values: ABM_ACTIVATE Notifies the system that an appbar has been activated.
ABM_GETAUTOHIDEBAR Retrieves the handle to the autohide appbar associated with a particular edge of the screen.
ABM_GETSTATE Retrieves the autohide and always-on-top states of the Windows taskbar.
ABM_GETTASKBARPOS Retrieves the bounding rectangle of the Windows taskbar.
ABM_NEW Registers a new appbar and specifies the message identifier that the system should use to send notification messages to the appbar.
ABM_QUERYPOS Requests a size and screen position for an appbar.
ABM_REMOVE Unregisters an appbar, removing the bar from the system's internal list.
ABM_SETAUTOHIDEBAR Registers or unregisters an autohide appbar for an edge of the screen.
ABM_SETPOS Sets the size and screen position of an appbar.
ABM_WINDOWPOSCHANGED Notifies the system when an appbar's position has changed. pData
Address of an APPBARDATA structure. The content of the structure depends on the value set in the dwMessage parameter. APPBARDATA
typedef struct _AppBarData {
DWORD cbSize;
HWND hWnd;
UINT uCallbackMessage;
UINT uEdge;
RECT rc;
LPARAM lParam;
} APPBARDATA, *PAPPBARDATA; Contains information about a system appbar message. This structure is used with the SHAppBarMessage function. cbSize
Contains the size of the structure, in bytes.
hWnd
Contains the handle to the appbar window.
uCallbackMessage
Application-defined message identifier. The application uses the specified identifier for notification messages that it sends to the appbar identified by the hWnd member. This member is used when sending the ABM_NEW message.
uEdge
Value that specifies an edge of the screen. This member can be one of the following values: ABE_BOTTOM Bottom edge.
ABE_LEFT Left edge.
ABE_RIGHT Right edge.
ABE_TOP Top edge. This member is used when sending the ABM_GETAUTOHIDEBAR, ABM_QUERYPOS, ABM_SETAUTOHIDEBAR, and ABM_SETPOS messages. rc
RECT structure to contain the bounding rectangle, in screen coordinates, of an appbar or the Windows taskbar. This member is used when sending the ABM_GETTASKBARPOS, ABM_QUERYPOS, and ABM_SETPOS messages.
lParam
Message-dependent value. This member is used with the ABM_SETAUTOHIDEBAR message.