LoadCursor() public static method

public static LoadCursor ( CursorName lpCursorName ) : HCURSOR
lpCursorName CursorName
return HCURSOR
Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
 public static IntPtr LoadCursor(CursorName lpCursorName)
 {
     return(Functions.LoadCursor(IntPtr.Zero, new IntPtr((int)lpCursorName)));
 }