Answer the question
In order to leave comments, you need to log in
C# How to fix a form in the background (Like Gadget)?
Hello, I want to create something like a widget (gadget) on the desktop in C #,
but the question arose of how to fix the window on the desktop? So that it can not be raised above the rest of the windows
Answer the question
In order to leave comments, you need to log in
public partial class Form1 : Form
{
[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 SWP_NOACTIVATE = 0x0010;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SetWindowPos(Handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
private void Form1_Activated(object sender, EventArgs e)
{
SetWindowPos(Handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question