I want to display a very small image on the top left corner of the windows desktop, it will be a picture of a small note and when you mouse over it, the window will show.
How can I do this in C#?
There should be no borders or regular window graphics
The image will be partially transparent
When a mouse over event occurs a window will display
The image will always overlay other windows
Thanks
I'll try to point you to the right direction for each of those requirements, you can do more research on how to exactly achieve each one using google or stackoverflow.com
You need to create a widows form, and add the image as the background of the form, or add an image control to the form.
after you have that, you can use the following to get your desired effects.
No Border
Set form's FormBoarderStyle propery to None
Transparency
Set Opacity property of the Form to something less than 100%
Mouse over
Use MouseHover or MouseEnter events of the form
Overlay other windows
Set TopMost property of the form to true.
Related
I have a Winform I want to resize. Not after launching; I want to resize it in the designer by dragging the edges.
I am aware that I can change the size manually in the form properties. This is not what I want to do. I want to quickly size the default size of the form with my mouse.
The problem appears to be that I cannot grab the edges of the form for some reason. I repeat, this is NOT DURING RUNTIME. It is not that I have disabled/enabled Autosize/Resizing.
It's almost like the edge grabs are a single pixel wide and I just can't hit it. I don't know. I've looked for accessibility settings. The last thing I want to do is reinstall MSVS. It's just maddening.
I've attached a photo. The little boxes on the bottom, right, and bottom-right corner are my targets.
you can try to click the form title before resizing. I think you may have a panel (or any container control) which is full docked in the form, that's why when you click the form body, you selected the panel instead of the form.
Another issue that I encountered was the windows font size was set to 120% (or more), so go to windows display setting and set the font size to 100%.
INTRODUCTION
Using C# or VB.NET. I'm trying to make a form's background transparent; this form will be overlaped to other window, it will be a top-most window, so the transparent form (and its controls) must have the ability that they must not receive focus and they must can be clicked trough, this means if for example I perform a left-click on the transparent background, then the window on background of that (in the Z-order window) is the window that must receive the click instead.
Notes:
For avoiding the focus I'm overriding the CreateParams property as explained here.
For making my form transparent, I'm calling Win32 DwmExtendFrameIntoClientArea function and also using SharpDX library as explained here. But I think this really doesn't matter with the question itself.
PROBLEM
I'll show a demostration of what I mean using images. Here below is a image of a form (with no transparency, just to simplify understanding) overlapped to a window of a text editor program; note that my form doesn't receive focus. Well, the problem is when I do click on the form's background (or one of its controls) the window on background (the text editor window) still have focus but it can't receive the click.
Here is the same image of above but with a transparent form:
RESEARCH
I'm not really sure about what to investigate, so I'm going blind trying to find something useful in a trial-and-error stage by overriding the Window procedure (WndProc) of the transparent form to test related windows messages, like WM_NCHITEST or WM_MOUSEACTIVATE message as said here:
Windows form with a transparent background that cannot be clicked through
Make a form not focusable in C#
How do I create an "unfocusable" form in C#?
You can do this by sending click (mouse up & mouse down) messages to the window underneath the transparent window using WinAPI.
PostMessageA
You'll need to find the window underneath the point you require.
WindowFromPoint
You'll have to translate the position of the click events accordingly since messages are processed based on relative window position, not absolute screen position.
I actually did this quite successfully to automatically play a facebook game many years ago.
Check the RAD designer in Visual Studio.
Is the label docked to fill?
Where is the main form clickable?
The transparent color is click-though in the main parent, however, components will still retain clicks.
I have a UserControl that is basically a ViewBox inside a Grid with a Border. The ViewBox has a background image and I blit various little icons onto the image. The icons are nothing more than pixels painted onto the background image. In code-behind I can detect when the mouse stays within the bounds of on one of these icons for more then 500ms. I call this a 'hover event'.
When I detect a hover event, I need to pop up something that shows details unique to the object represented by the icon. These details are not just text, there could be images of small graphs, so I think the popup needs to contain a StackPanel. I would like it to pop up, via some slick animation, at a location I specify near the location where the pointer is hovering.
Can someone please show me how to 1) create a popup containing a StackPanel at any given location in the ViewBox and (optionally) 2) have the popup use some slick animation when it appears?
Simple question, but I didn't know what's the keywords to Google.
Suppose we want to adjust the height of the taskbar on Windows. When u place the mouse cursor at the edge of it, the cursor will change to an up and down arrow meaning that the taskbar is resizable.
How do I get that cursor to come out in C#?
Is there a control for it? Or do I have to check if the mouse is on the edge of the control, if it is change cursor. On click resize according to the difference?
You would put a splitter control onto the form, set it to horizontal, then put the control you want to be sizeable (taskbar, whatever) inside the splitter, go into the dock settings and dock it to all sides.
Ok, I have googled, but maybe I put my search in weirdly. :/
I have a VB.NET WinForms application. I have the anchor properties set for all the controls so that it will resize all the controls to look decent when the form is maximized. (Haven't gotten around to manual resizing yet however).
Anyway, the problem:
I go to set the same properties for a button (testing with a single button for now) on the main GUI form/picture. When I go to run the program via F5, it looks decent. But when I maximize the form, the entire button covers up more than it should.
I've taken screenshots of the form so you can see a visual of what I'm talking about. :/
Before: http://zack.scudstorm.com/before.png
After: http://zack.scudstorm.com/after.png
What other propert(y|ies) do I need to set for the buttons to show up correctly? :/ (The buttons go over the boxes that say, for example, "1-1", "2-3", etc.
Thanks,
-Zack
Seems like you have anchored top-left and bottom-right when what you want is just top-left.
Edit: If it's just an image that does not change when the winform changes, then don't anchor your buttons at all. Just put them where they go. If you are scaling the image, then I would either detect the clicks on the image and do the scaling math or do the scaling math and set my buttons in code in the Form.OnResize event.
As it appears that your goal is just to be able to handle clicks on the "computers"...
One option that can be useful for this sort of task is to create an "overlay" bitmap (not displayed, but which is the exact same size as your source bitmap) which uses different colors to represent all the clickable regions. (e.g. (R=0,G=0,B=0) for computer 0, (0,0,1) for computer 1, etc)
You could even generate this bitmap somewhat automatically without too much trouble (If you have a mode where you can click the top left and then bottom right corners of the image to define a new region)
When the mouse is clicked, you can check the pixel at the scaled coordinates of the mouse position in the overlay and determine what their click corresponds to. This can be a lot easier than creating loads of controls, and makes it a lot easier to have clickable regions that aren't rectangular.