INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Visual Basic (Microsoft) Versions 5/6 FAQ

Windows API

How to enable/disable a windows object(EX. Start Menu) by percent
Posted: 12 May 04


This FAQ will show you some example code on how to enable & disable objects

'First you need to declare the API functions you will be using{
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
'};

'This function will get the handle of the start menu and enable it or disable it depending on the value of the Status value
Private Function Enable_WindowsXP_StartButton(Status as Boolean)
Dim zhWnd As Long
zhWnd = FindWindowEx(0&, 0&, "Shell_TrayWnd", vbNullString): zhWnd = FindWindowEx(zhWnd, 0&, "Button", vbNullString)'This uses the class of the object to find the objects handle
Call EnableWindow(zhWnd, Status)'Runs the API to enable or disable the object
End Function


'Use The Above Function In The Manner Below
Call Enable_WindowsXP_StartButton(False) 'To Disable Start Menu

Call Enable_WindowsXP_StartButton(True) 'To Disable Start Menu

*This code was made while using windows xp - so is not Guaranteed to work in other OS versions*

Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close