|
-
Nov 13th, 2008, 11:56 PM
#9
Re: Move System Tray, Start Button etc.
Here is my small code i wrote not so long ago, to determine where is the taskbar just aligned. It also helps to determine the actual desktop area.
Basic but works as well.
Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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 Sub Form_Load()
Dim Rt As RECT
Rt = GetDesktopRect
With Rt
Debug.Print .Left; .Top; .Right; .Bottom
End With
End
End Sub
Private Function GetDesktopRect(Optional ByRef GetTaskBarP As Long = -1) As RECT
Static tWnd As Long
Dim Rt As RECT
Dim sX As Long, sY As Long
sX = Screen.Width / Screen.TwipsPerPixelX
sY = Screen.Height / Screen.TwipsPerPixelY
If tWnd = 0 Then tWnd = FindWindow("Shell_TrayWnd", vbNullString)
GetWindowRect tWnd, Rt
With GetDesktopRect
.Left = 0
.Top = 0
.Right = sX
.Bottom = sY
End With
With Rt
If .Left < 1 And .Top > 1 Then
GetDesktopRect.Bottom = .Top
GetTaskBarP = 1
Exit Function
End If
If .Left < 1 And .Top < 1 And .Bottom > sY Then
GetDesktopRect.Left = .Right
GetTaskBarP = 2
Exit Function
End If
If .Left < 1 And .Top < 1 And .Right > sX Then
GetDesktopRect.Top = .Bottom
GetTaskBarP = 3
Exit Function
End If
If .Left > 0 Then
GetDesktopRect.Right = .Left
GetTaskBarP = 4
Exit Function
End If
End With
End Function
Funny code Maybe you can extend it to detect how close the mouse pointer is, then you can move the object close to the pointer, to make it easy to click on it.... Or just run before it, to be hard to catch :-D
Last edited by Jim Davis; Nov 14th, 2008 at 12:11 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|