VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create your own Start Button with this code

by SreeHarsha (2 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 14th April 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Create your own Start Button with this code

API Declarations



Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim tWnd As Long, bWnd As Long, ncWnd As Long


Rate Create your own Start Button with this code



     Dim R As RECT
    'Get the taskbar's window handle
    tWnd = FindWindow("Shell_TrayWnd", vbNullString)
    'Get the start-button's window handle
    bWnd = FindWindowEx(tWnd, ByVal 0&, "BUTTON", vbNullString)
    'Get the start button's position
    GetWindowRect bWnd, R
    'Create a new button
    ncWnd = CreateWindowEx(ByVal 0&, "BUTTON", "Harsha", WS_LBUTTONDOWN, 0, 0, R.Right - R.Left, R.Bottom - R.Top, tWnd, ByVal 0&, App.hInstance, ByVal 0&)
    'Show our button
    ShowWindow ncWnd, SW_NORMAL
    'Hide the start button
    ShowWindow bWnd, SW_HIDE
End Sub

Private Sub Form_Unload(Cancel As Integer)
    'show the start button
    ShowWindow bWnd, SW_NORMAL
    'destroy our button
    DestroyWindow ncWnd
End Sub

'Thank u

Download this snippet    Add to My Saved Code

Create your own Start Button with this code Comments

No comments have been posted about Create your own Start Button with this code. Why not be the first to post a comment about Create your own Start Button with this code.

Post your comment

Subject:
Message:
0/1000 characters