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

C# MONITORINFO类代码示例

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

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



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

示例1: WmGetMinMaxInfo

        private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            POINT lMousePosition;
            GetCursorPos(out lMousePosition);

            IntPtr lPrimaryScreen = MonitorFromPoint(new POINT(0, 0), MonitorOptions.MONITOR_DEFAULTTOPRIMARY);
            MONITORINFO lPrimaryScreenInfo = new MONITORINFO();
            if (GetMonitorInfo(lPrimaryScreen, lPrimaryScreenInfo) == false)
            {
                return;
            }

            IntPtr lCurrentScreen = MonitorFromPoint(lMousePosition, MonitorOptions.MONITOR_DEFAULTTONEAREST);

            MINMAXINFO lMmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            if (lPrimaryScreen.Equals(lCurrentScreen))
            {
                lMmi.ptMaxPosition.X = lPrimaryScreenInfo.rcWork.Left;
                lMmi.ptMaxPosition.Y = lPrimaryScreenInfo.rcWork.Top;
                lMmi.ptMaxSize.X = lPrimaryScreenInfo.rcWork.Right - lPrimaryScreenInfo.rcWork.Left;
                lMmi.ptMaxSize.Y = lPrimaryScreenInfo.rcWork.Bottom - lPrimaryScreenInfo.rcWork.Top;
            }
            else
            {
                lMmi.ptMaxPosition.X = lPrimaryScreenInfo.rcMonitor.Left;
                lMmi.ptMaxPosition.Y = lPrimaryScreenInfo.rcMonitor.Top;
                lMmi.ptMaxSize.X = lPrimaryScreenInfo.rcMonitor.Right - lPrimaryScreenInfo.rcMonitor.Left;
                lMmi.ptMaxSize.Y = lPrimaryScreenInfo.rcMonitor.Bottom - lPrimaryScreenInfo.rcMonitor.Top;
            }

            Marshal.StructureToPtr(lMmi, lParam, true);
        }
开发者ID:rischwa,项目名称:eve-fast-fitting-assessment,代码行数:33,代码来源:WindowResizer.cs


示例2: WmGetMinMaxInfo

        internal static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            // Adjust the maximized size and position to fit the work area
            // of the correct monitor.
            Int32 MONITOR_DEFAULTTONEAREST = 0x00000002;

            IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
            if (monitor != IntPtr.Zero)
            {
                MONITORINFO monitorInfo = new MONITORINFO();
                GetMonitorInfo(monitor, monitorInfo);

                RECT rcWorkArea = monitorInfo.m_rcWork;
                RECT rcMonitorArea = monitorInfo.m_rcMonitor;

                mmi.m_ptMaxPosition.m_x = Math.Abs(rcWorkArea.m_left - rcMonitorArea.m_left);
                mmi.m_ptMaxPosition.m_y = Math.Abs(rcWorkArea.m_top - rcMonitorArea.m_top);

                mmi.m_ptMaxSize.m_x = Math.Abs(rcWorkArea.m_right - rcWorkArea.m_left);
                mmi.m_ptMaxSize.m_y = Math.Abs(rcWorkArea.m_bottom - rcWorkArea.m_top);
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
开发者ID:yuriCarlos,项目名称:Spofy,代码行数:26,代码来源:NativeMethods.cs


示例3: WmGetMinMaxInfo

        private void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            // Adjust the maximized size and position to fit the work area of the correct monitor
            int MONITOR_DEFAULTTONEAREST =0x00000002;
            IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            if (monitor != IntPtr.Zero)
            {
                MONITORINFO monitorInfo = new MONITORINFO();
                GetMonitorInfo(monitor, monitorInfo);
                RECT rcWorkArea = monitorInfo.rcWork;
                RECT rcMonitorArea = monitorInfo.rcMonitor;
                mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
                mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
                mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
                mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);

                // Convert pixel sizes based on current DPI settings.
                // Window.MinHeight/MinWidth are 1/96th of an inch.
                PresentationSource presentationSource = PresentationSource.FromVisual(this);
                if (presentationSource != null)
                {
                    if (presentationSource.CompositionTarget != null)
                    {
                        Point minSize = presentationSource.CompositionTarget.TransformToDevice.Transform(new Point(MinWidth, MinHeight));
                        mmi.ptMinTrackSize.x = (int)minSize.X;
                        mmi.ptMinTrackSize.y = (int)minSize.Y;
                    }
                }
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
开发者ID:ProRoman,项目名称:Aura_PhotoViewer,代码行数:35,代码来源:ResizeableWindow.cs


示例4: WmGetMinMaxInfo

 private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
 {
     MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
     int MONITOR_DEFAULTTONEAREST = 0x00000002;
     IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
     if (monitor != IntPtr.Zero)
     {
         MONITORINFO monitorInfo = new MONITORINFO();
         GetMonitorInfo(monitor, monitorInfo);
         RECT rcWorkArea = monitorInfo.rcWork;
         RECT rcMonitorArea = monitorInfo.rcMonitor;
         mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
         mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
         mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
         mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
     }
     Marshal.StructureToPtr(mmi, lParam, true);
 }
开发者ID:dalinhuang,项目名称:ChargeLeaderSystem,代码行数:18,代码来源:WindowHelper.cs


示例5: WmGetMinMaxInfo

        private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            var structure = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
            var hMonitor = MonitorFromWindow(hwnd, 2);

            if (hMonitor != IntPtr.Zero)
            {
                var lpmi = new MONITORINFO();
                GetMonitorInfo(hMonitor, lpmi);
                RECT rcWork = lpmi.rcWork;
                RECT rcMonitor = lpmi.rcMonitor;
                structure.ptMaxPosition.x = Math.Abs((int)(rcWork.left - rcMonitor.left));
                structure.ptMaxPosition.y = Math.Abs((int)(rcWork.top - rcMonitor.top));
                structure.ptMaxSize.x = Math.Abs((int)(rcWork.right - rcWork.left));
                structure.ptMaxSize.y = Math.Abs((int)(rcWork.bottom - rcWork.top));
                structure.ptMinTrackSize.x = (int)Application.Current.MainWindow.MinWidth;
                structure.ptMinTrackSize.y = (int)Application.Current.MainWindow.MinHeight;
            }
            Marshal.StructureToPtr(structure, lParam, true);
        }
开发者ID:krisrang,项目名称:youdown-old,代码行数:20,代码来源:LayeredWindow.cs


示例6: WmGetMinMaxInfo

        private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            var mmi = (MINMAXINFO) Marshal.PtrToStructure(lParam, typeof (MINMAXINFO));

            // Adjust the maximized size and position to fit the work area of the correct monitor
            var MONITOR_DEFAULTTONEAREST = 0x00000002;
            var monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            if (monitor != IntPtr.Zero) {
                var monitorInfo = new MONITORINFO();
                GetMonitorInfo(monitor, monitorInfo);
                var rcWorkArea = monitorInfo.rcWork;
                var rcMonitorArea = monitorInfo.rcMonitor;
                mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
                mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
                mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
                mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
开发者ID:eduvm,项目名称:birthmail,代码行数:21,代码来源:WinPrincipal.xaml.cs


示例7: getNativeMonitorResolution

 private void getNativeMonitorResolution(out int width, out int height)
 {
     var monitor = MonitorFromWindow(GetActiveWindow(), MONITOR_DEFAULTTONEAREST);
     MONITORINFO monitorInfo = new MONITORINFO();
     monitorInfo.cbSize = Marshal.SizeOf(monitorInfo);
     if (!GetMonitorInfo(monitor, ref monitorInfo))
     {
         width = Screen.width;
         height = Screen.height;
     }
     else
     {
         width = monitorInfo.rcMonitor.Width;
         height = monitorInfo.rcMonitor.Height;
     }
 }
开发者ID:oafkad,项目名称:TouchScript,代码行数:16,代码来源:WindowsTouchHandlers.cs


示例8: GetMonitorInfo

 public static extern int GetMonitorInfo(IntPtr hMonitor, ref MONITORINFO lpmi);
开发者ID:MarianMitschke,项目名称:NFCAccessControl,代码行数:1,代码来源:GDI.cs


示例9: GetMonitor

        public static Monitor GetMonitor(IntPtr hMonitor)
        {
            MONITORINFO _info = new MONITORINFO();
            _info.cbSize = Marshal.SizeOf(_info);

            NativeMethods.GetMonitorInfo(hMonitor, ref _info);

            uint _dpiX = Monitor.DPICONST;
            uint _dpiY = Monitor.DPICONST;

            if (OS.SupportDPI)
            {
                NativeMethods.GetDpiForMonitor(hMonitor, MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out _dpiX, out _dpiY);
            }

            return new Monitor()
            {
                Size = _info.Size,
                WorkArea = _info.WorkArea,
                DPIx = _dpiX,
                DPIy = _dpiY,
                IsPrimary = _info.IsPrimary
            };
        }
开发者ID:l3ackEyeD,项目名称:SidebarDiagnostics,代码行数:24,代码来源:Windows.cs


示例10: IsFullScreen

        /*---------------------------------------------------------------------------------*/
        public bool IsFullScreen(string[] classNamesExcluded)
        {
            if (m_hWnd == IntPtr.Zero)
                return false;

            // 컨트롤의 최상위 핸들을 얻어옵니다.
            IntPtr hWnd = GetAncestor(m_hWnd, GetAncestorFlags.GetRoot);
            if (hWnd == IntPtr.Zero)
                return false;

            // 클래스이름을 얻어옵니다.
            StringBuilder className = new StringBuilder(256);
            if (GetClassName(hWnd, className, className.Capacity) == 0)
                return false;

            // 제외목록에서 하나라도 해당되는지 확인.
            if (classNamesExcluded.Any((string s) => s == className.ToString()))
                return false;

            // 현재 컨트롤이 속하는 모니터의 사각영역을 얻어옵니다.
            RECT desktop;
            IntPtr monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
            if (monitor == IntPtr.Zero)
            {
                // 모니터를 찾을 수 없으면 현재 윈도우 화면의 핸들로 설정한다.
                IntPtr desktopWnd = GetDesktopWindow();
                if (desktopWnd == IntPtr.Zero)
                    return false;

                if (GetWindowRect(desktopWnd, out desktop) == false)
                    return false;
            }
            else
            {
                MONITORINFO info = new MONITORINFO();
                info.cbSize = Marshal.SizeOf(info);
                if (GetMonitorInfo(monitor, ref info) == false)
                    return false;

                desktop = info.rcMonitor;
            }

            // 컨트롤의 작업영역을 알아낸다.
            RECT client;
            if (GetClientRect(hWnd, out client) == false)
                return false;

            // 컨트롤의 크기가 모니터 크기보다 작으면 전체화면이 아니다.
            if (client.Width < desktop.Width
                ||
                client.Height < desktop.Height)
                return false;

            // 여기까지 도달했으면 전체화면이다.
            return true;
        }
开发者ID:NeuroWhAI,项目名称:WhenFullScreen,代码行数:57,代码来源:WindowHandle.cs


示例11: GetActualScreenData

        private static void GetActualScreenData(ABEdge edge, Window appbarWindow, ref int leftOffset, ref int topOffset, ref int actualScreenWidth, ref int actualScreenHeight)
        {
            IntPtr handle = new WindowInteropHelper(appbarWindow).Handle;
            IntPtr monitorHandle = MonitorFromWindow(handle, MONITOR_DEFAULTTONEAREST);

            MONITORINFO mi = new MONITORINFO();
            mi.cbSize = Marshal.SizeOf(mi);

            if (GetMonitorInfo(monitorHandle, ref mi))
            {
                if (mi.dwFlags == MONITORINFOF_PRIMARY)
                {
                    return;
                }
                leftOffset = mi.rcWork.left;
                topOffset = mi.rcWork.top;
                actualScreenWidth = mi.rcWork.right - leftOffset;
                actualScreenHeight = mi.rcWork.bottom - mi.rcWork.top;
            }
        }
开发者ID:zachischeese,项目名称:SidebarDiagnostics,代码行数:20,代码来源:AppBar.cs


示例12: WmGetMinMaxInfo

        private static void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
        {
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            // Adjust the maximized size and position to fit the work area of the correct monitor
            int MONITOR_DEFAULTTONEAREST = 0x00000002;
            System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            if (monitor != System.IntPtr.Zero)
            {
                MONITORINFO monitorInfo = new MONITORINFO();
                GetMonitorInfo(monitor, monitorInfo);
                RECT rcWorkArea = monitorInfo.rcWork;
                RECT rcMonitorArea = monitorInfo.rcMonitor;
                mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
                mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);

                // 这行如果不注释掉在多显示器情况下显示会有问题! 
                // mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
                mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
                workAreaMaxHeight = mmi.ptMaxSize.y;

                //当窗口的任务栏自动隐藏时,最大化的时候最下边要留几个像素的空白,否则此窗口将屏幕铺满,则鼠标移到最下边时,任务栏无法自动弹出
                if (rcWorkArea.Height == rcMonitorArea.Height)
                {
                    mmi.ptMaxSize.y -= 2;
                }
            }

            Marshal.StructureToPtr(mmi, lParam, true);
        }
开发者ID:SmartEncounter,项目名称:SmartLCT-V2.0,代码行数:31,代码来源:WindowResizer.cs


示例13: GetMonitorInfo

 public static extern bool GetMonitorInfo(IntPtr hMonitor, ref MONITORINFO info);
开发者ID:AnotherAltr,项目名称:Rc.Core,代码行数:1,代码来源:User32.cs


示例14: GetMonitorInfo

 private static extern bool GetMonitorInfo(IntPtr monitor, ref MONITORINFO info);
开发者ID:jonhartnett,项目名称:IROM-Util,代码行数:1,代码来源:Window.cs


示例15: GetMonitorInfo

 internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);
开发者ID:ufouz1990,项目名称:LeapIN,代码行数:1,代码来源:Win32Services.cs


示例16: MonitorFromPoint

 internal static extern IntPtr MonitorFromPoint(POINT pt, MONITORINFO.MonitorOptions dwFlags);
开发者ID:jinlook,项目名称:MahApps.Metro,代码行数:1,代码来源:UnsafeNativeMethods.cs


示例17: GetMonitorInfo

 private static extern bool GetMonitorInfo(IntPtr hMonitor, ref MONITORINFO lpmi);
开发者ID:rxantos,项目名称:tesv-snip,代码行数:1,代码来源:nativemethods.cs


示例18: WmGetMinMaxInfo

        /// <summary>
        /// Creates and populates the MINMAXINFO structure for a maximized window.
        /// Puts the structure into memory address given by lParam.
        /// Only used to process a WM_GETMINMAXINFO message.
        /// </summary>
        /// <param name="hwnd">The window handle.</param>
        /// <param name="lParam">The lParam.</param>
        private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            // Get the MINMAXINFO structure from memory location given by lParam
            MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            // Adjust the maximized size and position to fit the work area of the correct monitor
            IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

            if (monitor != IntPtr.Zero)
            {
                MONITORINFO monitorInfo = new MONITORINFO();
                GetMonitorInfo(monitor, monitorInfo);
                RECT rcWorkArea = monitorInfo.rcWork;
                RECT rcMonitorArea = monitorInfo.rcMonitor;
                mmi.ptMaxPosition.X = Math.Abs(rcWorkArea.Left - rcMonitorArea.Left);
                mmi.ptMaxPosition.Y = Math.Abs(rcWorkArea.Top - rcMonitorArea.Top);
                mmi.ptMaxSize.X = Math.Abs(rcWorkArea.Right - rcWorkArea.Left);
                mmi.ptMaxSize.Y = Math.Abs(rcWorkArea.Bottom - rcWorkArea.Top);
            }

            // Copy the structure to memory location specified by lParam.
            // This concludes processing of WM_GETMINMAXINFO.
            Marshal.StructureToPtr(mmi, lParam, true);
        }
开发者ID:TedMANNERs,项目名称:ModernDesignTemplate,代码行数:31,代码来源:NativeMethods.cs


示例19: Capture

 public static WriteableBitmap Capture()
 {
     try
     {
         IntPtr hMonitor = MonitorFromPoint(new POINT(), MonitorOptions.MONITOR_DEFAULTTOPRIMARY);
         Debug.Assert(hMonitor != IntPtr.Zero);
         MONITORINFO mi = new MONITORINFO();
         mi.cbSize = (uint)Marshal.SizeOf(mi);
         bool bln = GetMonitorInfo(hMonitor, ref mi);
         Debug.Assert(bln);
         int W = mi.rcMonitor.right - mi.rcMonitor.left;
         int H = mi.rcMonitor.bottom - mi.rcMonitor.top;
         BITMAPINFOHEADER bmi = new BITMAPINFOHEADER();
         bmi.Init(W, H, 32);
         IntPtr hdcDesktop = GetDC(IntPtr.Zero);
         Debug.Assert(hdcDesktop != IntPtr.Zero);
         try
         {
             IntPtr hdcMem = CreateCompatibleDC(hdcDesktop);
             Debug.Assert(hdcMem != IntPtr.Zero);
             try
             {
                 IntPtr ppvBits = IntPtr.Zero;
                 IntPtr hbm = CreateDIBSection(hdcMem, ref bmi, 0, out ppvBits, IntPtr.Zero, 0);
                 Debug.Assert(hbm != IntPtr.Zero);
                 try
                 {
                     Debug.Assert(ppvBits != IntPtr.Zero);
                     IntPtr hOldObj = SelectObject(hdcMem, hbm);
                     bln = BitBlt(hdcMem, 0, 0, W, H, hdcDesktop, mi.rcMonitor.left, mi.rcMonitor.top, 0x00CC0020 /* SRCCOPY */);
                     Debug.Assert(bln);
                     GdiFlush();
                     ReleaseDC(IntPtr.Zero, hdcDesktop);
                     hdcDesktop = IntPtr.Zero;
                     WriteableBitmap wb = new WriteableBitmap(W, H);
                     int[] buf = wb.Pixels;
                     for (int ofs = 0; ofs < H; ++ofs)
                     {
                         Marshal.Copy(new IntPtr(ppvBits.ToInt64() + 4 * W * ofs), buf, (H - 1 - ofs) * W, W);
                     }
                     DeleteDC(hdcMem);
                     hdcMem = IntPtr.Zero;
                     DeleteObject(hbm);
                     hbm = IntPtr.Zero;
                     return wb;
                 }
                 finally
                 {
                     if(hbm != IntPtr.Zero)
                     {
                         DeleteObject(hbm);
                     }
                 }
             }
             finally
             {
                 if(hdcMem != IntPtr.Zero)
                 {
                     DeleteDC(hdcMem);
                 }
             }
         }
         finally
         {
             if(hdcDesktop != IntPtr.Zero)
             {
                 ReleaseDC(IntPtr.Zero, hdcDesktop);
             }
         }
     }
     catch(Exception e)
     {
         for (Exception r = e; r != null; r = r.InnerException)
         {
             Debug.WriteLine(r.Message);
             Debug.WriteLine(r.StackTrace);
         }
         return null;
     }
 }
开发者ID:michaelboyle-smarttech,项目名称:itec-ambire,代码行数:80,代码来源:ScreenCapture.cs


示例20: WmGetMinMaxInfo

        /// <summary>
        /// The WmGetMinMaxInfo function creates and populates the MINMAXINFO structure for a maximized window.
        /// Puts the structure into memory address given by lParam.
        /// Only used to process a WM_GETMINMAXINFO message.
        /// </summary>
        /// <param name="hwnd">The window handle.</param>
        /// <param name="lParam">The lParam.</param>
        private void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            // Get the MINMAXINFO structure from memory location given by lParam
            MINMAXINFO mmi =
                (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

            // Get the monitor that overlaps the window or the nearest
            IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
            if (monitor != IntPtr.Zero)
            {
                // Get monitor information
                MONITORINFO monitorInfo = new MONITORINFO();
                monitorInfo.Size = Marshal.SizeOf(typeof(MONITORINFO));
                GetMonitorInfo(monitor, ref monitorInfo);

                // The display monitor rectangle.
                // If the monitor is not the primary display monitor,
                // some of the rectangle's coordinates may be negative values
                RECT rcWorkArea = monitorInfo.WorkArea;
                RECT rcMonitorArea = monitorInfo.Monitor;

                // Set the dimensions of the window in maximized state
                mmi.MaxPosition.X = Math.Abs(rcWorkArea.Left - rcMonitorArea.Left);
                mmi.MaxPosition.Y = Math.Abs(rcWorkArea.Top - rcMonitorArea.Top);
                mmi.MaxSize.X = Math.Abs(rcWorkArea.Right - rcWorkArea.Left);
                mmi.MaxSize.Y = Math.Abs(rcWorkArea.Bottom - rcWorkArea.Top);

                // Set the maximum drag X size for the window
                mmi.MaxTrackSize.X = mmi.MaxSize.X;
                // Set the maximum drag Y size for the window
                mmi.MaxTrackSize.Y = mmi.MaxSize.Y;
                mmi.MinTrackSize.X = (int)MinWidowWidth;
                mmi.MinTrackSize.Y = (int)MinWidowHeight;

                // Set the working area depending of TaskBar position and AutoHide status
                mmi = AdjustWorkingAreaForAutoHide(monitor, mmi);
            }

            // Copy the structure to memory location specified by lParam.
            // This concludes processing of WM_GETMINMAXINFO.
            Marshal.StructureToPtr(mmi, lParam, true);
        }
开发者ID:wegorich,项目名称:XNA-Game-and-WPF-Map-Editor,代码行数:49,代码来源:WindowBaseAPI.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# MObject类代码示例发布时间:2022-05-24
下一篇:
C# MODE类代码示例发布时间: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