Member Avatar for Rahul47

Hello fellas, recently i hit upon an to develop a small program to lock screen.

As a part of it, I need to lock taskbar from functioning, i.e should not show up when pressed Start Button, or Ctrl + esc or not even Ctrl + alt + Del.

I dont know much of libraries or other way to do it.

Suggestions are always appreciated.

thanks :-)

Recommended Answers

All 6 Replies

Hi,

You can try this;

  Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    Const SWP_HIDEWINDOW = &H80
    Const SWP_SHOWWINDOW = &H40
    Dim taskBar As Integer

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Button1.Text = "Hide" Then
            Debug.Write(SetWindowPos(taskBar, 0&, 0&, 0&, 0&, 0&, SWP_HIDEWINDOW))
            Button1.Text = "Show"
        Else
            Debug.Write(SetWindowPos(taskBar, 0&, 0&, 0&, 0&, 0&, SWP_SHOWWINDOW))
            Button1.Text = "Hide"
        End If
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        taskBar = FindWindow("Shell_traywnd", "")
    End Sub
Member Avatar for Rahul47

@Luc001: Is that code for hiding taskbar or locking it comletely.

I need to lock a taskbar and it should not respond even if start button is pressed or should not popup the Windows Task Manager.

Appreciate your effort. Let me try code given by you.

Thanks

Hi Rahul47,
I am Jenifer, owner of Software Collection.
I didn't understand what you really wanting to learn?
I mean do you want to enable the auto hide feature of taskbar?
Then you can simple do it by going to taskbar properties and check the auto hide option.
But I don't think so you are looking for that simple solution :-P

Member Avatar for Rahul47

@Jenifer Sarah: Yea, you are right, am not looking for hiding feature.

I am actually writing an application which will lock screen when it's opened, Like a Child Lock in TV.
It will have only a small login panel, and will cover whole desktop including taskbar and start button.

But the catch is...start button is easily accessible through Start. . or Ctrl + Esc. Also Taskbar is brings up the form on hitting start button. Ctrl + Alt + Delete will also bring up Task Manager which should not. Ctrl + Tab will switch applications.

Conclusion: All controls to return to desktop should be locked and password protected.

Thanks for your concern.

Member Avatar for Rahul47

@Jenifer Sarah: Your link of Software Collection is directed to a dead page.
Please check again.

Thanks.

What you need is this: (I promise you it works on Windows 10)

Public Class Form1




 Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer,     ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As IntPtr, ByVal nCmdShow As Integer) As Integer
Public Const SWP_HIDEWINDOW = &H80
Public Const SWP_SHOWWINDOW = &H40
Public Const SW_HIDE As Integer = 0
Public Const SW_RESTORE As Integer = 9
Dim taskBar As Integer




Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    taskBar = FindWindow("Shell_traywnd", "")
    Dim intReturn As Integer = FindWindow("Shell_traywnd", "")
        SetWindowPos(intReturn, 0, 0, 0, 0, 0, SWP_HIDEWINDOW) 'This will "HIDE" your taskbar/// To bring back taskbar, simply       change the end to: SWP_SHOWWINDOW
    Dim hwnd As IntPtr
    hwnd = FindWindow(vbNullString, "Program Manager")
    If Not hwnd = 0 Then
        ShowWindow(hwnd, SW_RESTORE) 'Type "HIDE" where you see "SW_RESTORE" to hide
    End If

End Sub

End Class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.