Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Disable Start button

Posted on 1998-12-10
5
Medium Priority
?
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
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

688 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