예제 #1
0
        private void timerCheckPosition_Tick(object sender, EventArgs e)
        {
            ////// 获取当前的焦点窗口,如果不是绑定的Excel窗口,就隐藏,否则显示
            //IntPtr handle = ZS.Common.Win32.API.GetFocus();
            //IntPtr parent = ZS.Common.Win32.API.GetParent(BindControl);
            //if (handle == BindControl || handle == parent)
            //{
            //	this.Visible = true;
            //}
            //else
            //{
            //	this.Visible = false;
            //	return;
            //}


            // 获取绑定窗口的位置
            ZS.Common.Win32.API.RECT rec = new ZS.Common.Win32.API.RECT();
            if (_propBindControl != IntPtr.Zero)
            {
                ZS.Common.Win32.API.GetWindowRect(_propBindControl, ref rec);
            }

            if (this.Location.X != rec.left || this.Location.Y != rec.top)
            {
                ReSet();
            }
        }
예제 #2
0
        private void Test_ShowCoverForm()
        {
            try
            {
                string windowKey = Globals.ThisAddIn.Application.ActiveWindow.Caption.ToString();

                IntPtr hwnd = ZS.Common.Win32.Window.FindWindow(new IntPtr(Globals.ThisAddIn.Application.ActiveWindow.Hwnd), windowKey);
                ZS.Common.Win32.API.RECT rec = new ZS.Common.Win32.API.RECT();
                if (hwnd != IntPtr.Zero)
                {
                    ZS.Common.Win32.API.GetWindowRect(hwnd, ref rec);
                }
                Controls.frmFocus frm = new Controls.frmFocus();
                frm.Display();
                if (rec.bottom != 0)
                {
                    frm.Location = new System.Drawing.Point(rec.left, rec.top);
                    frm.Size     = new System.Drawing.Size(rec.right - rec.left, rec.bottom - rec.top);
                }
            }
            catch (Exception ex)
            {
                WriteConsole("启动遮罩窗体异常:" + ex.Message + ex.StackTrace);
            }
        }
예제 #3
0
 /// <summary>
 /// 重新设定窗口的位置。
 /// 根据绑定的控件的位置与尺寸,重新设定遮罩窗体的位置与尺寸。
 /// </summary>
 private void SetFormPosition()
 {
     ZS.Common.Win32.API.RECT rec = new ZS.Common.Win32.API.RECT();
     // 通过API 获取窗口尺寸
     if (_propBindControl != IntPtr.Zero)
     {
         ZS.Common.Win32.API.GetWindowRect(_propBindControl, ref rec);
     }
     if (rec.bottom != 0)
     {
         this.Location = new System.Drawing.Point(rec.left, rec.top);
         this.Size     = new System.Drawing.Size(rec.right - rec.left, rec.bottom - rec.top);
         panelY.Height = this.Height - 28;
         panelX.Width  = this.Width - 22;
     }
 }