1
I want my application to have a button that hides and re-exports the Windows taskbar in C#, to block user access to it. Any suggestions?
1
I want my application to have a button that hides and re-exports the Windows taskbar in C#, to block user access to it. Any suggestions?
3
Hiding the task is a very complicated thing, mainly because it’s not something that applications can just go around doing. Otherwise it would be easy to make it a mess.
What you want, is to keep the screen of your application in full screen and that’s very simple. It is only necessary to maximize the form, remove borders and set property TopMost
as true
.
Example:
// colocar o form em full screen
private void btFullScreen_Click(object sender, EventArgs e)
{
TopMost = true;
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
}
// Voltar ao estado normal (barra tarefas aparecendo)
private void btRestaurar_Click(object sender, EventArgs e)
{
TopMost = false;
FormBorderStyle = FormBorderStyle.FixedSingle; // ou a que estava antes
}
0
As they said, it’s very complicated to do, but not impossible. Add a new class with the following code:
using System; using System.Runtime.Interopservices;
public class Taskbar
{
[DllImport("user32.dll")]
private static extern int FindWindow(string className, string windowText);
[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int command);
[DllImport("user32.dll")]
public static extern int FindWindowEx(int parentHandle, int childAfter, string className, int windowTitle);
[DllImport("user32.dll")]
private static extern int GetDesktopWindow();
private const int SW_HIDE = 0;
private const int SW_SHOW = 1;
protected static int Handle
{
get
{
return FindWindow("Shell_TrayWnd", "");
}
}
protected static int HandleOfStartButton
{
get
{
int handleOfDesktop = GetDesktopWindow();
int handleOfStartButton = FindWindowEx(handleOfDesktop, 0, "button", 0);
return handleOfStartButton;
}
}
private Taskbar()
{
// hide ctor
}
public static void Show()
{
ShowWindow(Handle, SW_SHOW);
ShowWindow(HandleOfStartButton, SW_SHOW);
}
public static void Hide()
{
ShowWindow(Handle, SW_HIDE);
ShowWindow(HandleOfStartButton, SW_HIDE);
}
}
Show() shows and hide() hidden.
Browser other questions tagged c# winforms
You are not signed in. Login or sign up in order to post.
Give more details: why, why... Have you researched something? This is very complicated. For example even if you kill the Explorer.exe process that will hide the taskbar, it does not guarantee that the user will not press Windows+R and open the Explorer again.
– user26552
The idea is that the application can block user access to the task bar (like pressing F11 in browsers). Then I thought of two possibilities that would be the control of display of the task bar or make the application be "over" the same, preventing access. I’ve done a lot of research, found a few things like using borderStyle, but I’m having trouble implementing.
– Anderson Fellipe