Close dialog when click outside of it - c#

I'm working with GTK# and I have a dialog that I want to close when user clicks out of it. Very similar to the way a combobox works: when the dropdown list is expanded and you click out of it, it closes.
There are similar questions to this problem, but for other languages =( and I can't figure out a way to relate those answers to my problem.
Thanks in advance.

At first guess, you should connect to the notify::has-toplevel-focus signal of your dialog, and close it when the has-toplevel-focus property becomes false.

Related

Graphical Failure with InputBox and MessageBox

In my WPF-project im popping up an Microsoft.VisualBasic.Interaction.InputBox to get a filename from the user. If this filename is already in use im popping up a System.Windows.MessageBox to show the hint, that its already in use. After i hit OK on the MessageBox and it closed, i still see parts of the InputBox mixed up with some elements(a button) from my main programm.
Why does this happen?
Thanks in advance
You generally don't want to use any Windows.Forms based controls in a WPF application, it's just somehow against the point. You can easily create your own input box though, with the advantage of total control over behavior and style. This link stackoverflow describes your problem very nicely.

Close a Popup Dialog Box with Selenium Webdriver C#

I'm writing a test using C# for our website. When a record is deleted online, a popup dialog box appears that basically asks the user to confirm. Usually I can just inspect an element by right-clicking, but when this dialog box is up, nothing can be selected, in or out of the dialog box. When I tried using the IDE to see how it would handle the dialog popup, it gave this command:
Assert.IsTrue(Regex.IsMatch(CloseAlertAndGetItsText(), "^Are you sure you want to delete this batch[\\s\\S](\n|\r\n)All claims in this batch will be permanently deleted\\.(\n|\r\n)This action cannot be undone\\.$"));
That didn't work, so I also tried:
CloseAlertAndGetItsText();
But that didn't work either.
The box has two buttons, OK and cancel, and the OK button is already highlighted, so if there is a way to just do something like this:
driver.sendKeys(return);
But driver doesn't have a sendKeys command to call on its own.
driver.SwitchTo().Alert().Accept();
That should be able to handle the type of dialog box you're describing. I've been able to use it for any dialog I've had to come across, so it works pretty well. I've also read about using IAlert but since I've never needed to use it, I have no idea how well it works, but if my solution doesn't work for you, maybe look into that.

C# .NET & Messageboxes the user cant ignore

So I have failed to find anything that works...
But what I want a messagebox that wont allow the user to do ANYTHING untill he or she has clicked ok.
So if they were to say...Click outside the message box. it would beep and blink at them untill ok is clicked.
Is this done through the properties on the left hand side for the main parent form? Or is this all done through programming?
Thanks everyone.
Show the window using the .ShowDialog() method.
This question has been answered in this post, but in a nutshell, you need to set the MessageBoxOwner property to the main UI window.

Change default arrangement of Save and Cancel buttons in SaveFileDialog

I m coding in c# and I want to change the default arrangement of 'Save' and 'Cancel' buttons in SaveFileDialog. The default arrangement is that the 'Save' button is above the 'Cancel' button.
What I want is to place 'Cancel' button on the right hand side of the 'Save' button.
I searched over the web and found that the text on these buttons can be changed(to which the answer was on stackoverflow itself) and nothing found on changing their arrangements (locations).
Please give me a solution if any of you have experienced this so far....
thank you
Please don't do this.
The user is used to where these buttons appear. If you try to change their layout then you will just make you app feel wrong.
If you have to do this then should make sure you use the legacy file dialogs (which will make your dialogs look even more odd on Vista/7). Use the lpfnHook field in the OPENFILENAME struct to obtain hooks in to the dialog procedure. Respond to the CDN_INITDONE notification and move the buttons around with MoveWindow or SetWindowPos. You'll have to hunt for the button window handles.
But really, please don't do this, you'll just make your app worse.
That rings a bell. When you have the code to change the text of the button then you have the handle of the button window. Which you can then use when you pinvoke GetWindowRect and MoveWindow to move the button somewhere else. Visit pinvoke.net for the declarations.
Beware that the dialog changed in every Windows version. The next one might well break your program. Your customer is not going to be disappointed when you don't do this.

Dialog Box loses focus in Windows XP

I am having a strange problem. I have a C# .NET 2.0 application and a context menu. When you right click on the application, the context menu shows up and one of the items on the menu is Options. When you click options, I have an OptionsDialog form that shows up (using ShowDialog() method). The problem is, on Windows XP, the focus keeps going away. If I click on the options form, its gains focus for a second, but then loses it again! I have tried everything. On the Deactivate event, I call this.Focus() but that doesn't seem to make a difference. I also tried making the window topmost, but still doesn't work.
Another wierd thing is that this problem only seems to happen on XP. I tried it with Vista and Windows 7 and it works perfect. XP is doing something wierd though. Anyone have any thoughts on how to solve this?
A person here seems to have the same problem: http://forums.devshed.com/c-programming-42/c-form-won-t-focus-on-control-535596.html
Is that anything like what's going wrong with you? If you have a default button or a control that is the first tabStop value that also happens to be disabled when the form starts up, it could be the cause of the problem.
Check any disabled controls on the form, and make sure the default button and the first tab stop controls are both enabled. (Hint: Default button should usually be 'Cancel' on a modal form, and it should always be enabled.)
If you find out which window has the focus afterwards, maybe it gives you a clue what's going on.
This little demo app from 1997 will help you: http://www.microsoft.com/msj/0397/Win32/Win320397.aspx

Categories

Resources