当前位置: 首页>>代码示例>>C#>>正文


C# WINDOWPLACEMENT类代码示例

本文整理汇总了C#中WINDOWPLACEMENT的典型用法代码示例。如果您正苦于以下问题:C# WINDOWPLACEMENT类的具体用法?C# WINDOWPLACEMENT怎么用?C# WINDOWPLACEMENT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WINDOWPLACEMENT类属于命名空间,在下文中一共展示了WINDOWPLACEMENT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: load

        public void load()
        {
            Debug.Print("" + ht.Values.Count);
            foreach (DictionaryEntry de in ht)
            {
                try
                {
                    IntPtr hWnd = (IntPtr)de.Key;
                    if (IsWindowVisible(hWnd) == 0) continue;
                    WINDOWPLACEMENT wp = (WINDOWPLACEMENT)de.Value;
                    SetWindowPlacement(hWnd, ref wp);

                    Debug.Print("" + wp.showCmd);
                    if (wp.showCmd == 1)
                    {
                        WINDOWPLACEMENT wp2 = new WINDOWPLACEMENT();
                        GetWindowPlacement(hWnd, ref wp2);
                        if (wp2.rcNormalPosition.left == wp.rcNormalPosition.left)
                        {
                            RECT r = wp.rcNormalPosition;
                            MoveWindow(hWnd, r.left, r.top, r.right - r.left, r.bottom - r.top, 1);
                        }
                    }
                }
                catch
                {
                }

            }
        }
开发者ID:segabito,项目名称:NonowaWindowResize,代码行数:30,代码来源:EnumWindow.cs

示例2: GetVisible

 public static bool GetVisible()
 {
     WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
     placement.length = Marshal.SizeOf(placement);
     GetWindowPlacement(Process.GetCurrentProcess().MainWindowHandle, ref placement);
     return placement.showCmd != SW_HIDE;
 }
开发者ID:ribcesoftware,项目名称:Converter,代码行数:7,代码来源:Program.cs

示例3: GetMinimized

 public static bool GetMinimized()
 {
     WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
     placement.length = Marshal.SizeOf(placement);
     GetWindowPlacement(Process.GetCurrentProcess().MainWindowHandle, ref placement);
     return placement.showCmd == SW_SHOWMINIMIZED;
 }
开发者ID:ribcesoftware,项目名称:Converter,代码行数:7,代码来源:Program.cs

示例4: GetWindowPlacement

 public static WINDOWPLACEMENT GetWindowPlacement(IntPtr handle)
 {
     WINDOWPLACEMENT windowPlacement = new WINDOWPLACEMENT();
     if (!GetWindowPlacement(handle, ref windowPlacement))
         throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());
     return windowPlacement;
 }
开发者ID:Healix,项目名称:Gw2Launcher,代码行数:7,代码来源:WindowSize.cs

示例5: save

        public void save()
        {
            EnumWindows(new EnumWindowsDelegate(delegate(IntPtr hWnd, int lParam)
            {
                StringBuilder sb = new StringBuilder(0x1024);
                if (IsWindowVisible(hWnd) != 0 && GetWindowText(hWnd, sb, sb.Capacity) != 0)
                {
                    try
                    {
                        string title = sb.ToString();
                        int pid;
                        GetWindowThreadProcessId(hWnd, out pid);
                        Process p = Process.GetProcessById(pid);

                        WINDOWPLACEMENT wndpl = new WINDOWPLACEMENT();
                        wndpl.Length = Marshal.SizeOf(wndpl);

                        GetWindowPlacement(hWnd, ref wndpl);

                        ht[hWnd] = wndpl;
                    }
                    catch
                    {
                    }
                }
                return 1;
            }), 0);
        }
开发者ID:segabito,项目名称:NonowaWindowResize,代码行数:28,代码来源:EnumWindow.cs

示例6: GetWindowPlacement

 public static WINDOWPLACEMENT GetWindowPlacement(IntPtr hwnd)
 {
     WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
       placement.length = Marshal.SizeOf(placement);
       GetWindowPlacement(hwnd, ref placement);
       return placement;
 }
开发者ID:vtchill,项目名称:SteamServerBrowser,代码行数:7,代码来源:Win32.cs

示例7: FormObject_FormClosed

 //save the placement...
 private void FormObject_FormClosed(object sender, FormClosedEventArgs e)
 {
     //save placement.
     //all the "tough work" is handled above, and by the INIDataItem Extension methods. Here we
     //can simply use SetValue<> and set the value. Nice and clean.
     WINDOWPLACEMENT grabplacement = new WINDOWPLACEMENT();
     GetWindowPlacement(FormObject.Handle, ref grabplacement);
     Configuration[usesectionName][FormObject.Name].SetValue(grabplacement);
 }
开发者ID:BCProgramming,项目名称:BCJobClock,代码行数:10,代码来源:FormPositionSaver.cs

示例8: isWindowMinimized

 public static bool isWindowMinimized(IntPtr hWnd)
 {
     WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
     placement.length = Marshal.SizeOf(placement);
     var result = GetWindowPlacement(hWnd, ref placement);
     if (result)
     {
         return placement.showCmd == SW_SHOWMINIMIZED;
     }
     throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not get window placement");
 }
开发者ID:jorgechen,项目名称:CoolFish,代码行数:11,代码来源:NativeImports.cs

示例9: ActivateInternet

        /// <summary>
        /// Переключается в браузер:
        /// </summary>
        private static void ActivateInternet()
        {
            //System.Threading.Thread.Sleep(3000);
            IntPtr handle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Chrome_WidgetWin_1", null);
            //IntPtr hide_handle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Chrome_WidgetWin_1", null);
            //System.Threading.Thread.Sleep(5000);

            if (handle != IntPtr.Zero)
            {

                //System.Threading.Thread.Sleep(1000);
                IntPtr current_active = GetForegroundWindow();
                handle = FindWindowEx(IntPtr.Zero, handle, "Chrome_WidgetWin_1", null);

                WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
                placement.Length = Marshal.SizeOf(placement);
                GetWindowPlacement((IntPtr)handle, out placement);
                if (placement.ShowCmd == 3 || placement.ShowCmd == 1)//maximized || normal
                {
                    ShowWindow((IntPtr)handle, Constants.SW_MINIMIZE);
                    //UpdateWindow((IntPtr)handle);
                    return;
                }
                //if (current_active != handle)
                else if (placement.ShowCmd == 2)//minimized
                {
                    //handle = FindWindowEx(IntPtr.Zero, handle, "Chrome_WidgetWin_1", null);
                    ShowWindow((IntPtr)handle, Constants.SW_SHOW);
                    ShowWindow((IntPtr)handle, Constants.SW_MAXIMIZE);
                    UpdateWindow((IntPtr)handle);
                    SetActiveWindow((IntPtr)handle);
                    SetFocus((IntPtr)handle);
                    //SetWindowPos((IntPtr)handle, (IntPtr)Constants.HWND_TOP, 0, 0, 0, 0, Constants.SWP_NOMOVE | Constants.SWP_NOSIZE | Constants.SWP_FRAMECHANGED);
                    SetForegroundWindow(handle);
                    return;
                }
                else if (false)//normal
                {
                    SetForegroundWindow(handle);
                    //handle = FindWindowEx(IntPtr.Zero, handle, "Chrome_WidgetWin_1", null);
                    ShowWindow((IntPtr)handle, Constants.SW_MINIMIZE);
                    //ShowWindow((IntPtr)handle, Constants.SW_HIDE);
                    //ShowWindow((IntPtr)handle, Constants.SW_RESTORE);
                    //UpdateWindow((IntPtr)handle);
                    return;
                }
            }
            else
            {
                Process.Start("chrome.exe", "www.yandex.ru");
                System.Threading.Thread.Sleep(1000);
            }
            //System.Threading.Thread.Sleep(1000);
        }
开发者ID:TDeMon,项目名称:VolumeRegulator,代码行数:57,代码来源:Program.cs

示例10: GetPlacement

 public static Point GetPlacement(IntPtr handle)
 {
     var placement = new WINDOWPLACEMENT();
     placement.length = Marshal.SizeOf(placement);
     if (GetWindowPlacement(handle, ref placement))
     {
         var location = placement.rcNormalPosition;
         return new Point(location.X + location.Width/2, location.Y + location.Height / 2);
     }
     Logger.Write("placement not found.");
     return new Point(0, 0);
 }
开发者ID:jeroldhaas,项目名称:ContinuousTests,代码行数:12,代码来源:MsAGLVisualization.cs

示例11: FocusWindow

        public static void FocusWindow(IntPtr hwnd)
        {
            try
            {
                WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
                placement.length = Marshal.SizeOf(placement);
                if (GetWindowPlacement(hwnd, ref placement))
                {
                    if (placement.showCmd == ShowCmds.Minimized)
                        NativeMethods.ShowWindow(hwnd, NativeMethods.SW_RESTORE);

                    SetForegroundWindow(hwnd);
                }
            }
            catch
            { }
        }
开发者ID:Usagination,项目名称:Azpe,代码行数:17,代码来源:NativeMethods.cs

示例12: Restore

            public static void Restore(Window window, XElement xml)
            {
                var placement = new WINDOWPLACEMENT();

                placement.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
                placement.flags = 0;

                placement.showCmd = (int)xml.Element(ShowCommandElementName);
                placement.ptMinPosition.x = (int)xml.Element(MinPositionElementName).Attribute(XAttributeName);
                placement.ptMinPosition.y = (int)xml.Element(MinPositionElementName).Attribute(YAttributeName);
                placement.ptMaxPosition.x = (int)xml.Element(MaxPositionElementName).Attribute(XAttributeName);
                placement.ptMaxPosition.y = (int)xml.Element(MaxPositionElementName).Attribute(YAttributeName);
                placement.rcNormalPosition.left = (int)xml.Element(NormalPositionElementName).Attribute(LeftAttributeName);
                placement.rcNormalPosition.top = (int)xml.Element(NormalPositionElementName).Attribute(TopAttributeName);
                placement.rcNormalPosition.right = (int)xml.Element(NormalPositionElementName).Attribute(RightAttributeName);
                placement.rcNormalPosition.bottom = (int)xml.Element(NormalPositionElementName).Attribute(BottomAttributeName);

                var windowInteropHelper = new WindowInteropHelper(window);
                SetWindowPlacement(windowInteropHelper.Handle, ref placement);
            }
开发者ID:nguerrera,项目名称:xunit.runner.wpf,代码行数:20,代码来源:Storage.WindowPlacement.cs

示例13: Save

            public static XElement Save(Window window)
            {
                var windowInteropHelper = new WindowInteropHelper(window);
                var placement = new WINDOWPLACEMENT();
                GetWindowPlacement(windowInteropHelper.Handle, out placement);

                return
                    new XElement(WindowPlacementElementName,
                        new XElement(ShowCommandElementName, (placement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWNORMAL : placement.showCmd)),
                        new XElement(MinPositionElementName,
                            new XAttribute(XAttributeName, placement.ptMinPosition.x),
                            new XAttribute(YAttributeName, placement.ptMinPosition.y)),
                        new XElement(MaxPositionElementName,
                            new XAttribute(XAttributeName, placement.ptMaxPosition.x),
                            new XAttribute(YAttributeName, placement.ptMaxPosition.y)),
                        new XElement(NormalPositionElementName,
                            new XAttribute(LeftAttributeName, placement.rcNormalPosition.left),
                            new XAttribute(TopAttributeName, placement.rcNormalPosition.top),
                            new XAttribute(RightAttributeName, placement.rcNormalPosition.right),
                            new XAttribute(BottomAttributeName, placement.rcNormalPosition.bottom)));
            }
开发者ID:nguerrera,项目名称:xunit.runner.wpf,代码行数:21,代码来源:Storage.WindowPlacement.cs

示例14: FormObject_Load

        //Load event: load the form placement, if present, from the INI file we were given in our constructor.
        private void FormObject_Load(object sender, EventArgs e)
        {
            WINDOWPLACEMENT currplacement = new WINDOWPLACEMENT();
            GetWindowPlacement(FormObject.Handle, ref currplacement);
                //default is wherever it is now if there is a parse problem.

            WINDOWPLACEMENT getplacement =
                Configuration[usesectionName][FormObject.Name].GetValue(currplacement);

            //check for previous instances, and offset if there are.
            String thisproc = Process.GetCurrentProcess().ProcessName;
            Process[] existing = Process.GetProcessesByName(thisproc);
            if (existing.Length > 1)
            {
                //more than one, so offset...
                OffsetRect(ref getplacement.rcNormalPosition, 16*existing.Length, 16*existing.Length);
            }

            SetWindowPlacement(FormObject.Handle, ref getplacement);

            //load placement...
        }
开发者ID:BCProgramming,项目名称:BCJobClock,代码行数:23,代码来源:FormPositionSaver.cs

示例15: GetWindowPlacement

 private static extern bool GetWindowPlacement(
     IntPtr	hWnd,
     ref WINDOWPLACEMENT lpwndpl);
开发者ID:Usagination,项目名称:Azpe,代码行数:3,代码来源:NativeMethods.cs


注:本文中的WINDOWPLACEMENT类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。