I am running Windows XP 64 bit. I want to hide the taskbar when I run my application.
I tried codes by searching the web. In all those, it hides the task bar. But the problem is, when i open a notepad and maximize it, it is not actually into full screen. Because the space where task bar was there is still blocked with empty space. I want it fit really into full screen mode.
If you like to replace the windows shell (taskbar) you'll have to change a registry key.
Changing the default shell (all users):
open regedit (start menu > run, and type in regedit)
go to: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon.
Change Shell from explorer.exe to your program path and name e.g. c:\myKioskApp\Kiosk.exe
Changing the default shell (only current user):
open regedit (start menu > run, and type in regedit).
go to: HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon.
add a new string value (Edit > New > String Value) called shell. and set the value to the path of the new shell e.g. c:\myKioskApp\Kiosk.exe
log out and log back in.
I've done this by making the application borderless, maximized, and setting it to be Topmost. Here's a perfect example from CodeProject.
As one of the commenters has said, replacing disabling Explorer and running your application might be the best way, security-wise.
You Can Hide your task bar by setting Following Properties of your C# Form.
WindowState : Maximized
FormBorderStyle : FixedDialog
on window 7 (or maybe higher) using FormWindowState.Maximized is wrong because the maximum size will be subtracted by Taskbar height but you can do this
this.WindowState = FormWindowState.Normal; // or default
this.FormBorderStyle = FormBorderStyle.None;
this.TopMost = true;
// do it here
this.Location = new Point(0,0);
var fullscreenSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
this.Size = fullscreenSize;
Related
I have an old legacy system that uses Winforms and is published with the built in One click,
I look after 3 different installs and each one has its own database it connects to, so its been set up that when a different system is click, it check isCompany1 and will set the Favicon accordingly
so when depoyment is done in the application window the Icon and Manifest is set to the correct ICO, when installed the .exe icon will be what is set there,
However i am trying to bring these all inline as when we debug a drop asks which database we would like to connect to, and depending on that it will set things up differently.
When running in VS the icons in the taskbar will change accoring to the dynamic Favicon however when its depolyed with this new selection it wont change, (it will change once on first load, then wont again)
The issue is some users need access to the different instances so would like different icons at the bottom, but its not changing the task menu, but everything else such as ALT-TAB and the control panel icon is changing,
all forms link into a baseform and call this :
if (App.IsCompany1)
{
this.Icon = new Icon("Resources\\Company1.ico");
}
else if (App.Company2)
{
this.Icon = new Icon("Resources\\Company2.ico");
}
else if (App.Company3)
{
this.Icon = new Icon("Resources\\Company3.ico");
}
AS i said this will change everything but not the Taskbar, but will from VS debugging,
I have made sure the .ico has all sizes, by writing their sizes on each one, and they display correctly the Taskbar and ALT-TAB both use 32x32
If it's any consolation, I couldn't reproduce your complaint.
I put 3 icons in resources, a single button on a form, this code:
private int iconum = 0;
private Icon[] icons = new[] { Properties.Resources.icon1, Properties.Resources.icon2, Properties.Resources.icon3 };
private void button1_Click(object sender, EventArgs e)
{
this.Icon = icons[iconum++ % icons.Length];
}
And it cycled through the icons in the main form title bar and the windows task bar over and over on every button click (made sure to run a release built exe too, not a debug start):
Note: the thing in the top right is my taskbar
On Windows 10, the ShowBalloonTip method of NotifyIcon NEVER shows the balloon tip. This would appear to have something to do with Windows itself.
If I go to Settings > System > Notifications & actions > and find my running app (vshost32.exe in debug mode) and click on it, then turn on Show notifications in the action center, I can clearly see the balloon tip messages being added to the notifications, but never a balloon tip.
I assume this is a problem with Windows 10.
My NotifyIcon is VISIBLE
my_icon.ShowBalloonTip("Title", "Message", BalloonIcon.Info);
On my computer with Windows 10 version 1803, go to Settings > System > Notifications & actions, and turn on "Get notifications from apps and other senders".
The ballontips from my WPF app will show up.
Found the problem - was simple: Quiet Hours was turned on in the notification center and this was preventing the balloon tips.
Turn off Focus Assist. If you are using second screen, turn off "When I'm duplicating my display" option. My settings is like that:
I've fixed the problem by adding icon property. If this property isn't set, the baloontip won`t be shown. Here's example of my code:
var notify = new NotifyIcon();
notify.Visible = true;
notify.Icon = new System.Drawing.Icon(#"D:\Users\User\Desktop\some.ico");
int code = new Random().Next(1000, 9999);
notify.ShowBalloonTip(500, "code", $"{code}", ToolTipIcon.Info);
Neither of these solved my issue :(
But by accident I fixed it! My problem was I had my project configured for 32-bit on a 64-bit platform and for whatever reason they only show up when when I run the project for Any CPU (64-bit in this case)!!
Hopefully that helps some of you, it was a real mystery for me...
(I also posted this answer here because these are duplicate questions)
Change the Solution Configuration "Debug mode to Release mode" with X64 or X32 Solution platform. It will start work.
public static NotifyIcon trayIcon;
trayIcon = new NotifyIcon();
trayIcon.Icon = new Icon("Images/Test.ico");
trayIcon.Visible = true; trayIcon.Text=Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName);
ContextMenu contextMenu1 = new ContextMenu();
contextMenu1.MenuItems.Add("Menu2", Menu2_Event);
contextMenu1.MenuItems.Add("Menu3", Menu3_event);
contextMenu1.MenuItems.Add("Exit", Close_Click);
trayIcon.ContextMenu = contextMenu1;
trayIcon.BalloonTipText = "Hi Test";
trayIcon.ShowBalloonTip(1000);
Just for reference, as #rmirabelle wrote in the question "My NotifyIcon is VISIBLE". This is actually important.
If the notification icon is not visible in the systray, the BalloonTips won't show up either.
Possible sources for invisibility are:
Visible property = false
No icon is set for the NotifyIcon object
Universal app does not allow to remove or disable the close button it seems. We can hide it by going full screen. But when moving cursor over it, brings title bar back. Is there any way to remove the close button?
Reason : I am working on screen time. After allowed time gets over, I want to block the screen. I should remove close button so that user cant get over my app.
Edit : Removing close button wont help completely. It is a part of work. I am just asking how to remove it.
In Windows 10 version 1703 (build 10.0.15063) and beyond, you can prevent the app from closing, using the SystemNavigationManagerPreview class.
Add this to your app manifest:
<Capabilities>
<rescap:Capability Name="confirmAppClose" />
</Capabilities
You need to have the rescap namespace at the Package element:
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
In the constructor of your main form, add:
var sysNavMgr = SystemNavigationManagerPreview.GetForCurrentView();
sysNavMgr.CloseRequested += OnCloseRequested;
OnCloseRequested can be implemented as follows:
private void OnCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
{
var deferral = e.GetDeferral();
e.Handled = true;
deferral.Complete();
}
With current released API, we are able to customize the color of these three buttons in title bar. But there is no property or method could be used to disable or remove these buttons.
In UWP, we can use ApplicationView.TitleBar | titleBar property to get the title bar like following:
ApplicationViewTitleBar titleBar = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar;
This property's type is ApplicationViewTitleBar. It only has several properties that can customize the button's color like:
titleBar.ButtonBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonForegroundColor = Windows.UI.Colors.White;
titleBar.ButtonHoverBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonHoverForegroundColor = Windows.UI.Colors.White;
titleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonInactiveForegroundColor = Windows.UI.Colors.White;
titleBar.ButtonPressedBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonPressedForegroundColor = Windows.UI.Colors.White;
Using these properties may make the close button invisible like:
However this won't actually hide these buttons. Users can still minimize or maximize the app and when the pointer is over the top right corner, they will still see the close button.
From Windows 8.1, if we want users to use only an application and do nothing else including closing the application, we can use Kiosk Mode. For more info, please see Enable Kiosk Mode in Windows 8.1 and Set up a kiosk on Windows 10 Pro, Enterprise, or Education. However this won't meet your requirement as you want to block the screen after allowed time gets over.
So UWP may not be the best choice for your requirement. You may try to implement it with classic desktop apps.
in App.Xaml.cs add this code :
// Collapse Title bar
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
Window.Current.SetTitleBar(null);
ApplicationView view = ApplicationView.GetForCurrentView();
view.TryEnterFullScreenMode();
C++ Version
// COLLAPSE THE TITLE BAR
Windows::ApplicationModel::Core::CoreApplication::GetCurrentView()->TitleBar->ExtendViewIntoTitleBar = true;
Window::Current->SetTitleBar(nullptr);
Windows::UI::ViewManagement::ApplicationView^ view = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
view->TryEnterFullScreenMode();
I'm setting the HKEY_CLASSES_ROOT\.ext\DefaultIcon to the path of my application and it works...for the most part.
// create the HKEY_CLASSES_ROOT\extension
RegistryKey k = Registry.ClassesRoot.CreateSubKey(".spr");
k.SetValue("", "SpaceRead"); // set the default to the program name
RegistryKey di = k.CreateSubKey("DefaultIcon");
di.SetValue("", Application.ExecutablePath);
di.Close();
k.Close();
My problem is that my icon is showing up 'inside a white page' instead of only showing my icon (and losing the page)
here's an example. The first icon is mine, the second one is what I want.
My .ico file has all the standard resolutions in it, but I don't think that's the problem since even small icon views show the 'page' background.
Is there some custom icon rendering going on that I don't know about?
BTW, this is a Windows 7 x64 machine.
I have an application in .net where I want it to always open without any manual interaction.
In this application I have used NotifyIcon so it always start in Taskbar tray but the notification icon will only show if I manually open that .exe.
so what I did is just added it in Autostart application registry entry with the help of below:
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rkApp.SetValue("MyApp", Application.ExecutablePath.ToString());
So this works fine and on reboot it successfully open it in system taskbar Process list but not as a taskbar tray icon.
Can anyone help me.?
I'm working with NotifyIcon too, and there are some issues with that. First, you need to set an Icon for the NotifyIcon and be sure you didn't set it's Visibility to anything but Visibility.Visible.
Then, NotifyIcon is just a wrapper around the NotifyIcon Windows API, and there's a known issue that it cannot always be created. Therefore, when you initialize the NotifyIcon it might throw an Exception because of an error in Windows (the WinApi returns false if it couldn't be created, and in the source code they throw an Exception there). When it does that, you can just recreate the NotifyIcon in a loop until it can be created.
I also saw an issue sometime when the NotifyIcon was not created in the app.xaml as a XAML object but in code, since then I always create it in XAML instead of in code. Also now I imported the whole NotifyIcon project from CodeProject to be able to debug it's interior. So now I'm creating it in this way:
<NotifyIcon1:NotifyIcon x:Key="NotifyIcon" x:Name="notifyicon"
ToolTipText="" Visibility="Visible" IconSource="/Images/Icons/bulb.ico"/>
This should throw an Exception if the icon cannot be created in this part of the code in the NotifyIcon library:
/// <summary>
/// Creates the taskbar icon. This message is invoked during initialization,
/// if the taskbar is restarted, and whenever the icon is displayed.
/// </summary>
private void CreateTaskbarIcon()
{
lock (this)
{
if (!IsTaskbarIconCreated)
{
const IconDataMembers members = IconDataMembers.Message
| IconDataMembers.Icon
| IconDataMembers.Tip;
//write initial configuration
var status = Util.WriteIconData(ref iconData, NotifyCommand.Add, members);
if (!status)
{
throw new Win32Exception("Could not create icon data");
}
//set to most recent version
SetVersion();
messageSink.Version = (NotifyIconVersion) iconData.VersionOrTimeout;
IsTaskbarIconCreated = true;
}
}
}
Either you directly edit the code to your needs or you try to recreate the notifyicon when there's an Exception.
I guess this will be the problem because it was the same for us, as sometimes after startup Windows is not yet ready to create the icon. Should there be another issue for you, please post the code you use to create the notifyicon and the system (XP? 64bit?) on which the problem arises.
There was an issue with the way I was using the icon.
There might be an issue with the "icon" file we use in NotifyIcon so I just fixed that issue just by replacing the way
// START: Creating a red graphic instead of image
Bitmap b = new Bitmap(16, 16);
Graphics g = Graphics.FromImage(b);
g.Clear(Color.Transparent);
SolidBrush sb = new SolidBrush(Color.Red);
g.FillEllipse(sb, 0, 0, 16, 16);
// END: Creating a red graphic instead of image
m_notifyicon.Visible = true;
m_notifyicon.Icon = Icon.FromHandle(b.GetHicon());
Now I am able to see the Red icon even after rebooting my computer.