Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 454
Viewed: 2883
Added: Aug 19, 2002
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Code to return and change the picture, width, height and position of the start button. V good code, works with all versions of windows.

Highlight all by clicking in box
<!---Declaration--->
Declarations

Option Explicit

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hWndChild As Long) As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

Private Type POINTAPI
X As Long
Y As Long
End Type

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type

Private Const GW_NEXT = 2
Private Const GW_CHILD = 5
Private Const BM_SETIMAGE = &HF7

Highlight All
<!---Code--->
'Use this code well, my fellow VB'ers
'Tip: press Ctrl + A to select all this code!

Private Function TaskbarHwnd() As Long

Dim MainHwnd As Long, CHwnd As Long
Dim CLS_NM As String * 14

MainHwnd = GetDesktopWindow
CHwnd = GetWindow(MainHwnd, GW_CHILD)
Do While CHwnd <> 0
GetClassName CHwnd, CLS_NM, 14
If Left(CLS_NM, 13) = "Shell_TrayWnd" Then
TaskbarHwnd = CHwnd
Exit Function
End If
CHwnd = GetWindow(CHwnd, GW_NEXT)
Loop

End Function
Property Get hwnd() As Long

Dim MainHwnd As Long, CHwnd As Long
Dim CLS_NM As String * 7

MainHwnd = TaskbarHwnd
CHwnd = GetWindow(MainHwnd, GW_CHILD)
Do While CHwnd <> 0
GetClassName CHwnd, CLS_NM, 7
If Left(CLS_NM, 6) = "Button" Then
hwnd = CHwnd
Exit Property
End If
CHwnd = GetWindow(CHwnd, GW_NEXT)
Loop

End Property

'Set picture. ie hPic (LoadPicture("C:mystart.bmp"))
Property Let hPic(ByVal hPicture As Long)

PostMessage hwnd, BM_SETIMAGE, 0, hPicture

End Property
Property Let Width(ByVal sWidth As Long)

SetWindowPos hwnd, 0, 0, 0, sWidth / 15, Height / 15, 2

End Property

Property Get Width() As Long

Dim tmpRECT As RECT

GetWindowRect hwnd, tmpRECT
Width = (tmpRECT.Right - tmpRECT.Left) * 15

End Property

Property Let Height(ByVal sHeight As Long)

SetWindowPos hwnd, 0, 0, 0, Width / 15, sHeight / 15, 2

End Property

Property Get Height() As Long

Dim tmpRECT As RECT

GetWindowRect hwnd, tmpRECT
Height = (tmpRECT.Bottom - tmpRECT.Top) * 15

End Property

Property Let Left(ByVal lX As Long)

SetWindowPos hwnd, 0, lX / 15, Top / 15, 0, 0, 1

End Property

Property Get Left() As Long

Dim tmpPLC As WINDOWPLACEMENT

tmpPLC.Length = Len(tmpPLC)
GetWindowPlacement Start.hwnd, tmpPLC

Left = tmpPLC.rcNormalPosition.Left * 15

End Property
Property Let Top(ByVal lY As Long)

SetWindowPos hwnd, 0, Left / 15, lY / 15, 0, 0, 1

End Property
Property Get Top() As Long

Dim tmpPLC As WINDOWPLACEMENT

tmpPLC.Length = Len(tmpPLC)
GetWindowPlacement Start.hwnd, tmpPLC

Top = tmpPLC.rcNormalPosition.Top * 15

End Property
Property Let Parent(ByVal hParent As Long)

SetParent hwnd, hParent

End Property
Property Get Parent() As Long

Parent = GetParent(hwnd)

End Property;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions