コード例 #1
0
 public WindowClassEx(WindowClassStyles style,
                      Delegates.WindowProcedure windowProcedure,
                      int classExtraBytes,
                      int windowExtraBytes,
                      IntPtr instance,
                      IntPtr icon,
                      IntPtr cursor,
                      IntPtr backgroundBrush,
                      string menuName,
                      string className,
                      IntPtr iconSmall)
 {
     Size             = (uint)Marshal.SizeOf(typeof(WindowClassEx));
     Style            = style;
     WindowProcedure  = windowProcedure;
     ClassExtraBytes  = classExtraBytes;
     WindowExtraBytes = windowExtraBytes;
     Instance         = instance;
     Icon             = icon;
     Cursor           = cursor;
     BackgroundBrush  = backgroundBrush;
     MenuName         = menuName;
     ClassName        = className;
     IconSmall        = iconSmall;
 }
コード例 #2
0
ファイル: WindowFactory.cs プロジェクト: zyj0021/WinApi
        public WindowFactory(string name, WindowClassStyles styles, IntPtr hInstance, IntPtr hIcon, IntPtr hCursor,
                             IntPtr hBgBrush, WindowProc wndProc)
        {
            var cache     = Cache.Instance;
            var className = name ?? Guid.NewGuid().ToString();

            this.ClassName      = className;
            this.InstanceHandle = hInstance;
            this.m_windowProc   = wndProc ?? DefWindowProc;

            this.m_classInitializerProcRef = this.ClassInitializerProc;

            var classInfo = new WindowClassEx
            {
                Size                  = cache.WindowClassExSize,
                ClassName             = className,
                CursorHandle          = hCursor,
                IconHandle            = hIcon,
                Styles                = styles,
                BackgroundBrushHandle = hBgBrush,
                WindowProc            = this.m_classInitializerProcRef,
                InstanceHandle        = hInstance
            };

            this.RegisterClass(ref classInfo);
        }
コード例 #3
0
ファイル: WindowFactory.cs プロジェクト: zyj0021/WinApi
        public static WindowFactory Create(string className         = null,
                                           WindowClassStyles styles = WindowClassStyles.CS_HREDRAW | WindowClassStyles.CS_VREDRAW,
                                           IntPtr?hInstance         = null, IntPtr?hIcon    = null,
                                           IntPtr?hCursor           = null, IntPtr?hBgBrush = null, WindowProc wndProc = null)
        {
            var cache = Cache.Instance;

            return(new WindowFactory(className, styles,
                                     hInstance ?? cache.ProcessHandle,
                                     hIcon ?? cache.AppIconHandle,
                                     hCursor ?? cache.ArrowCursorHandle,
                                     hBgBrush ?? (IntPtr)SystemColor.COLOR_WINDOW, wndProc));
        }
コード例 #4
0
        public static void RegisterWindowClass(String className, WindowClassStyles styles)
        {
            User32.WNDCLASSEX windowClass = new User32.WNDCLASSEX();

            windowClass.cbSize      = (UInt32)Marshal.SizeOf(typeof(User32.WNDCLASSEX));
            windowClass.style       = (UInt32)styles;
            windowClass.lpfnWndProc = ((hwnd, uMsg, wParam, lParam) =>
            {
                return(User32.DefWindowProc(hwnd, uMsg, wParam, lParam));
            });
            windowClass.hInstance     = Marshal.GetHINSTANCE(typeof(Win32Interop).Module);
            windowClass.lpszClassName = className;

            User32.RegisterClassEx(ref windowClass);
        }
コード例 #5
0
ファイル: WindowClass.cs プロジェクト: tajbender/Vanara
 /// <summary>Initializes a new instance of the <see cref="WindowClass"/> class and registers the class name.</summary>
 /// <param name="className">
 /// <para>
 /// A string that specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx,
 /// or any of the predefined control-class names.
 /// </para>
 /// <para>
 /// The maximum length for <c>lpszClassName</c> is 256. If <c>lpszClassName</c> is greater than the maximum length, the
 /// RegisterClassEx function will fail.
 /// </para>
 /// </param>
 /// <param name="hInst">A handle to the instance that contains the window procedure for the class.</param>
 /// <param name="wndProc">
 /// A pointer to the window procedure. You must use the CallWindowProc function to call the window procedure. For more information,
 /// see WindowProc.
 /// </param>
 /// <param name="styles">The class style(s). This member can be any combination of the Class Styles.</param>
 /// <param name="hIcon">
 /// A handle to the class icon. This member must be a handle to an icon resource. If this member is <c>NULL</c>, the system provides
 /// a default icon.
 /// </param>
 /// <param name="hSmIcon">
 /// A handle to a small icon that is associated with the window class. If this member is <c>NULL</c>, the system searches the icon
 /// resource specified by the <c>hIcon</c> member for an icon of the appropriate size to use as the small icon.
 /// </param>
 /// <param name="hCursor">
 /// A handle to the class cursor. This member must be a handle to a cursor resource. If this member is <c>NULL</c>, an application
 /// must explicitly set the cursor shape whenever the mouse moves into the application's window.
 /// </param>
 /// <param name="hbrBkgd">
 /// A handle to the class background brush. This member can be a handle to the brush to be used for painting the background, or it
 /// can be a color value. A color value must be one of the following standard system colors (the value 1 must be added to the chosen color).
 /// <para>
 /// The system automatically deletes class background brushes when the class is unregistered by using <see cref="UnregisterClass"/>.
 /// An application should not delete these brushes.
 /// </para>
 /// <para>
 /// When this member is <c>NULL</c>, an application must paint its own background whenever it is requested to paint in its client
 /// area. To determine whether the background must be painted, an application can either process the WM_ERASEBKGND message or test
 /// the <c>fErase</c> member of the PAINTSTRUCT structure filled by the BeginPaint function.
 /// </para>
 /// </param>
 /// <param name="menuName">
 /// A string that specifies the resource name of the class menu, as the name appears in the resource file. If you use an integer to
 /// identify the menu, use the MAKEINTRESOURCE macro. If this member is <c>NULL</c>, windows belonging to this class have no default menu.
 /// </param>
 /// <param name="extraBytes">
 /// The number of extra bytes to allocate following the window-class structure. The system initializes the bytes to zero.
 /// </param>
 /// <param name="extraWinBytes">
 /// The number of extra bytes to allocate following the window instance. The system initializes the bytes to zero. If an application
 /// uses <c>WNDCLASSEX</c> to register a dialog box created by using the <c>CLASS</c> directive in the resource file, it must set
 /// this member to <c>DLGWINDOWEXTRA</c>.
 /// </param>
 public WindowClass(string className, HINSTANCE hInst, WindowProc wndProc, WindowClassStyles styles = 0, HICON hIcon = default, HICON hSmIcon = default,
                    HCURSOR hCursor = default, HBRUSH hbrBkgd = default, string menuName = null, int extraBytes = 0, int extraWinBytes = 0)
 {
     // TODO: Find way to hold on to wndProc ref
     wc = new WNDCLASSEX
     {
         cbSize        = (uint)Marshal.SizeOf(typeof(WNDCLASSEX)),
         lpfnWndProc   = wndProc,
         hInstance     = hInst,
         lpszClassName = className,
         style         = styles,
         hIcon         = hIcon,
         hIconSm       = hSmIcon,
         hCursor       = hCursor,
         hbrBackground = hbrBkgd,
         lpszMenuName  = menuName,
         cbClsExtra    = extraBytes,
         cbWndExtra    = extraWinBytes,
     };
     Atom = Win32Error.ThrowLastErrorIfNull(Macros.MAKEINTATOM(RegisterClassEx(wc)));
 }
コード例 #6
0
 public WinapiHostFactory(string name, WindowClassStyles styles, IntPtr hInstance, IntPtr hIcon, IntPtr hCursor, IntPtr hBgBrush, WindowProc wndProc)
     : base(name, styles, hInstance, hIcon, hCursor, hBgBrush, wndProc)
 {
 }
コード例 #7
0
ファイル: User32.cs プロジェクト: Grabacr07/ResinTimer
 public static WindowClassStyles SetClassLong(IntPtr hwnd, ClassLongPtrIndex nIndex, WindowClassStyles dwNewLong)
 {
     return(Environment.Is64BitProcess
         ? (WindowClassStyles)SetClassLong64(hwnd, nIndex, (IntPtr)dwNewLong)
         : (WindowClassStyles)SetClassLong32(hwnd, nIndex, (IntPtr)dwNewLong));
 }
コード例 #8
0
        protected HintNativeWindow(IntPtr ownerHandle, WindowClassExFlags classFlags, WindowClassStyles classStyles, WindowStyles styles)
        {
            CreateParams cp = new CreateParams();

            cp.Parent      = ownerHandle;
            cp.Style       = (int)(WindowStyles.WS_DISABLED | styles);
            cp.ClassStyle |= (int)classStyles;
            cp.ExStyle     = (int)classFlags;

            CreateHandle(cp);
        }
コード例 #9
0
ファイル: User32.cs プロジェクト: CirnoV/MetroRadiance
 public static WindowClassStyles SetClassLong(IntPtr hwnd, ClassLongPtrIndex nIndex, WindowClassStyles dwNewLong)
 {
     return Environment.Is64BitProcess
         ? (WindowClassStyles)SetClassLong64(hwnd, nIndex, (IntPtr)dwNewLong)
         : (WindowClassStyles)SetClassLong32(hwnd, nIndex, (IntPtr)dwNewLong);
 }