最做了类似任务日程安排的桌面便签小程序,主要是要窗口一直显示在桌面上即使按"显示桌面"也不会被隐藏.
首先需要添加引用
using System.Runtime.InteropServices;
导入dll
[DllImport("user32.dll", EntryPoint = "SetParent")]
public static extern int SetParent(int hWndChild, int hWndNewParent);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
public static extern int FindWindow(string lpClassName, string lpWindowName);
在load事件中加入
SetParent(this.Handle.ToInt32(), FindWindow("Progman", "Program Manager"));
Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(this);