Hai cameron2 & Billy Conner,
extreamly sorry for the late comment to your posts.coz i am sure i did not notify of your comments.
caeonen2,
Wow this is really good, so simple.
Did you manage this by yourself?
yah yah, just undestanding the window & it's messages helped me a lot.
there are plenty of articles on the net on Window Messages and Undestaning the Window architect.
BillCorner
fun, but it only works if your task bar sits horizontal(bottom or top of screen), if its on the side of the screen it doesn't look good.
Mars base one Username: Jim Davis Password: yCrm33
Posts
1,284
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.
Just got registered and was looking through the forum. I've been using AutoHotKey for doing small apps and this is something I was trying to do with that {the system tray part anyway}. I haven't taken a look at this yet, but I wanted to thank you in advance