Change close button tooltip - c#

i have to change my form close button tooltip from "Close" to "Other text", does anyone know how can i access that button, so i can perform the switch?

This is almost certainly impossible.
You could hide the form's title bar and re-create it from scratch, but this is going to take a lot of effort.
Alternatively, you could use a third-party library to give your app an Office-style ribbon UI, making sure that library gives you the ability to change title bar button tooltips.
Edit: You could hide the form's title bar close button, put an ordinary button on the form, put the word "Close" on the button, and set the button's tooltip to whatever you wanted.
(I don't think any of these suggestions are practical...)

Related

Make a cutom popup with darkened background in uwp with XAML c#

I have made a few buttons for my admin page, for example-delete user, change info etc.. I want the window to darken once I click on one of the buttons, and then I want my own custom popup to appear(it will act like a small window), where I could, for example, enter values-the name of the user I want to delete for instance and then if I want to exit the popup, I will just have to click on the darkened background.
Technically, I could just achieve the same thing by making multiple windows and referencing to them on the click of each button, however, I think it will look unprofessional.
Does anyone know how can I achieve what I have just written? My biggest problem is with even creating a custom popup because so far I have only used the default dialog box.
I will be very thankful for any help.
I want my own custom popup to appear(it will act like a small window)
Did you tried to use ContentDialog Class ?
if I want to exit the popup, I will just have to click on the darkened background.
Because of ContentDialogs are Modal dialog to achieve this you should use PopUp Class instead of ContentDialog.
Something like below source for XAML page then set its IsOpen=true; in code behind to show popup to user:
<Popup x:Name="popupDeleteUser"
IsLightDismissEnabled="True"
IsOpen="false">
<Grid>
Put your controls here
</Grid>
</Popup>
I want the window to darken once I click on one of the buttons
you can use Blur animation

ToolStripButton have different behavior on showing Modal Less Dialog

I have a main window and a toolstrip on it with different command buttons. In these commands, I've a 'Print' button too (See Below). When I click on 'Print' button , I need to show sub-form as Modal Less Dialog. Because, I've few option on sub-form. If user select them then he/she can interact with Main Form too.
Meanwhile, on show() method I disable all controls on Main Form (see below) as it will be done if I use ShowDialog() method to show sub-form. When I click the Print Button, it's color changed which shows it is focused/selected.
On click sub-form is show like below pic.
Logically, it should return to previous mode when I close sub-form. But, even sub-form is showing... that 'Print' button on Main-Form is still focused/selected. When I close the sub-form, that 'Print' Button still focused/selected like below.
What Event/ Property needs to be changed to make this 'Print' Button to show like as it is in initial state.
I've tried Invalidate(), change BackColor but didn't meet the requirement yet. Any Guidelines ?
Set the CheckOnClick property of your button to false if you don't want it to appear "selected" at all, otherwise toggle the CheckState property on the button when the subform is closed.
Well, Selected Property in ToolStripButton is read only. Anyone, needs to clear the selection of toolstrip buttons can use below method which is invoked via reflections.
MethodInfo method = typeof(ToolStrip).GetMethod("ClearAllSelections", BindingFlags.NonPublic | BindingFlags.Instance);
method.Invoke(yourToolStripName, null);
This comes from : How to Deselect ToolStripItems
Happy Programming.

How do I make a custom modal popup window in WPF and have it return a value?

I'm taking a whack at WPF and trying to learn as I go. I'd appreciate any advice offered.
I've got a Window that has a Page attached to it (through a Frame on the Window). When you press a button on the Page, I want a custom window to pop up to present several custom options and be displayed in a manner of my choosing (I'm thinking right now I want it to be a grid but that may change as I go on). When selected, the modal window will disappear and return to the calling method (button press from the Page) the value of the selected choice.
I don't want the standard windows dialog box with the options of yes, no, okay, cancel, or anything like that. This is truly just a custom popup that returns a value to the caller when the user makes their selection on the popup.
Create a new Window subclass, which you can layout however you like. Then in your button click event handler, display it modally using myModalWindow.ShowDialog();. You can then have a property on the window class which you can access after it closes in order to access result data, i.e.:
myModalWindow.ShowDialog();
var data = myModalWindow.SomeResultProperty;
If you really want to have something returned from a method, I suppose you could create your own public method on your window class which internally calls ShowDialog() and then returns a value.

Interacting with a form without it activating

I'm trying to implement code-completion popup window in my project. The window is derived from Form. It contains two controls: custom list derived from UserControl (it shows completion possibilities with icons) and a VScrollBar.
When the popup appears, it doesn't steal focus from the editor (form's ShowWithoutActivation is overriden to return true) and the editor sends certain keystrokes to the popup so the user can interact with it using keyboard. So far it works like a charm.
The problem is, I want to allow the user to use mouse as well. But, when the user clicks into the popup window, its form activates and steals focus from the editor. I can react to this by giving the focus back to the editor, I have even set up a Timer to do this regularly, but apart from being a poor solution, the title bar of the editor always flickers when this happens (when the popup is clicked).
Is there any way to interact with the popup form (using mouse) that doesn't make the form activate?
The ShowWithoutActivation's documentation reads: "If your non-activated window needs to use UI controls, you should consider using the ToolStrip controls, such as ToolStripDropDown. These controls are windowless, and will not cause a window to activate when they are selected." This seems exactly like the thing I need, but I want to use a custom control and a scroll bar.
The same problem would be with a tooltip that shows these two arrows to switch method overloads (known from VS) - the whole form would use no controls at all (only render the text and the arrows), but when clicked, it should not activate. The problem could be summarized up to "How to create a form that would never activate, but allow the user to interact with certail controls inside?".
Thanks.
Just override the onFocus event...
public partial class myListBox:ListBox
{
protected override void OnGotFocus(EventArgs e)
{
}
}
The issue is that you're using a Form for this rather than building some custom control that doesn't run in its' own UI thread like a Form does.
The flashing and highlighting is handled by windows whenever a Form activates/focuses. The only thing I cay think of is to make your Form borderless and create/draw/handle your own title bar that doesn't flash when focused.
OK, I may have found a solution. The key seems to be WM_MOUSEACTIVATE message, which the popup form must intercept and respond with MA_NOACTIVATE. But there's a catch - the control derived from UserControl still grabs focus when clicked (the scrollbar luckily doesn't anymore). The problem seems to be in the UserControl.OnMouseDown method, which internally puts focus on the control. There are some ways to fix this:
derive the control from Control instead of UserControl
override the OnMouseDown method and not call base.OnMouseDown there
make the control's CanFocus property return false, but this seems not possible, because that means to make the control either not visible or not enabled, which is both undesirable
The last case when the popup form steals focus seems to be when its resizing (using mouse) ends. But it is safe here to call Owner.Activate() as a result to Activated event...

Show/Hide ContextMenuStrip outside the form

I'm creating a simple clipboard manager application. It monitors the content of a clipboard. When a change occurs (throu the win api message loop) it fires up a method to capture current content of clipboard and creates new object called clipboarditem. Next its building a ContextMeuStrip which consits of several clipboarditems created previously. The items menu is accessed by a hotkey. It shows up this menu on certain position of the screen itemsMenu.Show(caretPosition);, with .Focus(), I want it to make it disappear after it loses the focus (eg. clicking somehwere else on the screen or switch applications by alt-tab). Found an event OnLoseFocus but I dont think its working properly because the menu wont even show up.
How to make ContextMenuStrip disappear after loosing focus and how to prevent from showing ContextMenuStrip in taskabr ?
Sorry for my language skills :)
From a very quick look at the events that ContextMenuStrip contains, have you tried the "MouseCaptureChanged" event? It may help you with the losing focus issue.
For the showing in the taskbar issue, have you set "ShowInTaskbar" to false on the form you have your ContextMenuStrip (if you have it on a form)?

Categories