disable Start menu button

H

Harsh Trivedi

Hi,

We are developing application in VS .NET 2005 + C# + .NET CF 2.0 SP1

My user requirement is ... to disable the Start menu button (Upper left
side, to invoke the start up menu) . This way we can prevent the user to
click on any other program or control panel when our application is running.

Is there a way to achieve this?

Thanks in advance
 
H

Harsh Trivedi

Hi,

Hurrey, this worked for me...to disable the start menu...
ShowWindow(FindWindow("HHTaskBar", null), 1); //0=hide, 1=show

On the same track, if anyone can sent source code to set start button as
visible false.... :)
 
P

Paul G. Tobey [eMVP]

Yes, that's one thing that you'd need to do. You'd also need to disable
that window so Alt+Tab doesn't allow the user to switch applications.
You'll basically have to P/Invoke to those functions (ShowWindow,
FindWindow, EnableWindow), to accomplish this operation.

Paul T.
 
K

Kay-Christian Wessel

Here is something I use, which I found on the net some time ago.

Kay





Imports System.Runtime.InteropServices

Public Class BarControl

<DllImport("coredll.dll", EntryPoint:="GetForegroundWindow",
SetLastError:=True)> Private Shared Function GetForegroundWindow() As IntPtr

End Function

<DllImport("aygshell.dll", EntryPoint:="SHFullScreen", SetLastError:=True)>
Private Shared Function SHFullScreen(ByVal hwndRequester As IntPtr, ByVal
dwState As Integer) As Boolean

End Function

<DllImport("coredll.dll", EntryPoint:="EnableWindow")> Private Shared
Function EnableWindow(ByVal hwnd As IntPtr, ByVal bEnable As Boolean) As
Boolean

End Function

<DllImport("coredll.dll", EntryPoint:="FindWindow")> Private Shared Function
FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As
IntPtr

End Function

Private Const SHFS_SHOWSTARTICON As Integer = &H10

Private Const SHFS_HIDESTARTICON As Integer = &H20

Private Const SHFS_HIDESIPBUTTON As Integer = &H8

Private Const SHFS_SHOWSIPBUTTON As Integer = &H4

Private Const SHFS_SHOWTASKBAR As Integer = &H1

Private Const SHFS_HIDETASKBAR As Integer = &H2

Private Shared Function SetTaskBarEnabled(ByVal bEnabled As Boolean) As
Boolean

Dim hwnd As IntPtr = FindWindow("HHTaskBar", Nothing)

If Not hwnd.Equals(IntPtr.Zero) Then

If bEnabled Then

Return EnableWindow(hwnd, True)

Else

Return EnableWindow(hwnd, False)

End If

End If

Return True

End Function

Private Shared Function SetTaskbarVisible(ByVal visible As Boolean) As
Boolean

Dim hwnd As IntPtr = FindWindow("HHTaskBar", Nothing)

If Not hwnd.Equals(IntPtr.Zero) Then

If visible Then

Return SHFullScreen(hwnd, SHFS_SHOWTASKBAR)

Else

Return SHFullScreen(hwnd, SHFS_HIDETASKBAR)

End If

End If

End Function

Private Shared Function SetStartButtonVisible(ByVal visible As Boolean) As
Boolean

Dim hwnd As IntPtr = GetForegroundWindow()

If Not hwnd.Equals(IntPtr.Zero) Then

If visible Then

Return SHFullScreen(hwnd, SHFS_SHOWSTARTICON)

Else

Return SHFullScreen(hwnd, SHFS_HIDESTARTICON)

End If

End If

End Function

Private Shared Function SetSIPVisible(ByVal visible As Boolean) As Boolean

Dim hwnd As IntPtr = GetForegroundWindow()

If Not hwnd.Equals(IntPtr.Zero) Then

If visible Then

Return SHFullScreen(hwnd, SHFS_HIDESIPBUTTON)

Else

Return SHFullScreen(hwnd, SHFS_HIDESIPBUTTON)

End If

End If

End Function

Public Shared Sub ShowTaskBar()

SetTaskBarEnabled(True)

SetTaskbarVisible(True)

End Sub

Public Shared Sub HideTaskBar()

SetTaskbarVisible(False)

SetTaskBarEnabled(False)

End Sub

Public Shared Sub ShowSIP()

SetSIPVisible(True)

End Sub

Public Shared Sub HideSIP()

SetSIPVisible(False)

End Sub

Public Shared Sub HideStartButton()

SetStartButtonVisible(False)

End Sub

Public Shared Sub ShowStartButton()

SetStartButtonVisible(True)

End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top