C#在桌面上定位窗口

可以说我在C#中有一个普通的窗口。 它没有边框样式,因此无法移动或resize等。我如何定位该窗口使其显示在与桌面或上面相同的级别?

像小部件或雨量计皮肤。 有任何想法吗?

如果我理解正确并且你想在桌面上绘图,基本上,这可能会有所帮助: http : //www.neowin.net/forum/lofiversion/index.php/t293883.html

[DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern IntPtr FindWindow( [MarshalAs(UnmanagedType.LPTStr)] string lpClassName, [MarshalAs(UnmanagedType.LPTStr)] string lpWindowName); [DllImport("user32.dll")] public static extern IntPtr SetParent( IntPtr hWndChild, // handle to window IntPtr hWndNewParent // new parent window ); IntPtr hwndf = this.Handle; IntPtr hwndParent = FindWindow("ProgMan", null); SetParent(hwndf,hwndParent); this.TopMost = false; 

这会将您的表单重新表现为桌面本身的子窗口。

经过多次阅读代码后,我不确定为什么他们使用FindWindow()寻找“ProgMan”而不是使用

 [DllImport("user32.dll")] static extern IntPtr GetDesktopWindow(); 

但到目前为止我自己都没试过。