示例#1
0
文件: Form1.cs 项目: harlodsin/Hider
 protected override void WndProc(ref Message m)
 {
     switch (m.Msg)
     {
         case 0x0312:
             if (this.KeyRadio.Checked)
             {
                 if (m.WParam.ToString().Equals("1"))
                 {
                     IEnumerable<HwndInfo> infos = from h in this.HwndList where h.HWndName.ToLower().IndexOf(this.comboBox3.Text) >= 0 select h;
                     foreach (var i in infos)
                     {
                         bool show1 = W32api.ShowWindow(i.HWnd, 0);
                     }
                 }
                 else if (m.WParam.ToString().Equals("2"))
                 {
                     IEnumerable<HwndInfo> infos = from h in this.HwndList where h.HWndName.ToLower().IndexOf(this.comboBox3.Text) >= 0 select h;
                     foreach (var i in infos)
                     {
                         bool show1 = W32api.ShowWindow(i.HWnd, 5);
                     }
                 }
             }
             else
             {
                 if (m.WParam.ToString().Equals("1"))
                 {
                     HwndInfo info = new HwndInfo();
                     info.HWnd = W32api.GetForegroundWindow();
                     StringBuilder sb = new StringBuilder();
                     W32api.GetWindowTextW(info.HWnd, sb, sb.Capacity);
                     CurrentList.Add(info);
                     bool show1 = W32api.ShowWindow(info.HWnd, 0);
                 }
                 else if (m.WParam.ToString().Equals("2"))
                 {
                     foreach(var i in CurrentList){
                         bool show1 = W32api.ShowWindow(i.HWnd, 5);
                     }
                 }
             }
             break;
         default:
             break;
     }
     base.WndProc(ref m);
 }
示例#2
0
文件: Form1.cs 项目: harlodsin/Hider
 private void timer1_Tick(object sender, EventArgs e)
 {
     this.HwndList.Clear();
     W32api.EnumWindows(delegate(IntPtr hWnd, int LParam)
     {
         StringBuilder sb = new StringBuilder();
         W32api.GetWindowTextW(hWnd, sb, sb.Capacity);
         //下面的内容是用ArrayList来存放当前窗口信息的代码
         HwndInfo info = new HwndInfo { HWnd = hWnd, HWndName = sb.ToString()};
         this.HwndList.Add(info);
         return true;
     }, 0);
 }