|
| 1 | +VERSION 5.00 |
| 2 | +Begin VB.Form frmMain |
| 3 | + BorderStyle = 1 'Fixed Single |
| 4 | + Caption = "Find Start Button" |
| 5 | + ClientHeight = 930 |
| 6 | + ClientLeft = 45 |
| 7 | + ClientTop = 330 |
| 8 | + ClientWidth = 3135 |
| 9 | + BeginProperty Font |
| 10 | + Name = "Tahoma" |
| 11 | + Size = 8.25 |
| 12 | + Charset = 0 |
| 13 | + Weight = 400 |
| 14 | + Underline = 0 'False |
| 15 | + Italic = 0 'False |
| 16 | + Strikethrough = 0 'False |
| 17 | + EndProperty |
| 18 | + LinkTopic = "Form1" |
| 19 | + MaxButton = 0 'False |
| 20 | + MinButton = 0 'False |
| 21 | + ScaleHeight = 930 |
| 22 | + ScaleWidth = 3135 |
| 23 | + StartUpPosition = 2 'CenterScreen |
| 24 | + Begin VB.ListBox List1 |
| 25 | + Height = 255 |
| 26 | + Left = 120 |
| 27 | + TabIndex = 1 |
| 28 | + Top = 90 |
| 29 | + Width = 2895 |
| 30 | + End |
| 31 | + Begin VB.CommandButton btnStatus |
| 32 | + Caption = "Disable Start button" |
| 33 | + Height = 375 |
| 34 | + Left = 120 |
| 35 | + TabIndex = 0 |
| 36 | + Top = 480 |
| 37 | + Width = 2895 |
| 38 | + End |
| 39 | +End |
| 40 | +Attribute VB_Name = "frmMain" |
| 41 | +Attribute VB_GlobalNameSpace = False |
| 42 | +Attribute VB_Creatable = False |
| 43 | +Attribute VB_PredeclaredId = True |
| 44 | +Attribute VB_Exposed = False |
| 45 | +Option Explicit |
| 46 | + |
| 47 | + |
| 48 | +Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long |
| 49 | +' if fEnable=0 then you disable the window. if 1, you enable it. |
| 50 | + |
| 51 | +Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long |
| 52 | +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 |
| 53 | + |
| 54 | +Private xText(1) As String |
| 55 | +Private Toggle As Long |
| 56 | +Private StartButtonHandle As Long |
| 57 | + |
| 58 | +Private Sub btnStatus_Click() |
| 59 | +Dim Funk As Long |
| 60 | + |
| 61 | +Toggle = (Toggle + 1) Mod 2 |
| 62 | + |
| 63 | +btnStatus.Caption = xText(Toggle) |
| 64 | +Funk = EnableWindow(StartButtonHandle, Toggle) |
| 65 | +End Sub |
| 66 | + |
| 67 | +Private Sub Form_Load() |
| 68 | +Dim hWParent As Long |
| 69 | + |
| 70 | +Toggle = 1 |
| 71 | + |
| 72 | +hWParent = FindWindow("Shell_TrayWnd", vbNullString) |
| 73 | +StartButtonHandle = FindWindowEx(hWParent, 0&, "Button", vbNullString) |
| 74 | + |
| 75 | +List1.AddItem "Start button handle : " + Trim(Str(StartButtonHandle)) |
| 76 | + |
| 77 | +xText(1) = "Disable Start button" |
| 78 | +xText(0) = "Enable Start button" |
| 79 | + |
| 80 | +End Sub |
0 commit comments