Solved

Disable Start button

Posted on 1998-12-10
5
233 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

738 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