The dialog works as a color picker w/ a shot of the entire desktop as it's background and is instantiated from a form.
The dialog's Cursor property is set to a pipette (custom) cursor on load.
The region on the dialog where the parent form appears is set to transparent so current color at pixel location is reflected on the parent form.
On load, however, the cursor momentarily changes to a pipette cursor and then changes back to default, regardless.
I'm not sure what's happening. I already tried setting the pipette cursor again OnMouseHover, OnMouseMove, heck even OnPaint, on the dialog, but nothing works.
Try this one out in the Form load.
It worked for my Custom cursor (Controll for the Cursor was a Button)
System.IO.MemoryStream ms = new System.IO.MemoryStream(CustomCursorPath);
Controlname.Cursor = new Cursor(ms);
Related
I'm trying to place a transparent and borderless child (WinForm) form on top of another child (WinForm) form that is opaque, but I'd like to retain the ability to directly click on the transparent form. There are a few answers on the web regarding making a transparent form that can be clicked through, but I want to make one that I can click on.
I've found this answer, which shows that setting my transparent form's BackColor and TransparencyKey to something specific like Color.Red achieves the desired behavior. However based on this answer, it seems this behavior between certain Colors and TransparencyKey may actually be a long-running bug.
Ideally I don't want to rely on a bug to achieve a desired effect. What would be a more "appropriate" approach for making a clickable, transparent, and borderless (WinForm) form?
Update (Additional Context):
I'm basically creating a screen pixel previewer for color data extraction.
Overlay forms containing captured bitmap(s) of the screen area.
Another form that gives a visual indicator for the pixel area being previewed (small black box in the below snapshot). This form is placed above the bitmap forms. I have this form as transparent (to see through to the below bitmaps), but I still want to be able to click on it for event processing.
Without the TransparencyKey = BackColor = Color.Red trick, clicking within the small black box causes focus to move to the below bitmap form, which then covers up the small box form and the preview window showing the zoomed view. The purpose of the click is to capture the cursor position for additional processing. I can work around this by immediately giving focus back to the small box + preview forms, but that occasionally causes flicker.
When I set the main window's visibility to hidden, No icon is shown in taskbar, so I have no control over the window to show it again. I want for the application's icon to be visible even when I hide the window, and to show the window when I click it's button in the taskbar. (something like minimize behavior)
How can I achieve that using WPF and .Net 4.0 in C#?
Edit: I mean the icon in taskbar (usually in the left and middle of the horizontal taskbar) not the notifyicon in system tray.
So, based on "comments" section, what you are looking to do is minimize or hide a window but still show some windows or dialogues that the window opens. First if you want to keep your window in the task bar, you should minimize with:
this.WindowState = WindowState.Minimized
That can be called from anywhere within the form. As you mentioned, though, this will close hide any dialogues that have this window set as the parent. The key, then is to not use this window as the parent. Lets say your dialogues inherit from form. You want to use:
newWindow.Show();
I am guessing that you are calling "ShowDialog", which ties the window state to the parent window state. Try this out and hopefully it will help!
Edit
One more note: the same is actually true of MessageBoxes, but the way to control the parent form is with the first parameter of the MessageBox.Show() call. If you pass in a form as the first parameter, that will be the parent, otherwise the parent will not be set.
How to popup a child form when I click the button. I want to child winform to be in the centre of the screen and the whole background screen should be blurred. and a small close button should be visible in the right corner of the form. I have searched the web but found nothing.
Using Winforms.
Make a new windows form. it has a close button by default. Set it default position to center screen. Then on your button click.
Lets say your new form is Form2
Form2 frm = new Form2();
frm.ShowDialog();
it will not make the rest of screen blurred but user will not be able to do anything with it.
For blurry effect a workaround has been posted here
You can trigger event from click button like this
Form form1=new Form();
form1.show;
and after that to blurr the parent screen use opacity property of and increase or decrease it accord to your requirement.
you can also control the transparency of the child form using a timer and increase paacity with timer click it will make it more dynamic and interactive.
I have a winforms C# application that opens multiple dialog boxes. To suit the style of the application, I have removed the default title bars for each window and created my own (with control buttons and drag-to-move function).
The problem that now faces me is that without a titlebar, the user has no way of telling which window is the 'active' window when they are manually moved apart (so they are not overlapping).
In any windows application (that uses titlebars), when you try to navigate away from a dialog box back to the main program (without closing the dialog box) - it wont let you. The border of the dialog box flashes and you hear a windows error sound. Some kind of equivalent visual feedback would be great without needing to have the default titlebars - and tinting an entire window darker seems like it would do the trick nicely.
Something like this in pseudo-code, which would nicely tint the parent window whilst a dialog is open:
// tint window now
window.ShowDialog();
// un-tint window
I have tried to place a panel covering everything with colour set to 'transparent' (with the intention of later controlling the opacity of the panel) but the transparency does not seem to work. Any other ideas of accomplishing this? Or does anyone have a better suggestion to achieve the same level of visual feedback?
Summary:
Is there any way to tint an entire window, or overlay it with a colour? If not, could anyone suggest an alternate method of making the window appear 'inactive'?
I would suggest you to create a method in forms you want to disable:
void DisableForm()
{
//some fancy color
this.BackColor = System.Drawing.Color.Khaki;
//and disable all controls owned by form, just to be sure
foreach (var s in this.Controls)
{
((Control)s).Enabled = false;
}
}
and functions which enables back those forms of course.
edit.
also you can set visibility property of controls to false
A strange thing started to happen with our application. The mouse cursor used to change when you hover over the border of a view so that you know you can start to drag and resize that view. Suddenly the cursor no longer shows up and it's difficult to resize the views because of this.
Update: It was found that this only happens after we open up another view. The views that are in a docked pane can be resized BUT the cursor doesn't show up. The cursor does show up until I open that one particular view I was talking about earlier AND if I undock the view from its docked pane.
Anybody have any ideas why this might happen? Has this ever happened to you?
I figured it out. Turns out there was a "Mouse.OverrideCursor" variable that works globally for the application and it was set to override the cursor. Now this really means it is overridden and not changed when it would normally be changed like hovering over a horizontal or vertical resize border.
Solution: You have to set that global variable to null like this ...
Originally:
Mouse.OverrideCursor = Cursors.Arrow;
Now:
Mouse.OverrideCursor = null;