c#让窗口停靠在桌面上

 

c#让窗口停靠在桌面上

标签: c#stringmanageruserdll任务
  1917人阅读  评论(0)  收藏  举报
  分类:
 
·Net(23) 

最做了类似任务日程安排的桌面便签小程序,主要是要窗口一直显示在桌面上即使按"显示桌面"也不会被隐藏.

首先需要添加引用

[csharp]  view plain  copy
 
  1. using System.Runtime.InteropServices;  


导入dll

[csharp]  view plain  copy
 
  1. [DllImport("user32.dll", EntryPoint = "SetParent")]  
  2. public static extern int SetParent(int hWndChild, int hWndNewParent);  
  3.   
  4. [DllImport("user32.dll", EntryPoint = "FindWindow")]  
  5. public static extern int FindWindow(string lpClassName, string lpWindowName);  


在load事件中加入

[csharp]  view plain  copy
 
  1. SetParent(this.Handle.ToInt32(), FindWindow("Progman""Program Manager"));  
  2. Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(this);  

猜你喜欢

转载自hypercube.iteye.com/blog/2304845