Tooltip in c# form does not appear when switching computers - c#

Hi I am having a very strange problem. I have a form with multiple tooltips that appear when the mouse is over a specific control. So far I was developing the form on a Windows 7 machine and everything were going fine. Tonight I tested my executable on my other Windows 7 machine (same version and service pack) but none of the tooltips are working.
Does anybody have an idea what might be the problem? Bellow I am giving the code for one such Tooltip
ToolTip UrlNameInputBallonTip = new ToolTip();
private void CheckForUrl()
{
UrlNameInputBallonTip.IsBalloon = true;
if (IsValidHttpUri(UrlNameInput.Text) == false && IsValidHttpsUri(UrlNameInput.Text) == false)
{
UrlNameInputBallonTip.SetToolTip(UrlNameInput, "This is not a valid url!\r\nex. \"http://domain\"");
UrlNameInputBallonTip.Show("This is not a valid url!\r\nex. \"http://domain\"", UrlNameInput, UrlNameInput.Width / 2, UrlNameInput.Height, 5000);
}
else
{
UrlNameInputBallonTip.Hide(this);
}
}

Hi I was able to find the cause of the problem and I am reporting this for future reference. On the suspected machine the option to display balloon tips (arrow pointing to the control) was disabled. I am not sure why, perhaps some other app disable it at some point, but after enabling it through registry ti works fine now. Thanks for the help!

Related

C# NotifyIcon tooltip not showing (Windows 10) [duplicate]

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

Winform TopMost Property not working properly when instance is running from Sever

I have developed a COM based Windows Form application and deployed it on Windows server 2008 R2.
The process is that a user will open a different third party application installed on the same server from his browser and then for a particular operation the third party application will start instance of my application.
Everything works perfect except when instance of my application opens in the user's machine, it's not fully TopMost window. The taskbar of the user's machine gets semi displayed on the running application. Below is the code I am using and I have attached the image as well. can anyone please help me in resolving this issue.
private void frmCyberLab_Load(object sender, EventArgs e)
{
Module.cancelled = false;
this.FormBorderStyle = FormBorderStyle.Sizable;
this.TopLevel = true;
this.TopMost = true;
this.Location = new Point(0, 0);
this.Height = Screen.PrimaryScreen.Bounds.Size.Height;
this.Width = Screen.PrimaryScreen.Bounds.Size.Width;
// Some more code here not related to form's display property.
}
Edit- I even tried using FormBorderStyle = FormBorderStyle.None; as suggested in the comment but I am still facing this issue. can someone please tell me what could be the reason and how Can I solve it.
To solve this issue I followed this Artcle - http://www.codeproject.com/Articles/16618/How-To-Make-a-Windows-Form-App-Truly-Full-Screen-a and also had to drop the idea of using the borders in the form.

Start another application on top most in tablet mode

When I run another .exe from my application it starts in the background and does not show the application on top of the screen instead shows tablet mode home screen , it's working fine in normal desktop mode but when I run it in Windows 10 Tablet mode then it does not show on top it starts in the background.
I've used myWindow.TopMost = true; , but it does not work as intended in Windows 10 Tablet Mode.
Code used to start exe file
Process p = new Process();
p.StartInfo.RedirectStandardOutput= true;
p.RedirectStandardInput = true;
p = Process.Start("myApp.exe");
p.WaitForExit();
the exe I'm invoking(starting) is my own exe application(it's not system app), I'm running app on windows 10.
It's only not working on top in Tablet mode( and I'm targeting my application only for Tablets).
Any help is appreciated..!
As I faced a similar situation, (it is not tablet, or windows-10 related. Has similarities only by WPF and TopMost tags) I'll show you how I resolve it:
I would like to have the FilterWindow always TopMost (but only over my application, not over entire set of apps in my Operating System)
See my code. May it'll helps you.
private void OnFilter() {
var filterViewModel = ViewModelLocator.FilterViewModel;
/* ... */
var filterWindow = new FilterWindow {
DataContext = filterViewModel,
Owner = GetParentWindow()
};
filterWindow.ShowDialog();
SelectedIndex = 0;
}
private static Window GetParentWindow() {
Window parent = null;
var activeWindows = Application.Current.Windows.Cast<Window>().Where(item => (item).IsActive).ToList();
if (activeWindows.Any()) {
parent = activeWindows[activeWindows.Count - 1];
}
else {
foreach (var item in
Application.Current.Windows.Cast<object>().Where(item => item.GetType().Name == typeof(RibbonWindow).Name)) {
parent = item as Window;
}
}
return parent;
}
The magic is Owner = GetParentWindow().
Without setting the Owner the FilterWindow had a ridiculous behavior.
Hope it helps you. If no, I will remove the response. (it does not fit in a comment)
Moerfi's solution of using Owner = GetParentWindow() worked surperb, much thanks for this solution. It also solved another problem I had.
I am writing an application for Surface 3 that runs on Windows 10 Pro on tablet mode, whenever a MessageBox or custom dialog control box is closed, as opposed to going back to parent window, Win 10 goes to start menu.
As if once the dialog control is opened the parent window is being placed into background, so when dialog control is closed there is no active window for Win 10 to switch back.
Setting owner on child dialog control solved that problem. Thank you very much.

Odd visual behavior from ToolStripMenuItem

I've got a Drop Down Menu that is dynamically filled every time it opens, here is the logic that does it:
private void joysticksToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
_joysticks = _joystickWrapper.FindDevices(DeviceType.Joystick);
joysticksToolStripMenuItem.DropDownItems.Clear();
foreach (var di in _joysticks)
{
var item = new ToolStripMenuItem(di.ProductName);
item.Checked = di.InstanceGuid == _joystickWrapper.CurrentDeviceInfo.InstanceGuid;
joysticksToolStripMenuItem.DropDownItems.Add(item);
}
}
When I run the application this is what I see:
The check is in the wrong location and the blue area is too wide.
Any ideas on where to look to fix this? The entire menu is all System.Windows.Forms, no custom visual code in the entire application.
I tried on my current machine (Windows 10 Build 9926) and on my dev server (Server 2012R2) with the same results. I've also compiled this to the NET Framework 4.5 and 4.5.1
EDIT
For those interested, here is the git repo for this project:
https://github.com/adam8797/RovControl
I came across this exact same issue and was finally able to resolve it by setting the ImageScalingSize property of the MenuStrip to 16,16 (it had somehow been set to 32,32, possibly due to my editing of the form on a high DPI machine)
I see you adding items in Menu while its opening. Seems like the selected area and its width is already defined and its not reacting to the new data you inserted. What about trying to manually define width of Menu Item and see if that helps.

Show Windows Forms balloon tips

I have this code
if (IsValid(textBox.Text))
{
toolTip.Hide(textBox);
}
else
{
toolTip.Show("Please enter an valid text", textBox);
textBox.Select();
}
It work fine as normal tooltip, but when I set IsBallon to true on toolTip it stops showing at all.
This seems to be a known issue:
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/1b0b026f-90ea-4cd3-b372-45de2d60ca0c/
and
http://www.debugging.com/bug/20204
Try the solution suggested in the latter:
I'd use regedit to check the registry setting for which the key is as follows:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\EnableBalloonTips
If it's zero, they're disabled. You'd then need to change it to 1 and reboot the machine.
(EDIT: Adjusted the registry key after reading further in the linked page)

Categories