コード例 #1
0
        public static WindowHandle CreateWindow(
            Atom className,
            string windowName,
            WindowStyles style,
            ExtendedWindowStyles extendedStyle,
            int x,
            int y,
            int width,
            int height,
            WindowHandle parentWindow,
            IntPtr menuHandle,
            ModuleInstance instance,
            IntPtr parameters)
        {
            WindowHandle window = Imports.CreateWindowExW(
                extendedStyle,
                className,
                windowName,
                style,
                x,
                y,
                width,
                height,
                parentWindow,
                menuHandle,
                instance ?? ModuleInstance.Null,
                parameters);

            if (window == WindowHandle.Null)
            {
                throw Errors.GetIoExceptionForLastError();
            }

            return(window);
        }
コード例 #2
0
ファイル: Windows.cs プロジェクト: carlossanlop/WInterop
        public unsafe static WindowHandle CreateWindow(
            Atom classAtom,
            string?windowName  = null,
            WindowStyles style = WindowStyles.Overlapped,
            ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default,
            Rectangle bounds          = default,
            WindowHandle parentWindow = default,
            MenuHandle menuHandle     = default,
            ModuleInstance?instance   = null,
            IntPtr parameters         = default)
        {
            WindowHandle window = Imports.CreateWindowExW(
                extendedStyle,
                (char *)classAtom.ATOM,
                windowName,
                style,
                bounds.X,
                bounds.Y,
                bounds.Width,
                bounds.Height,
                parentWindow,
                menuHandle,
                instance ?? ModuleInstance.Null,
                parameters);

            if (window.IsInvalid)
            {
                Error.ThrowLastError();
            }

            return(window);
        }
コード例 #3
0
        public WindowHandle CreateWindow(
            Rectangle bounds,
            string windowName  = null,
            WindowStyles style = WindowStyles.Overlapped,
            ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default,
            bool isMainWindow         = false,
            WindowHandle parentWindow = default,
            IntPtr parameters         = default,
            MenuHandle menuHandle     = default)
        {
            if (!IsRegistered)
            {
                throw new ArgumentException("Window class must be registered before using.");
            }

            WindowHandle window = Windows.CreateWindow(
                Atom,
                windowName,
                style,
                extendedStyle,
                bounds,
                parentWindow,
                menuHandle,
                parameters: parameters);

            if (isMainWindow)
            {
                MainWindow = window;
            }

            return(window);
        }
コード例 #4
0
ファイル: WindowUtil.cs プロジェクト: Longi94/AngryMouse
        public static void SetWindowStyles(Window window, ExtendedWindowStyles styles)
        {
            var hwnd          = new WindowInteropHelper(window).Handle;
            var extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);

            extendedStyle |= (int)styles;
            SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle);
        }
コード例 #5
0
ファイル: Windows.cs プロジェクト: carlossanlop/WInterop
 public static void CreateMainWindowAndRun(
     WindowClass windowClass,
     string?windowTitle = null,
     WindowStyles style = WindowStyles.OverlappedWindow,
     ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default,
     MenuHandle menuHandle = default)
 {
     CreateMainWindowAndRun(windowClass, DefaultBounds, windowTitle, style, extendedStyle, menuHandle);
 }
コード例 #6
0
 //Documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/ms632680(v=vs.85).aspx
 private static extern IntPtr CreateWindowEx(
     ExtendedWindowStyles extendedStyle,
     IntPtr windowClassAtom,
     string windowName,
     WindowStyles style,
     int x, int y, int width, int height,
     IntPtr parent,
     IntPtr menu,
     IntPtr instance,
     IntPtr param);
コード例 #7
0
 public WindowHandle CreateWindow(
     string windowName  = null,
     WindowStyles style = WindowStyles.Overlapped,
     ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default,
     bool isMainWindow         = false,
     WindowHandle parentWindow = default,
     IntPtr parameters         = default,
     MenuHandle menuHandle     = default)
 {
     return(CreateWindow(Windows.DefaultBounds, windowName, style, extendedStyle, isMainWindow, parentWindow, parameters, menuHandle));
 }
コード例 #8
0
ファイル: Windows.cs プロジェクト: maryamariyan/WInterop
 public static WindowHandle CreateWindow(
     ModuleInstance instance,
     string className,
     string windowName,
     WindowStyles style,
     ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.None,
     int x      = WindowDefines.CW_USEDEFAULT,
     int y      = WindowDefines.CW_USEDEFAULT,
     int width  = WindowDefines.CW_USEDEFAULT,
     int height = WindowDefines.CW_USEDEFAULT)
 => WindowMethods.CreateWindow(className, windowName, style, extendedStyle, x, y, width, height, instance);
コード例 #9
0
 public static WindowHandle CreateWindow(
     Atom className,
     string windowName,
     WindowStyles style,
     ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.None,
     int x      = WindowDefines.CW_USEDEFAULT,
     int y      = WindowDefines.CW_USEDEFAULT,
     int width  = WindowDefines.CW_USEDEFAULT,
     int height = WindowDefines.CW_USEDEFAULT,
     ModuleInstance instance = null)
 {
     return(CreateWindow(className, windowName, style, extendedStyle, x, y, width, height, WindowHandle.Null, IntPtr.Zero, instance, IntPtr.Zero));
 }
コード例 #10
0
 public static extern WindowHandle CreateWindowExW(
     ExtendedWindowStyles dwExStyle,
     IntPtr lpClassName,
     string lpWindowName,
     WindowStyles dwStyle,
     int x,
     int y,
     int nWidth,
     int nHeight,
     WindowHandle hWndParent,
     IntPtr hMenu,
     ModuleInstance hInstance,
     IntPtr lpParam);
コード例 #11
0
ファイル: ButtonClass.cs プロジェクト: bangush/WInterop
 public override WindowHandle CreateWindow(
     Rectangle bounds,
     string?windowName  = null,
     WindowStyles style = WindowStyles.Overlapped,
     ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default,
     bool isMainWindow         = false,
     WindowHandle parentWindow = default,
     IntPtr parameters         = default,
     MenuHandle menuHandle     = default)
 {
     style |= (WindowStyles)ButtonStyle;
     return(base.CreateWindow(bounds, windowName, style, extendedStyle, isMainWindow, parentWindow, parameters, menuHandle));
 }
コード例 #12
0
ファイル: Windows.cs プロジェクト: maryamariyan/WInterop
 public static WindowHandle CreateWindow(
     string className,
     string windowName,
     WindowStyles style,
     ExtendedWindowStyles extendedStyle,
     int x,
     int y,
     int width,
     int height,
     WindowHandle parentWindow,
     IntPtr menuHandle,
     ModuleInstance instance,
     IntPtr parameters) => WindowMethods.CreateWindow(
     className, windowName, style, extendedStyle, x, y, width, height, parentWindow, menuHandle, instance, parameters);
コード例 #13
0
        public static string ToStringFlags(this ExtendedWindowStyles extendedWindowStyles)
        {
            var names  = new HashSet <string>();
            var type   = typeof(ExtendedWindowStyles);
            var values = (ExtendedWindowStyles[])Enum.GetValues(type);

            foreach (var val in values)
            {
                if ((extendedWindowStyles & val) == val)
                {
                    var name = Enum.GetName(type, val);
                    Debug.Assert(name != null, "name != null");
                    names.Add(name);
                }
            }
            return(string.Join(" | ", names));
        }
コード例 #14
0
ファイル: Windows.cs プロジェクト: carlossanlop/WInterop
        /// <summary>
        /// Creates a window of the specified class and processes the message loop.
        /// Does not return until the message loop exits.
        /// </summary>
        public static void CreateMainWindowAndRun(
            WindowClass windowClass,
            Rectangle bounds,
            string?windowTitle = null,
            WindowStyles style = WindowStyles.OverlappedWindow,
            ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default,
            MenuHandle menuHandle = default)
        {
            if (!windowClass.IsRegistered)
            {
                windowClass.Register();
            }

            WindowHandle mainWindow = windowClass.CreateWindow(
                bounds,
                windowTitle,
                style,
                extendedStyle,
                isMainWindow: true,
                menuHandle: menuHandle);

            try
            {
                mainWindow.ShowWindow(ShowWindowCommand.Normal);
                mainWindow.UpdateWindow();

                while (GetMessage(out WindowMessage message))
                {
                    TranslateMessage(ref message);
                    DispatchMessage(ref message);
                }

                // Make sure our window class doesn't get collected while we're pumping messages
                GC.KeepAlive(windowClass);
            }
            catch
            {
                // Hit the P/Invoke directly as we want to throw the original error.
                Imports.DestroyWindow(mainWindow);
                throw;
            }
        }
コード例 #15
0
        public unsafe static WindowHandle CreateWindow(
            string className,
            string windowName  = null,
            WindowStyles style = WindowStyles.Overlapped,
            ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default,
            Rectangle bounds          = default,
            WindowHandle parentWindow = default,
            MenuHandle menuHandle     = default,
            ModuleInstance instance   = default,
            IntPtr parameters         = default)
        {
            WindowHandle window;

            fixed(char *name = className)
            {
                window = Imports.CreateWindowExW(
                    extendedStyle,
                    name,
                    windowName,
                    style,
                    bounds.X,
                    bounds.Y,
                    bounds.Width,
                    bounds.Height,
                    parentWindow,
                    menuHandle,
                    instance ?? ModuleInstance.Null,
                    parameters);
            }

            if (window.IsInvalid)
            {
                throw Error.GetExceptionForLastError();
            }

            return(window);
        }
コード例 #16
0
        /// <summary>
        /// Creates a window of the specified class and processes the message loop.
        /// Does not return until the message loop exits.
        /// </summary>
        public static void CreateMainWindowAndRun(
            WindowClass windowClass,
            Rectangle bounds,
            string windowTitle = null,
            WindowStyles style = WindowStyles.OverlappedWindow,
            ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default,
            MenuHandle menuHandle = default)
        {
            // Hack for launching as a .NET Core Windows Application
            Console.Console.TryFreeConsole();

            if (!windowClass.IsRegistered)
            {
                windowClass.Register();
            }

            WindowHandle mainWindow = windowClass.CreateWindow(
                bounds,
                windowTitle,
                style,
                extendedStyle,
                isMainWindow: true,
                menuHandle: menuHandle);

            mainWindow.ShowWindow(ShowWindowCommand.Normal);
            mainWindow.UpdateWindow();

            while (GetMessage(out WindowMessage message))
            {
                TranslateMessage(ref message);
                DispatchMessage(ref message);
            }

            // Make sure our window class doesn't get collected while were pumping
            GC.KeepAlive(windowClass);
        }
コード例 #17
0
 public static UInt32 ToUInt32(this ExtendedWindowStyles extendedWindowStyles)
 {
     return((UInt32)extendedWindowStyles);
 }
コード例 #18
0
ファイル: Windows.cs プロジェクト: vmlellis/OptiKey
 public static void SetExtendedWindowStyle(IntPtr hWnd, ExtendedWindowStyles exStyle)
 {
     PInvoke.SetWindowLong(hWnd, (int)GWL.GWL_EXSTYLE, (int)exStyle);
 }
コード例 #19
0
 //Documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/ms632667(v=vs.85).aspx
 private static extern bool AdjustWindowRect(
     ref IntRect rect,
     WindowStyles style,
     bool menu,
     ExtendedWindowStyles extendedStyle);
コード例 #20
0
ファイル: USER32.cs プロジェクト: shugen002/bililive_dm
#pragma warning restore CS0612 // 类型或成员已过时
        public static ExtendedWindowStyles SetExtendedWindowStyles(IntPtr hWnd, ExtendedWindowStyles styles)
        => (ExtendedWindowStyles)SetWindowStyles(hWnd, WindowStylesKind.ExStyles, (int)styles);
コード例 #21
0
 public static extern bool AdjustWindowRectEx(
     ref RECT lpRect,
     WindowStyles dwStyle,
     bool bMenu,
     ExtendedWindowStyles dwExStyle);
コード例 #22
0
 public static extern bool AdjustWindowRectExForDpi([In][Out] ref Rectangle lpRect,
                                                    bool bMenu, ExtendedWindowStyles dwExStyle, uint dpi);