private FindWindow ( string lpClassName, string lpWindowName ) : |
||
lpClassName | string | |
lpWindowName | string | |
Результат |
public Taskbar() { IntPtr hWnd = WinApi.FindWindow("Shell_TrayWnd", null); WinApi.APPBARDATA appbardata = default(WinApi.APPBARDATA); appbardata.cbSize = (uint)Marshal.SizeOf(typeof(WinApi.APPBARDATA)); appbardata.hWnd = hWnd; IntPtr value = WinApi.SHAppBarMessage(WinApi.ABM.GetTaskbarPos, ref appbardata); if (value == IntPtr.Zero) { throw new InvalidOperationException(); } this.Position = (TaskbarPosition)appbardata.uEdge; this.Bounds = Rectangle.FromLTRB(appbardata.rc.Left, appbardata.rc.Top, appbardata.rc.Right, appbardata.rc.Bottom); appbardata.cbSize = (uint)Marshal.SizeOf(typeof(WinApi.APPBARDATA)); int num = WinApi.SHAppBarMessage(WinApi.ABM.GetState, ref appbardata).ToInt32(); this.AlwaysOnTop = ((num & 2) == 2); this.AutoHide = ((num & 1) == 1); }
public Taskbar() { IntPtr intPtr = WinApi.FindWindow("Shell_TrayWnd", null); WinApi.APPBARDATA aPPBARDATum = new WinApi.APPBARDATA() { cbSize = (uint)Marshal.SizeOf(typeof(WinApi.APPBARDATA)), hWnd = intPtr }; if (WinApi.SHAppBarMessage(WinApi.ABM.GetTaskbarPos, ref aPPBARDATum) == IntPtr.Zero) { throw new InvalidOperationException(); } this.Position = (TaskbarPosition)aPPBARDATum.uEdge; this.Bounds = Rectangle.FromLTRB(aPPBARDATum.rc.Left, aPPBARDATum.rc.Top, aPPBARDATum.rc.Right, aPPBARDATum.rc.Bottom); aPPBARDATum.cbSize = (uint)Marshal.SizeOf(typeof(WinApi.APPBARDATA)); IntPtr intPtr1 = WinApi.SHAppBarMessage(WinApi.ABM.GetState, ref aPPBARDATum); int num = intPtr1.ToInt32(); this.AlwaysOnTop = (num & 2) == 2; this.AutoHide = (num & 1) == 1; }
public Taskbar() { IntPtr taskbarHandle = WinApi.FindWindow(Taskbar.ClassName, null); WinApi.APPBARDATA data = new WinApi.APPBARDATA(); data.cbSize = (uint)Marshal.SizeOf(typeof(WinApi.APPBARDATA)); data.hWnd = taskbarHandle; IntPtr result = WinApi.SHAppBarMessage(WinApi.ABM.GetTaskbarPos, ref data); if (result == IntPtr.Zero) { throw new InvalidOperationException(); } this.Position = (TaskbarPosition)data.uEdge; this.Bounds = Rectangle.FromLTRB(data.rc.Left, data.rc.Top, data.rc.Right, data.rc.Bottom); data.cbSize = (uint)Marshal.SizeOf(typeof(WinApi.APPBARDATA)); result = WinApi.SHAppBarMessage(WinApi.ABM.GetState, ref data); int state = result.ToInt32(); this.AlwaysOnTop = (state & WinApi.AlwaysOnTop) == WinApi.AlwaysOnTop; this.AutoHide = (state & WinApi.Autohide) == WinApi.Autohide; }