in category
Search All
Tutorials
.Net
ASP
C/C++
ColdFusion
Delphi
DHTML
HTML
Java
Javascript
Perl
PHP
VBScript
Visual Basic
XML
Visual Basic
/
System Info
/ Start Button
Snippet details
ID:
454
Viewed:
1346
Added:
2002-08-19
Version:
User Rated at:
Rate This:
Select a rating...
5 .. Best
4
3 .. Average
2
1 .. Worst
Snippets in this catagory
Show Printable Version
Code to return and change the picture, width, height and position of the start button. V good code, works with all versions of windows.
General Details
Snippet uploaded by:
snippet
Email :
webmaster@snippetlibrary.com
Snippet By:
Unknown
Snippet By:
Unknown
Declarations
Highlight All
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
Code
Highlight All
'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 Reviews to show
Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.
Subject:
Reviewed By:
Write a review:
Terms of Conditions
Powered By
© 2005
snippetlibrary.com
All Rights Reserved.