コード例 #1
0
ファイル: WinGLNative.cs プロジェクト: luislasonbra/PixelFarm
        IntPtr CreateWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device, IntPtr parentHandle)
        {
            // Use win32 to create the native window.
            // Keep in mind that some construction code runs in the WM_CREATE message handler.

            // The style of a parent window is different than that of a child window.
            // Note: the child window should always be visible, even if the parent isn't.
            WindowStyle         style    = 0;
            ExtendedWindowStyle ex_style = 0;

            if (parentHandle == IntPtr.Zero)
            {
                style   |= WindowStyle.OverlappedWindow | WindowStyle.ClipChildren;
                ex_style = ParentStyleEx;
            }
            else
            {
                style   |= WindowStyle.Visible | WindowStyle.Child | WindowStyle.ClipSiblings;
                ex_style = ChildStyleEx;
            }

            // Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc).
            Win32Rectangle rect = new Win32Rectangle();

            rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height;
            Functions.AdjustWindowRectEx(ref rect, style, false, ex_style);
            // Create the window class that we will use for this window.
            // The current approach is to register a new class for each top-level WinGLWindow we create.
            if (!class_registered)
            {
                ExtendedWindowClass wc = new ExtendedWindowClass();
                wc.Size      = ExtendedWindowClass.SizeInBytes;
                wc.Style     = DefaultClassStyle;
                wc.Instance  = Instance;
                wc.WndProc   = WindowProcedureDelegate;
                wc.ClassName = ClassName;
                wc.Icon      = Icon != null ? Icon.Handle : IntPtr.Zero;
#warning "This seems to resize one of the 'large' icons, rather than using a small icon directly (multi-icon files). Investigate!"
                wc.IconSm = Icon != null ? new Icon(Icon, 16, 16).Handle : IntPtr.Zero;
                wc.Cursor = Functions.LoadCursor(CursorName.Arrow);
                ushort atom = Functions.RegisterClassEx(ref wc);
                if (atom == 0)
                {
                    throw new PlatformException(String.Format("Failed to register window class. Error: {0}", Marshal.GetLastWin32Error()));
                }
                class_registered = true;
            }

            IntPtr window_name = Marshal.StringToHGlobalAuto(title);
            IntPtr handle      = Functions.CreateWindowEx(
                ex_style, ClassName, window_name, style,
                rect.left, rect.top, rect.Width, rect.Height,
                parentHandle, IntPtr.Zero, Instance, IntPtr.Zero);
            if (handle == IntPtr.Zero)
            {
                throw new PlatformException(String.Format("Failed to create window. Error: {0}", Marshal.GetLastWin32Error()));
            }
            return(handle);
        }
コード例 #2
0
ファイル: API.cs プロジェクト: yzaroui/ClassicalSharp
        internal static Win32Rectangle From(Rectangle value)
        {
            Win32Rectangle rect = new Win32Rectangle();

            rect.left   = value.Left;
            rect.right  = value.Right;
            rect.top    = value.Top;
            rect.bottom = value.Bottom;
            return(rect);
        }
コード例 #3
0
ファイル: API.cs プロジェクト: yzaroui/ClassicalSharp
        internal static Win32Rectangle From(Size value)
        {
            Win32Rectangle rect = new Win32Rectangle();

            rect.left   = 0;
            rect.right  = value.Width;
            rect.top    = 0;
            rect.bottom = value.Height;
            return(rect);
        }
コード例 #4
0
        private IntPtr CreateWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device, IntPtr parentHandle)
        {
            WindowStyle         windowStyle1 = WindowStyle.Overlapped;
            WindowStyle         windowStyle2;
            ExtendedWindowStyle extendedWindowStyle;

            if (parentHandle == IntPtr.Zero)
            {
                windowStyle2        = windowStyle1 | WindowStyle.TiledWindow | WindowStyle.ClipChildren;
                extendedWindowStyle = ExtendedWindowStyle.WindowEdge | ExtendedWindowStyle.ApplicationWindow;
            }
            else
            {
                windowStyle2        = windowStyle1 | WindowStyle.Child | WindowStyle.Visible | WindowStyle.ClipSiblings;
                extendedWindowStyle = ExtendedWindowStyle.Left;
            }
            Win32Rectangle lpRect = new Win32Rectangle();

            lpRect.left   = x;
            lpRect.top    = y;
            lpRect.right  = x + width;
            lpRect.bottom = y + height;
            Functions.AdjustWindowRectEx(ref lpRect, windowStyle2, false, extendedWindowStyle);
            if (!this.class_registered)
            {
                if ((int)Functions.RegisterClassEx(ref new ExtendedWindowClass()
                {
                    Size = ExtendedWindowClass.SizeInBytes,
                    Style = ClassStyle.OwnDC,
                    Instance = this.Instance,
                    WndProc = this.WindowProcedureDelegate,
                    ClassName = this.ClassName,
                    Icon = this.Icon != null ? this.Icon.Handle : IntPtr.Zero,
                    IconSm = this.Icon != null ? new Icon(this.Icon, 16, 16).Handle : IntPtr.Zero,
                    Cursor = Functions.LoadCursor(CursorName.Arrow)
                }) == 0)
                {
                    throw new PlatformException(string.Format("Failed to register window class. Error: {0}", (object)Marshal.GetLastWin32Error()));
                }
                this.class_registered = true;
            }
            IntPtr WindowName = Marshal.StringToHGlobalAuto(title);
            IntPtr windowEx   = Functions.CreateWindowEx(extendedWindowStyle, this.ClassName, WindowName, windowStyle2, lpRect.left, lpRect.top, lpRect.Width, lpRect.Height, parentHandle, IntPtr.Zero, this.Instance, IntPtr.Zero);

            if (windowEx == IntPtr.Zero)
            {
                throw new PlatformException(string.Format("Failed to create window. Error: {0}", (object)Marshal.GetLastWin32Error()));
            }
            else
            {
                return(windowEx);
            }
        }
コード例 #5
0
        void GrabCursor()
        {
            Win32Rectangle rect = Win32Rectangle.From(ClientRectangle);
            Point          pos  = PointToScreen(new Point(rect.left, rect.top));

            rect.left = pos.X;
            rect.top  = pos.Y;
            if (!Functions.ClipCursor(ref rect))
            {
                Debug.WriteLine(String.Format("Failed to grab cursor. Error: {0}",
                                              Marshal.GetLastWin32Error()));
            }
        }
コード例 #6
0
ファイル: WinGLNative.cs プロジェクト: linkedinyou/opentk
        void GrabCursor()
        {
            Point          pos  = PointToScreen(new Point(ClientRectangle.X, ClientRectangle.Y));
            Win32Rectangle rect = new Win32Rectangle();

            rect.left   = pos.X;
            rect.right  = pos.X + ClientRectangle.Width;
            rect.top    = pos.Y;
            rect.bottom = pos.Y + ClientRectangle.Height;
            if (!Functions.ClipCursor(ref rect))
            {
                Debug.WriteLine(String.Format("Failed to grab cursor. Error: {0}",
                                              Marshal.GetLastWin32Error()));
            }
        }
コード例 #7
0
ファイル: API.cs プロジェクト: yzaroui/ClassicalSharp
 internal static extern bool AdjustWindowRectEx(ref Win32Rectangle lpRect, WindowStyle dwStyle, bool bMenu, ExtendedWindowStyle dwExStyle);
コード例 #8
0
ファイル: API.cs プロジェクト: yzaroui/ClassicalSharp
 internal static extern bool AdjustWindowRect([In, Out] ref Win32Rectangle lpRect, WindowStyle dwStyle, bool bMenu);
コード例 #9
0
ファイル: API.cs プロジェクト: yzaroui/ClassicalSharp
 internal extern static bool GetClientRect(IntPtr windowHandle, out Win32Rectangle clientRectangle);
コード例 #10
0
ファイル: API.cs プロジェクト: jpbruyere/opentk
 internal extern static BOOL GetWindowRect(HWND windowHandle, out Win32Rectangle windowRectangle);
コード例 #11
0
ファイル: API.cs プロジェクト: jpbruyere/opentk
 internal extern static BOOL GetClientRect(HWND windowHandle, out Win32Rectangle clientRectangle);
コード例 #12
0
ファイル: API.cs プロジェクト: jpbruyere/opentk
 internal static Win32Rectangle From(Size value)
 {
     Win32Rectangle rect = new Win32Rectangle();
     rect.left = 0;
     rect.right = value.Width;
     rect.top = 0;
     rect.bottom = value.Height;
     return rect;
 }
コード例 #13
0
ファイル: Functions.cs プロジェクト: tanis2000/FEZ
 public static bool ClipCursor(ref Win32Rectangle rcClip);
コード例 #14
0
ファイル: Functions.cs プロジェクト: conankzhang/fez
 internal static bool GetWindowRect(IntPtr windowHandle, out Win32Rectangle windowRectangle);
コード例 #15
0
ファイル: WinGLNative.cs プロジェクト: raphaelts3/opentk
        IntPtr CreateWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device, IntPtr parentHandle)
        {
            // Use win32 to create the native window.
            // Keep in mind that some construction code runs in the WM_CREATE message handler.

            // The style of a parent window is different than that of a child window.
            // Note: the child window should always be visible, even if the parent isn't.
            WindowStyle style = 0;
            ExtendedWindowStyle ex_style = 0;
            if (parentHandle == IntPtr.Zero)
            {
                style |= WindowStyle.OverlappedWindow | WindowStyle.ClipChildren;
                ex_style = ParentStyleEx;
            }
            else
            {
                style |= WindowStyle.Visible | WindowStyle.Child | WindowStyle.ClipSiblings;
                ex_style = ChildStyleEx;
            }

            // Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc).
            Win32Rectangle rect = new Win32Rectangle();
            rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height;
            Functions.AdjustWindowRectEx(ref rect, style, false, ex_style);

            // Create the window class that we will use for this window.
            // The current approach is to register a new class for each top-level WinGLWindow we create.
            if (!class_registered)
            {
                ExtendedWindowClass wc = new ExtendedWindowClass();
                wc.Size = ExtendedWindowClass.SizeInBytes;
                wc.Style = DefaultClassStyle;
                wc.Instance = Instance;
                wc.WndProc = WindowProcedureDelegate;
                wc.ClassName = ClassName;
                wc.Icon = Icon != null ? Icon.Handle : IntPtr.Zero;
#warning "This seems to resize one of the 'large' icons, rather than using a small icon directly (multi-icon files). Investigate!"
                wc.IconSm = Icon != null ? new Icon(Icon, 16, 16).Handle : IntPtr.Zero;
                wc.Cursor = Functions.LoadCursor(CursorName.Arrow);
                ushort atom = Functions.RegisterClassEx(ref wc);

                if (atom == 0)
                    throw new PlatformException(String.Format("Failed to register window class. Error: {0}", Marshal.GetLastWin32Error()));

                class_registered = true;
            }

            IntPtr window_name = Marshal.StringToHGlobalAuto(title);
            IntPtr handle = Functions.CreateWindowEx(
                ex_style, ClassName, window_name, style,
                rect.left, rect.top, rect.Width, rect.Height,
                parentHandle, IntPtr.Zero, Instance, IntPtr.Zero);

            if (handle == IntPtr.Zero)
                throw new PlatformException(String.Format("Failed to create window. Error: {0}", Marshal.GetLastWin32Error()));

            return handle;
        }
コード例 #16
0
ファイル: API.cs プロジェクト: shahid-pk/opentk
 internal static extern bool AdjustWindowRectEx(ref Win32Rectangle lpRect, WindowStyle dwStyle, bool bMenu, ExtendedWindowStyle dwExStyle);
コード例 #17
0
ファイル: Functions.cs プロジェクト: tanis2000/FEZ
 internal static bool GetClientRect(IntPtr windowHandle, out Win32Rectangle clientRectangle);
コード例 #18
0
ファイル: WinGLNative.cs プロジェクト: tanis2000/FEZ
 private IntPtr CreateWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device, IntPtr parentHandle)
 {
   WindowStyle windowStyle1 = WindowStyle.Overlapped;
   WindowStyle windowStyle2;
   ExtendedWindowStyle extendedWindowStyle;
   if (parentHandle == IntPtr.Zero)
   {
     windowStyle2 = windowStyle1 | WindowStyle.TiledWindow | WindowStyle.ClipChildren;
     extendedWindowStyle = ExtendedWindowStyle.WindowEdge | ExtendedWindowStyle.ApplicationWindow;
   }
   else
   {
     windowStyle2 = windowStyle1 | WindowStyle.Child | WindowStyle.Visible | WindowStyle.ClipSiblings;
     extendedWindowStyle = ExtendedWindowStyle.Left;
   }
   Win32Rectangle lpRect = new Win32Rectangle();
   lpRect.left = x;
   lpRect.top = y;
   lpRect.right = x + width;
   lpRect.bottom = y + height;
   Functions.AdjustWindowRectEx(ref lpRect, windowStyle2, false, extendedWindowStyle);
   if (!this.class_registered)
   {
     if ((int) Functions.RegisterClassEx(ref new ExtendedWindowClass()
     {
       Size = ExtendedWindowClass.SizeInBytes,
       Style = ClassStyle.OwnDC,
       Instance = this.Instance,
       WndProc = this.WindowProcedureDelegate,
       ClassName = this.ClassName,
       Icon = this.Icon != null ? this.Icon.Handle : IntPtr.Zero,
       IconSm = this.Icon != null ? new Icon(this.Icon, 16, 16).Handle : IntPtr.Zero,
       Cursor = Functions.LoadCursor(CursorName.Arrow)
     }) == 0)
       throw new PlatformException(string.Format("Failed to register window class. Error: {0}", (object) Marshal.GetLastWin32Error()));
     this.class_registered = true;
   }
   IntPtr WindowName = Marshal.StringToHGlobalAuto(title);
   IntPtr windowEx = Functions.CreateWindowEx(extendedWindowStyle, this.ClassName, WindowName, windowStyle2, lpRect.left, lpRect.top, lpRect.Width, lpRect.Height, parentHandle, IntPtr.Zero, this.Instance, IntPtr.Zero);
   if (windowEx == IntPtr.Zero)
     throw new PlatformException(string.Format("Failed to create window. Error: {0}", (object) Marshal.GetLastWin32Error()));
   else
     return windowEx;
 }
コード例 #19
0
ファイル: Functions.cs プロジェクト: conankzhang/fez
 public static bool ClipCursor(ref Win32Rectangle rcClip);
コード例 #20
0
ファイル: API.cs プロジェクト: jpbruyere/opentk
 internal static Win32Rectangle From(Rectangle value)
 {
     Win32Rectangle rect = new Win32Rectangle();
     rect.left = value.Left;
     rect.right = value.Right;
     rect.top = value.Top;
     rect.bottom = value.Bottom;
     return rect;
 }
コード例 #21
0
ファイル: Functions.cs プロジェクト: tanis2000/FEZ
 internal static bool GetWindowRect(IntPtr windowHandle, out Win32Rectangle windowRectangle);
コード例 #22
0
ファイル: WinGLNative.cs プロジェクト: raphaelts3/opentk
 void GrabCursor()
 {
     Point pos = PointToScreen(new Point(ClientRectangle.X, ClientRectangle.Y));
     Win32Rectangle rect = new Win32Rectangle();
     rect.left = pos.X;
     rect.right = pos.X + ClientRectangle.Width;
     rect.top = pos.Y;
     rect.bottom = pos.Y + ClientRectangle.Height;
     if (!Functions.ClipCursor(ref rect))
         Debug.WriteLine(String.Format("Failed to grab cursor. Error: {0}",
             Marshal.GetLastWin32Error()));
 }
コード例 #23
0
ファイル: API.cs プロジェクト: jpbruyere/opentk
 internal static extern bool AdjustWindowRectEx(
     ref Win32Rectangle lpRect,
     WindowStyle dwStyle,
     [MarshalAs(UnmanagedType.Bool)] bool bMenu,
     ExtendedWindowStyle dwExStyle);