コード例 #1
0
 /// <summary>
 ///     Makes this window the active window, moving it to the front of the Z-Order (bar topmost windows) and enabling full user interaction.
 /// </summary>
 public void Show()
 {
     try
     {
         WinApi.ShowWindow(Hwnd, 5);
         WinApi.WINDOWPLACEMENT placement = new WinApi.WINDOWPLACEMENT();
         WinApi.GetWindowPlacement(Hwnd, ref placement);
         //var style = WinApi.GetWindowLong(Hwnd, GWL_STYLE).ToInt64();
         //if ((style & Convert.ToInt64(WinApi.WsMinimize)) == WinApi.WsMinimize)
         //{
         //if ((style & Convert.ToInt64(WinApi.WsMaximize)) == WinApi.WsMaximize)
         if ((placement.showCmd == (3 & 6)) | (placement.showCmd == 3))
         {
             WinApi.ShowWindow(Hwnd, 3);
         }
         else
         {
             WinApi.ShowWindow(Hwnd, 1);
         }
         //}
         WinApi.SetForegroundWindow(Hwnd);
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Window not focused!\r\n" + ex);
     }
 }
コード例 #2
0
 /// <summary>
 /// Retrieves placement information about this window
 /// </summary>
 protected WinApi.WINDOWPLACEMENT GetWindowPlacement()
 {
     WinApi.WINDOWPLACEMENT wp = new WinApi.WINDOWPLACEMENT {
         length = Marshal.SizeOf(typeof(WinApi.WINDOWPLACEMENT))
     };
     WinApi.GetWindowPlacement(new HandleRef(this, Handle), ref wp);
     return(wp);
 }
コード例 #3
0
        private FormWindowState GetWindowState()
        {
            WinApi.WINDOWPLACEMENT wp = new WinApi.WINDOWPLACEMENT();
            if (WinApi.GetWindowPlacement(this.Handle, out wp))
            {
                if (wp.showCmd == (int)WinApi.ShowWindowCommands.Maximize)
                    return FormWindowState.Maximized;
                else if (wp.showCmd == (int)WinApi.ShowWindowCommands.Minimize)
                    return FormWindowState.Minimized;
                else if (wp.showCmd == (int)WinApi.ShowWindowCommands.Normal)
                    return FormWindowState.Normal;
            }

            return this.WindowState;
        }