Show Windows Forms balloon tips - c#

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)

Related

Xamarin.Mac Secure Text Field to move the focus by inputting Enter key

I would like to move the focus by input enter key after entering a string into a secure text field, but I have no idea how to do it at all.
Do I define it as an Outlet? What do I do then?
I couldn't find anything on Google the following code in fragments only:
public override void ViewDidLoad()
{
base.ViewDidLoad();
textPassword.ShouldReturn = (NSSecureTextField) =>
{
textPassword.ResignFirstResponder();
return true;
};
}
Of course, it doesn't work. What do I need to do to make this work?
In order to do what you are trying to achieve you will want to go into your storyboard and right click on both your NSTextFields individually.
This will bring up a list of methods that can be utilised
see screenshot
Dragging action into your viewcontroller.h file within xcode will set up the action link for both textfields.
Now in order to link this to your Viewcontroller.cs youll need to add the methods you set up into your viewcontroller.See screenshot
The code you found on google was close however it seems in order to resignfirstresponder on mac you need to assign first responder to something else.
Looking at the screenshot above i've taken first responder from the emailtextfield(1) and given it to passwordtextfield(2) which seems to be similar to what your looking to do.
Let me know how you get on.
Rob

Keyboard not showing when being prompted by UITextField

In iOS 13.2, I'm noticing that my keyboard no longer shows up in my apps on the simulator and a real device. When I tap inside a UITextField, nothing happens but the cursor blinking inside the textfield. Is anyone else having this problem or know how to solve?
UPDATE
The problem originates from removing storyboard files and initiating a rootViewController programmatically
var windowScene = new UIWindowScene(session, connectionOptions);
Window = new UIWindow(windowScene);
Window.RootViewController = new ViewController();
Window.MakeKeyAndVisible();
After that, I just noticed the keyboard doesn't show again in a new project.
This looks like a bug when you try use a programatic approach to setting a rootViewController in the new SceneDelegate opposed to how we used to in AppDelegate.
I got around this by keeping the dumb storyboard which sets the rootViewController inside and keeping SceneDelegate.cs clean for the moment and my keyboard works again. Thanks for all your answers.
set textfiled delegate.
#IBOutlet weak var urlTextField: UITextField!
override func viewDidLoad() {
self.urlTextField.delegate = self // urlTextField it is your textfield outlet
}
If you delete this line of code, the keyboard does not appear, but if this exists, the keyboard does come up.
About simulator : You can check setting in iOS simulator firsrt .
Have a look at this screenshot ,be sure Use Hardware Keyboard not be selected . Or you can select it and unselect it again , then keyboard will show.
Restart app to check whether keyboard can be shown.

Tooltip in c# form does not appear when switching computers

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!

Binding height, width, etc to a variable

I don't know if I'm just not understanding what I've found so far, or if it really is too complex to apply to such a simple idea as it seems. I'm trying to bind a button's height and width to variables that are stored in user settings. I can't seem to get this to work, or rather I simply don't how to, as in what commands to use. The issue lies in not knowing what to put in the Binding field of the xaml. If anyone could point to a guide that involves just this, could explain what to do I would be very appreciative.
Edit: I've solved the problem of binding the variable, it now saves to the User setting file when it should. Now I'm having an issue with the value stored in user setting beig overwritten every time the program loads with the default value. I am running this through VS debug menu selection, so I suppose the issue could lie there, but I've tried publishing it and running and still getting the same results. Any ideas?
Assuming by 'User Settings' you mean the built-in Settings not a custom implementation:
See http://blogs.windowsclient.net/bragi/archive/2008/07/03/using-settings-in-wpf-or-how-to-store-retrieve-window-pos-and-loc.aspx for an example of this - essentially you want to set up TwoWay bindings to Properties.Settings.Default: note that you have to define the settings in advance using the Settings UI, and you have to call Properties.Settings.Default.Save() when the app exits to persist the settings.
I'm posting this answer so that hopefully somebody else can read it and avoid such a ridiculous problem. First off, as far as the initial question, Staurt answered it quite nicely. But my edit above brought up a new but related problem. I ended up fixing it on accident.
The whole purpose of this was that I have a slider bar that adjusts the size of a shortcut button dock. The slider worked, but as I said above it would reset itself every time I reloaded. The issue in this case was that I have the buttons set to resize as the slider moves, so I used the slider_ValueChanged event as you can see here:
private void iconSizeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
try
{
Properties.Settings.Default.iconHeight = Convert.ToInt32(iconSizeSlider.Value);
Properties.Settings.Default.iconWidth = Convert.ToInt32(iconSizeSlider.Value * 1.3);
Properties.Settings.Default.Save();
//iconWidth.Text = buttonWidth.ToString();
//ButtonRefresh();
}
catch (FormatException)
{
}
}
While trying to use the Run To Cursor part of VS2010, I got tired of having to F11 through a multitude of loading steps, so as a debugging tool I added a bool fullyInitialized flag. This solved the problem completely. Apparently (which I didn't realize before), when the slider was first initialized it considered the value to have changed, so when it ran through the ValueChanged method, it reset everything to default. So adding a simple conditional around the try-catch to check for the fullyInitialized flag solved everything. Hopefully this helps somebody else.

How to get selected text from ANY window (using UI Automation) - C#

I have a small tray application which registers a system-wide hotkey. When the user selects a text anywhere in any application and presses this hotkey I want to be able to capture the selected text. I'm currently doing this using AutomationElements:
//Using FocusedElement (since the focused element should be the control with the selected text?)
AutomationElement ae = AutomationElement.FocusedElement;
AutomationElement txtElement = ae.FindFirst(TreeScope.Subtree,Condition.TrueCondition);
if(txtElement == null)
return;
TextPattern tp;
try
{
tp = txtElement.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
}
catch(Exception ex)
{
return;
}
TextPatternRange[] trs;
if (tp.SupportedTextSelection == SupportedTextSelection.None)
{
return;
}
else
{
trs = tp.GetSelection();
string selectedText = trs[0].GetText(-1);
MessageBox.Show(selectedText );
}
This works for some apps (such as notepad, visual studios edit boxes and such) but not for all (such as Word, FireFox, Chrome, and so on.)
Anyone here with any ideas of how to be able to retreive the selected text in ANY application?
Unfortunately, there's no way to get the selected text from any arbitrary application. UI Automation works if the application supports UIA TextPattern; unfortunately, most do not. I wrote an application that tried to do this, and had a bunch of fallbacks.
I tried (pretty much in order):
UIA.TextPattern
Internet Explorer-specific (this had different implementations for IE 6,7,8,9)
Adobe Reader-specific
Clipboard
This covered 80-90% of the applications out there, but there were quite a few that still failed.
Note that restoring the clipboard has problems of its own; some applications (Office, etc.) put vendor-specific information into the clipboard that can have pointers into internal data; when you put your own info on the clipboard, the internal data gets released, and when you put the old data back, the clipboard now points to freed data, resulting in crashes. You could work around this somewhat by only saving/restoring known clipboard formats, but again, that results in odd behavior in that apps behave "wrong" instead of crashing.
UIA technology does not supported by all applications, you can try to use MSAA in some cases (like FF, Chrome, etc.) but you still will get many problems.
The best way is to save current clipboard text, send "CTRL + C" keypress message via SendMessage WinAPI function, get clipboard text, and restore initial clipboard text as Rick said.
Is it possible to look at the clipboard and make your hotkey: CTRL+C ?
You won't be able to read selected text from any application. For example some PDF files have protected content that disallows copies.

Categories