public static void ActivateWindowNoFocus(IntPtr hWnd) { SWP flags = SWP.NOACTIVATE | SWP.SHOWWINDOW | SWP.NOSIZE | SWP.NOMOVE; NativeMethods.SetWindowPos(hWnd, (IntPtr)(-1), 0, 0, 0, 0, flags); NativeMethods.SetWindowPos(hWnd, (IntPtr)(-2), 0, 0, 0, 0, flags); }
public static extern bool SetWindowPos([In()] IntPtr hWnd, [In()][Optional()] HWND hWndInsertAfter, [In()] int X, [In()] int Y, [In()] int cx, [In()] int cy, [In()] SWP uFlags);
public void UpdateThumbs(int offsetLevel) { CURSORINFO cursorInfo = new CURSORINFO(); cursorInfo.cbSize = Marshal.SizeOf(cursorInfo); User32.GetCursorInfo(out cursorInfo); this.IsCursorOnScreen = Options.AreaSrcBounds.Contains(cursorInfo.ptScreenPos.X, cursorInfo.ptScreenPos.Y); this.UpdateCursorState(); // DebugWindow.Instance.UpdateMessage($"Is3DActive: {this.Is3DActive}{Environment.NewLine}IsCursorOnScreen: {this.IsCursorOnScreen}{ Environment.NewLine}ScreenBounds: { Options.ScreenBounds}{Environment.NewLine}Mouse Position:{cursorInfo.ptScreenPos}"); if (this.ThumbLeft == null || this.ThumbRight == null) { return; } SbSComputedVariables scv = Options.ComputedVariables; this.OffsetLevel = offsetLevel; int screenWidth = Options.ScreenDestBounds.Width; int screenHeight = Options.ScreenDestBounds.Height; double scale = Options.ScreenScale; POINT screenSrcTopLeft = new POINT(Options.AreaSrcBounds.Left, Options.AreaSrcBounds.Top); POINT screenDestTopLeft = new POINT(Options.ScreenDestBounds.Left, Options.ScreenDestBounds.Top); int parallaxDecal = 2 * Options.ParallaxEffect * offsetLevel; this.Position = cursorInfo.ptScreenPos - screenSrcTopLeft; POINT offset = App.Current.Dispatcher.Invoke <POINT>(() => { POINT result = this.ThumbLeft.SetCursor(cursorInfo.hCursor); this.ThumbRight.SetCursor(cursorInfo.hCursor); return(result); }); SWP leftVisible = (this.Position.X + parallaxDecal + arrowStdSize.X < screenWidth) && (Options.ModeSbS || this.Position.Y + arrowStdSize.Y < screenHeight) ? SWP.SWP_SHOWWINDOW : SWP.SWP_HIDEWINDOW; SWP rightVisible = (this.Position.X - parallaxDecal > 0) ? SWP.SWP_SHOWWINDOW : SWP.SWP_HIDEWINDOW; User32.SetWindowPos(this.ThumbLeft.Handle, this.Owner?.ThumbLeft.Handle ?? IntPtr.Zero, scv.DestPositionX + (int)((this.Position.X + parallaxDecal - offset.X * scale) / scv.RatioX), scv.DestPositionY + (int)((this.Position.Y - offset.Y * scale) / scv.RatioY), (int)(32 * scale / scv.RatioX), (int)(32 * scale / scv.RatioY), SWP.SWP_ASYNCWINDOWPOS | leftVisible); User32.SetWindowPos(this.ThumbRight.Handle, this.Owner?.ThumbRight.Handle ?? IntPtr.Zero, scv.DestPositionX + scv.DecalSbSX + (int)((this.Position.X - parallaxDecal - offset.X * scale) / scv.RatioX), scv.DestPositionY + scv.DecalSbSY + (int)((this.Position.Y - offset.Y * scale) / scv.RatioY), (int)(32 * scale / scv.RatioX), (int)(32 * scale / scv.RatioY), SWP.SWP_ASYNCWINDOWPOS | rightVisible); //DebugWindow.Instance.UpdateMessage($"Mouse Left: {this.Position.X} Top: {this.Position.Y}"); }
internal static extern BOOL SetWindowPos( IntPtr hWnd, IntPtr hWndInsertAfter, int x = 0, int y = 0, int cx = 0, int cy = 0, SWP flags = (SWP)0);
public static bool SetWindowPos(IntPtr hWnd, int x, int y, int cx, int cy, SWP flags, out int lastError) { var result = SafeNativeMethods.SetWindowPos(hWnd, _zeroPtr, x, y, cx, cy, (int)flags); lastError = result ? 0 : Marshal.GetLastWin32Error(); return(result); }
public static extern bool SetWindowPos( [In] IntPtr hWnd, [In] IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SWP uFlags);
public static extern BOOL SetWindowPos( IntPtr hWnd, IntPtr hWndInsertAfter, int x = 0, int y = 0, int cx = 0, int cy = 0, SWP flags = default);
private static extern bool SetWindowPos( IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SWP uFlags);
public static extern bool SetWindowPos( IntPtr hWnd, // ウィンドウのハンドル IntPtr hWndInsertAfter, // 配置順序のハンドル int X, // 横方向の位置 int Y, // 縦方向の位置 int cx, // 幅 int cy, // 高さ SWP uFlags // ウィンドウ位置のオプション );
public static extern BOOL SetWindowPos( HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, SWP uFlags );
public override void ProcessWindow(WindowHandle hWnd) { SWP swpParam = SWP.NOACTIVATE | SWP.NOZORDER; if (Maximize.IsPresent) { hWnd.Maximize(); } else if (Minimize.IsPresent) { hWnd.Minimize(); } else { if (Restore.IsPresent || hWnd.GetIsMaximized() || hWnd.GetIsMinimized()) { hWnd.Restore(); } #region default the x,y,w,h if ((Width == 0) || (Height == 0) || (Left == 0) || (Top == 0)) { NativeMethods.RECT bounds; NativeMethods.GetWindowRect(hWnd, out bounds); if ((Width == 0) && (Height == 0)) { swpParam |= SWP.NOSIZE; } else if ((Left == 0) && (Top == 0)) { swpParam |= SWP.NOMOVE; } if (Width == 0) { Width = bounds.Width; } if (Height == 0) { Height = bounds.Height; } if (Left == 0) { Left = bounds.Left; } if (Top == 0) { Top = bounds.Top; } } #endregion NativeMethods.SetWindowPos(hWnd, IntPtr.Zero, Left, Top, Width, Height, swpParam); } }
public void UpdateThumbs(int offsetLevel) { if (this.ThumbLeft == null || this.ThumbRight == null) { return; } this.OffsetLevel = offsetLevel; bool modeSbS = Options.ModeSbS; int screenWidth = Options.ScreenWidth; int screenHeight = Options.ScreenHeight; double scale = Options.ScreenScale; double dX = modeSbS ? 2 : 1; double dY = modeSbS ? 1 : 2; int decalX = modeSbS ? screenWidth / 2 : 0; int decalY = modeSbS ? 0 : Options.ScreenHeight / 2; int parallaxDecal = 2 * Options.ParallaxEffect * offsetLevel; CURSORINFO cursorInfo = new CURSORINFO(); cursorInfo.cbSize = Marshal.SizeOf(cursorInfo); User32.GetCursorInfo(out cursorInfo); this.Position = cursorInfo.ptScreenPos; POINT offset = this.ThumbLeft.SetCursor(cursorInfo.hCursor); this.ThumbRight.SetCursor(cursorInfo.hCursor); SWP leftVisible = (modeSbS && this.Position.X + parallaxDecal + arrowStdSize.X < screenWidth) || (!modeSbS && this.Position.Y + arrowStdSize.Y < screenHeight) ? SWP.SWP_SHOWWINDOW : SWP.SWP_HIDEWINDOW; SWP rightVisible = !modeSbS || this.Position.X - parallaxDecal > 0 ? SWP.SWP_SHOWWINDOW : SWP.SWP_HIDEWINDOW; User32.SetWindowPos(this.ThumbLeft.Handle, this.Owner?.ThumbLeft.Handle ?? IntPtr.Zero, (int)((this.Position.X + parallaxDecal - offset.X * scale) / dX), (int)((this.Position.Y - offset.Y * scale) / dY), (int)(32 * scale / dX), (int)(32 * scale / dY), SWP.SWP_ASYNCWINDOWPOS | leftVisible); User32.SetWindowPos(this.ThumbRight.Handle, this.Owner?.ThumbRight.Handle ?? IntPtr.Zero, decalX + (int)((this.Position.X - parallaxDecal - offset.X * scale) / dX), decalY + (int)((this.Position.Y - offset.Y * scale) / dY), (int)(32 * scale / dX), (int)(32 * scale / dY), SWP.SWP_ASYNCWINDOWPOS | rightVisible); //DebugWindow.Instance.UpdateMessage($"Mouse Left: {this.Position.X} Top: {this.Position.Y}"); }
/// <summary>Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.</summary> public static void SetWindowPos (this Window window, Window windowAfter = null, int left = InvalidInt, int top = InvalidInt, int width = InvalidInt, int height = InvalidInt, SWP flags = 0) { if (windowAfter == null) flags = flags | SWP.NOZORDER; if (left == InvalidInt || top == InvalidInt) flags = flags | SWP.NOMOVE; if (width == InvalidInt || height == InvalidInt) flags = flags | SWP.NOSIZE; if (!SetWindowPos(GetHandle(window), GetHandle(windowAfter), left, top, width, height, flags)) throw new Win32Exception(); }
public static BOOL SetWindowPos( HandleRef hWnd, IntPtr hWndInsertAfter, int x = 0, int y = 0, int cx = 0, int cy = 0, SWP flags = (SWP)0) { BOOL result = SetWindowPos(hWnd.Handle, hWndInsertAfter, x, y, cx, cy, flags); GC.KeepAlive(hWnd.Wrapper); return(result); }
public static BOOL SetWindowPos( IHandle hWnd, IntPtr hWndInsertAfter, int x = 0, int y = 0, int cx = 0, int cy = 0, SWP flags = default) { BOOL result = SetWindowPos(hWnd.Handle, hWndInsertAfter, x, y, cx, cy, flags); GC.KeepAlive(hWnd); return(result); }
public void MoveWindowToPoint(Point point, bool isActivate = false, bool isTop = false) { SWP swp = SWP.AsynchronousWindowPosition | SWP.IgnoreResize; if (!isActivate) { swp |= SWP.DoNotActivate; } if (!isTop) { swp |= SWP.IgnoreZOrder; } SetWindowPos(HWnd, HWNDInsertAfter.Top, point.X, point.Y, 0, 0, swp); }
/// <summary> /// Moves the window to the specified location and size /// </summary> /// <param name="x">The horizontal location.</param> /// <param name="y">The vertical location.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> public void SetPosition(int x, int y, int width, int height) { SWP param = SWP.NOACTIVATE; if (width + height <= 0) { param |= SWP.NOSIZE; } if (this.GetIsMaximized() || this.GetIsMaximized()) { this.Restore(); } NativeMethods.SetWindowPos(this, IntPtr.Zero, x, y, width, height, SWP.NOACTIVATE); }
public void SaveTransaction(TaskCard taskCard, int id) { swp = new FinancialPlanner.Common.JSONSerialization().DeserializeFromString <SWP>(taskCard.TaskTransactionType.ToString()); DataBase.DBService.ExecuteCommandString(string.Format(INSERT_SWP, id, swp.Arn, swp.Cid, swp.MemberName, swp.Amc, swp.FolioNumber, swp.Scheme, swp.Options, swp.Amount, swp.Duration, swp.Frequency, swp.ModeOfExecution, swp.Remark), true); }
private SWP convertToSWP(DataRow dr) { SWP SWP = new SWP(); SWP.Id = dr.Field <int>("ID"); SWP.TaskId = dr.Field <int>("TaskId"); SWP.Arn = dr.Field <int>("ARN"); SWP.Cid = dr.Field <int>("CID"); SWP.MemberName = dr.Field <string>("MemberName"); SWP.Amc = dr.Field <int>("AMC"); SWP.FolioNumber = dr.Field <string>("FolioNumber"); SWP.Scheme = dr.Field <int>("SchemeId"); SWP.Options = dr.Field <string>("Option"); SWP.Amount = dr.Field <long>("Amount"); SWP.Duration = dr.Field <int>("Duration"); SWP.Frequency = dr.Field <string>("Frequency"); SWP.ModeOfExecution = dr.Field <string>("ModeOfExecution"); SWP.Remark = dr.Field <string>("Remark"); return(SWP); }
/// <summary> /// 更改指定窗口样式 /// </summary> /// <param name="Title">窗口标题</param> /// <param name="ZStyle">Z方向排序</param> /// <param name="SWP"> /// <para>窗口大小和位置标志</para> /// <para>注: 若使用 ZStyle, 则必须赋值此参数</para> /// </param> /// <param name="SW">窗口显示状态</param> /// <returns></returns> public bool ChangeWindow(string Title, ZStyle ZStyle = 0, SWP SWP = 0, SW SW = 0) { try { IntPtr hWnd = WndTab[Title].Handle; if (ZStyle != 0) { SetWindowPos(hWnd, HWNDPos[(int)ZStyle], 0, 0, 0, 0, (uint)SWP); } if (SW != 0) { ShowWindow(hWnd, (int)SW); } } catch (KeyNotFoundException) { return(false); throw; } return(true); }
public object GetTransaction(int id) { try { Logger.LogInfo("Get: SWP transaction process start"); SWP swp = new SWP(); DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_BY_ID, id)); foreach (DataRow dr in dtAppConfig.Rows) { swp = convertToSWP(dr); } Logger.LogInfo("Get: SWP purchase transaction process completed."); return(swp); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
/// <summary> /// /// </summary> /// <param name="hwnd"></param> /// <param name="pos"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="cx"></param> /// <param name="cy"></param> /// <param name="uFlags"></param> /// <returns></returns> public static bool SetWindowPos(IntPtr hwnd, HWND pos, int x, int y, int cx, int cy, SWP uFlags) { return NativeMethods.SetWindowPos(hwnd, pos, x, y, cx, cy, uFlags); }
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SWP flags);
private static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SWP uFlags) { if (!_SetWindowPos(hWnd, hWndInsertAfter, x, y, cx, cy, uFlags)) { // If this fails it's never worth taking down the process. Let the caller deal with the error if they want. return(false); } return(true); }
public static bool SetWindowPos(IntPtr handle, IntPtr insertAfter, int left, int top, int right, int bottom, SWP flags) { return NativeMethods.SetWindowPos(handle, insertAfter, left, top, right, bottom, flags); }
internal static extern bool SetWindowPos(IntPtr hwnd, HWND pos, int x, int y, int cx, int cy, SWP uFlags);
internal static IEnumerable <SWP> EnumerateFlags(SWP flags) => Enum.GetValues(typeof(SWP)).Cast <SWP>().Where(x => flags.HasFlag(x));
public extern static int SetWindowPos( IntPtr hWnd, HWND pos, int X, int Y, int cx, int cy, SWP uFlags);
public static extern IntPtr DeferWindowPos(IntPtr hWinPosInfo, IntPtr hWnd, [Optional] IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SWP uFlags);
public static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SWP uFlags) { return(NativeMethods._SetWindowPos(hWnd, hWndInsertAfter, x, y, cx, cy, uFlags)); }
public static extern bool SetWindowPos(IntPtr hwnd, int hwnd2, int x, int y, int cx, int cy, SWP uFlags);
public static extern bool SetWindowPos(HWND hwnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, SWP uFlags);
public static void SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SWP uFlags) { if (!_SetWindowPos(hWnd, hWndInsertAfter, x, y, cx, cy, uFlags)) { throw new Win32Exception(); } }
public static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndAfter, int X, int Y, int Width, int Height, SWP flags);
public static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SWP uFlags) { if (!_SetWindowPos(hWnd, hWndInsertAfter, x, y, cx, cy, uFlags)) { // If this fails it's never worth taking down the process. Let the caller deal with the error if they want. return false; } return true; }
/// <summary> /// /// </summary> /// <param name="hwnd"></param> /// <param name="pos"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="cx"></param> /// <param name="cy"></param> /// <param name="uFlags"></param> /// <returns></returns> public static bool SetWindowPos(IntPtr hwnd, HWND pos, int x, int y, int cx, int cy, SWP uFlags) { return(NativeMethods.SetWindowPos(hwnd, pos, x, y, cx, cy, uFlags)); }
public extern static int SetWindowPos ( IntPtr hWnd, HWND pos, int X, int Y, int cx, int cy, SWP uFlags);
private static extern UInt32 SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int width, int height, SWP flags);
public static extern IntPtr SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int Y, int cx, int cy, SWP wFlags);
internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SWP uFlags);
private static extern bool _SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SWP uFlags);