• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WINDOWPLACEMENT类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetPlacement

 private static WINDOWPLACEMENT GetPlacement(this IntPtr hwnd)
 {
     var placement = new WINDOWPLACEMENT();
     placement.length = Marshal.SizeOf(placement);
     GetWindowPlacement(hwnd, ref placement);
     return placement;
 }
开发者ID:t00,项目名称:seb,代码行数:7,代码来源:SEBWindowHandler.cs


示例17: GetWindowPlacement

 public static extern unsafe bool GetWindowPlacement(IntPtr hWnd, WINDOWPLACEMENT* lpwndpl);
开发者ID:AArnott,项目名称:pinvoke,代码行数:1,代码来源:User32.cs


示例18: New

 public static WINDOWPLACEMENT New()
 {
     WINDOWPLACEMENT ret = new WINDOWPLACEMENT();
     ret.length = (uint)System.Runtime.InteropServices.Marshal.SizeOf(ret);
     return ret;
 }
开发者ID:machisuji,项目名称:Kieker,代码行数:6,代码来源:DllImport.cs


示例19: GetWindowPlacement

 internal static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl);
开发者ID:TDeMon,项目名称:VolumeRegulator,代码行数:1,代码来源:Program.cs


示例20: ManageExtPlayer

        private void ManageExtPlayer(Process player, PlayableItem playable)
        {
            //minimize MCE if indicated
            IntPtr mceWnd = FindWindow(null, "Windows Media Center");
            WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
            GetWindowPlacement(mceWnd, ref wp);

            Cursor.Hide();

            if (HideTaskbar)
            {
                Taskbar.Hide();
            }

            if (ShowSplashScreen)
            {
                //throw up a form to cover the desktop if we minimize and we are in the primary monitor
                if (System.Windows.Forms.Screen.FromHandle(mceWnd).Primary)
                {
                    ExternalSplashForm.Display(Application.CurrentInstance.ExtSplashBmp);
                }
            }

            if (MinimizeMCE)
            {
                Logger.ReportVerbose("Minimizing Windows Media Center");
                wp.showCmd = 2; // 1 - Normal; 2 - Minimize; 3 - Maximize;
                SetWindowPlacement(mceWnd, ref wp);
            }

            // async this so it doesn't slow us down if the service isn't responding for some reason
            Async.Queue("Wait for external player to launch", () =>
            {
                player.Refresh();
                player.WaitForInputIdle(5000);
                OnExternalPlayerLaunched(playable);
            });

            //and wait for it to exit
            player.WaitForExit();

            player.Dispose();

            //now restore MCE
            wp.showCmd = 1; // 1 - Normal; 2 - Minimize; 3 - Maximize;
            SetWindowPlacement(mceWnd, ref wp);

            if (ShowSplashScreen)
            {
                ExternalSplashForm.Hide();
            }

            if (HideTaskbar)
            {
                Taskbar.Show();
            }

            Cursor.Show();

            SetForegroundWindow(mceWnd);

            OnPlaybackFinished(GetFinishedPlaybackState());
        }
开发者ID:rickbassham,项目名称:videobrowser,代码行数:63,代码来源:ExternalPlaybackController.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WM类代码示例发布时间:2022-05-24
下一篇:
C# WIN32_FIND_DATA类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap