Solved

Disable Start button

Posted on 1998-12-10
5
219 Views
Last Modified: 2010-07-27
I found this code thats supposed to disable enable the start button but it does not work. What is wrong or I need code that works.

'to disable
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), vbNull, "Button", ""), False)

'to enable
 Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), vbNull, "Button", ""), True)
   
This is the start button with the windows logo on the taskbar, and the keyboard.

Thank you Experts
 
0
Comment
Question by:fred12
5 Comments
 
LVL 9

Expert Comment

by:Dalin
ID: 1449225
fred12,
Tray this:

Dim hWnd1 As Long

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

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
       Const SWP_HIDEWINDOW = &H80
       Const SWP_SHOWWINDOW = &H40


'code for disable:
hWnd1 = FindWindow("Shell_traywnd", "")
Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)

'and code for enable again:
Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)

Regards
Dalin
0
 

Author Comment

by:fred12
ID: 1449226
Dalin sorry the code you provided hide/shows all of taskbar, Im looking for just the start button. Thank you
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 100 total points
ID: 1449227
Here you are:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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 EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long


Private Sub Command1_Click()
'to disable
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "Button", ""), 0)

End Sub

Private Sub Command2_Click()
'to enable
Call EnableWindow(FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0, "Button", ""), 1)
End Sub


0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1449228
Try this:
Dim hFw as long
hFw = FindWindow("Shell_TrayWnd", vbNullString)
hFw = FindWindowEx(hFw, 0,  "Button", vbNullString)
EnableWindow(hFw, FALSE)
0
 

Author Comment

by:fred12
ID: 1449229
:)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now