Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable Start button

Posted on 1998-12-10
5
Medium Priority
?
248 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 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

877 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