I made a Windows Forms application, I want to use it as a widget on the desktop, but I can not fix it so that it is always behind all open processes (that is, on the desktop). I read foreign sites, the methods described there do not work, maybe there is some modern version to do this?
- oneAnd can you describe the methods that have been tried on you somehow so that you will not be offered the same in the second round ... well, or maybe even attach, code / settings ... maybe you just missed something? - Mikhail Rebrov
|
3 answers
In the Activated form event, we write:
private void Form1_Activated(object sender, EventArgs e) { this.SendToBack(); } This will permanently place the form below all others.
To keep the form permanently on the desktop, disable the option to minimize it:
this.MinimizeBox = false; - An interesting option, you will have to try. for a good effect, the border is also removed so that the cap of the form does not loom before your eyes - rdorn
- Cool, but not that. The method works if to go to the slave table to minimize the entire window separately, but I click in the lower right corner of the screen, which minimizes all windows, including the window with the widget. Can I somehow prevent the application from collapsing? - Stephanzion2
|
This is how you can create a form that the user cannot place on top of others. However, it appears from above itself and will go deep as it moves to other applications.
class Form1 : Form { protected override CreateParams CreateParams { get { const int WS_EX_NOACTIVATE = 0x08000000, WS_EX_APPWINDOW = 0x00040000; var cp = base.CreateParams; cp.ExStyle = (cp.ExStyle & ~WS_EX_APPWINDOW) | WS_EX_NOACTIVATE; return cp; } } } |
The way that the form is always at the back level and does not go on top of other windows:
private void Form1_Click(object sender, EventArgs e) { this.SendToBack(); } private void Form1_Shown(object sender, EventArgs e) { this.SendToBack(); } private void Form1_Activated(object sender, EventArgs e) { this.SendToBack(); } However, when you click "minimize all windows" disappears.
|