示例#1
0
        /// <summary>
        /// Method used to create the window. When overriding, the <c>hWnd</c> field must be set to the handle of the created window.
        /// </summary>
        protected virtual SafeHWND CreateWindow()
        {
            HINSTANCE hInst = GetModuleHandle();

            wCls = new WindowClass($"{GetType().Name}+{Guid.NewGuid()}", hInst, WndProc);
            return(Win32Error.ThrowLastErrorIfInvalid(CreateWindowEx(0, wCls.Atom, hWndParent: HWND.HWND_MESSAGE, hInstance: hInst)));
        }
示例#2
0
        public Form1()
        {
            InitializeComponent();

            hInst = Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]);

            WindowRegister(hInst);
        }
示例#3
0
 public static extern HANDLE LoadImageW(
     HINSTANCE hInst,
     IntPtr name,
     Win32ImageType type,
     int cx,
     int cy,
     Win32LoadImageFlags fuLoad
     );
示例#4
0
 /// <summary>
 /// Method used to create the window. When overriding, the <c>hWnd</c> field must be set to the handle of the created window.
 /// </summary>
 protected virtual SafeHWND CreateWindow()
 {
     lock (this)
     {
         if (!Handle.IsNull)
         {
             throw new InvalidOperationException("Window handle already exists.");
         }
         HINSTANCE hInst = GetModuleHandle();
         wCls = new WindowClass($"{GetType().Name}+{Guid.NewGuid()}", hInst, WndProc);
         return(Win32Error.ThrowLastErrorIfInvalid(CreateWindowEx(0, wCls.Atom, hWndParent: HWND.HWND_MESSAGE, hInstance: hInst)));
     }
 }
示例#5
0
 public static extern HWND CreateWindowExW(
     DWORD dwExStyle,
     [MarshalAs(UnmanagedType.LPWStr)] string lpClassName,
     [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName,
     Win32WindowStyle dwStyle,
     int x,
     int y,
     int nWidth,
     int nHeight,
     HWND hWndParent,
     HMENU hMenu,
     HINSTANCE hInstance,
     LPVOID lpParam
     );
示例#6
0
        // FUNCTION: WinMain()
        //
        // PURPOSE: Entry point for the application.
        private static int Main()
        {
            if (!MagInitialize())
            {
                return(0);
            }
            using var uninitMag = new GenericSafeHandle(p => MagUninitialize());

            hInst = GetModuleHandle();
            if (!SetupMagnifier(hInst))
            {
                return(0);
            }

            ShowWindow(hwndHost, ShowWindowCommand.SW_NORMAL);
            UpdateWindow(hwndHost);

            // Create a timer to update the control.
            var timerId = SetTimer(hwndHost, default, timerInterval, UpdateMagWindow);
示例#7
0
        private ATOM WindowRegister(HINSTANCE hInstance)
        {
            WndMainProc = new WNDPROC(WndProc);

            WNDCLASSEX wnd;

            wnd.cbClsExtra    = 0;
            wnd.cbSize        = (UInt32)Marshal.SizeOf(typeof(WNDCLASSEX));
            wnd.cbWndExtra    = 0;
            wnd.hbrBackground = IntPtr.Zero;
            wnd.hCursor       = Cursors.Arrow.Handle;
            wnd.hIcon         = IntPtr.Zero;
            wnd.hIconSm       = IntPtr.Zero;
            wnd.hInstance     = hInstance;
            wnd.lpfnWndProc   = WndMainProc;
            wnd.lpszClassName = "Form2";
            wnd.lpszMenuName  = null;
            wnd.style         = 0x0008;

            return(RegisterClassEx(ref wnd));
        }
示例#8
0
 /// <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)));
 }
示例#9
0
 public static string LoadString(HINSTANCE hInstance, uint uID, int maxLength)
 {
     StringBuilder lpBuffer = new StringBuilder(0x100);
     int num = 0;
     while (((num = LoadString(hInstance, uID, lpBuffer, lpBuffer.Capacity)) >= (lpBuffer.Capacity - 1)) && (lpBuffer.Capacity <= maxLength))
     {
         lpBuffer.Capacity *= 2;
     }
     if (num == 0)
     {
         return null;
     }
     return lpBuffer.ToString();
 }
示例#10
0
    public static int Run(DXSample sample, HINSTANCE hInstance, int nCmdShow)
    {
        var useWarpDevice = false;

        // Parse the command line parameters
        foreach (var arg in Environment.GetCommandLineArgs())
        {
            if (Program.Matches(arg, "warp"))
            {
                useWarpDevice = true;
                continue;
            }
        }

        fixed(char *lpszClassName = "DXSampleClass")
        fixed(char *lpWindowName = sample.Name)
        {
            // Initialize the window class.
            var windowClass = new WNDCLASSEXW {
                cbSize        = (uint)sizeof(WNDCLASSEXW),
                style         = CS_HREDRAW | CS_VREDRAW,
                lpfnWndProc   = &WindowProc,
                hInstance     = hInstance,
                hCursor       = LoadCursorW(HINSTANCE.NULL, (ushort *)IDC_ARROW),
                lpszClassName = (ushort *)lpszClassName
            };

            _ = RegisterClassExW(&windowClass);

            // Create the window and store a handle to it.
            s_hwnd = CreateWindowExW(
                0,
                windowClass.lpszClassName,
                (ushort *)lpWindowName,
                WS_OVERLAPPEDWINDOW,
                CW_USEDEFAULT,
                CW_USEDEFAULT,
                CW_USEDEFAULT,
                CW_USEDEFAULT,
                HWND.NULL,                       // We have no parent window.
                HMENU.NULL,                      // We aren't using menus.
                hInstance,
                ((IntPtr)GCHandle.Alloc(sample)).ToPointer()
                );
        }

        RECT windowRect;

        _ = GetClientRect(s_hwnd, &windowRect);

        // Initialize the sample. OnInit is defined in each child-implementation of DXSample.
        var backgroundColor = new Vector4(0.0f, 0.2f, 0.4f, 1.0f);

        var size = new Size(windowRect.right - windowRect.left, windowRect.bottom - windowRect.top);

        sample.OnInit(DXGI_FORMAT_UNKNOWN, backgroundColor, DXGI_FORMAT_UNKNOWN, 1.0f, 2, s_hwnd, true, size, useWarpDevice);

        _ = ShowWindow(s_hwnd, nCmdShow);

        // Main sample loop.
        MSG msg;

        DispatchPending(&msg);

        var lastFramesPerSecond = 0u;

        while (msg.message != WM_QUIT)
        {
            var delta = sample.OnBeginFrame();
            sample.OnUpdate(delta);

            var framesPerSecond = sample.FramesPerSecond;

            if (framesPerSecond != lastFramesPerSecond)
            {
                fixed(char *lpWindowName = $"{sample.Name} ({framesPerSecond} fps)")
                {
                    _ = SetWindowTextW(s_hwnd, (ushort *)lpWindowName);
                }

                lastFramesPerSecond = framesPerSecond;
            }

            if (sample.IsWindowVisible)
            {
                sample.OnRender();
            }

            DispatchPending(&msg);
        }

        sample.OnDestroy();

        // Return this part of the WM_QUIT message to Windows.
        return((int)msg.wParam);
示例#11
0
 public static extern SimulatorIntPtr Create(HINSTANCE instance, HWND parenthwnd, bool showonprimary, bool fullscreen);
示例#12
0
 public static extern HWND CreateWindowEx(
     DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
     DWORD dwStyle, Int32 x, Int32 y, Int32 nWidth, Int32 nHeight,
     HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, [MarshalAs(UnmanagedType.AsAny)] object pvParam);
示例#13
0
 public static extern int LoadString(HINSTANCE hInstance, int uID, out IntPtr lpBuffer, int nBufferMax);
示例#14
0
 public static extern HRESULT TaskDialog(HWND hwndParent, HINSTANCE hInstance, string pszWindowTitle, string pszMainInstruction, string pszContent, TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons, SafeResourceId pszIcon, out int pnButton);
示例#15
0
文件: API.cs 项目: jpbruyere/opentk
 internal static extern BOOL GetClassInfoEx(HINSTANCE hinst, UIntPtr lpszClass, ref ExtendedWindowClass lpwcx);
示例#16
0
文件: API.cs 项目: jpbruyere/opentk
 public static extern HCURSOR LoadCursor(HINSTANCE hInstance, LPCTSTR lpCursorName);
示例#17
0
 WindowsDynamicLibrary(HINSTANCE handle) :
示例#18
0
 public static extern HACCEL LoadAccelerators(HINSTANCE hInstance, string lpTableName);
示例#19
0
 public static extern HHOOK SetWindowsHookEx(int idHook, LowLevelMouseProc lpfn, HINSTANCE hMod, int dwThreadId);
        public static int Run(DXSample pSample, HINSTANCE hInstance, int nCmdShow)
        {
            var useWarpDevice = false;

            // Parse the command line parameters
            foreach (var arg in Environment.GetCommandLineArgs())
            {
                if (Program.Matches(arg, "warp"))
                {
                    useWarpDevice = true;
                    continue;
                }
            }

            fixed(char *lpszClassName = "DXSampleClass")
            fixed(char *lpWindowName = pSample.Name)
            {
                // Initialize the window class.
                var windowClass = new WNDCLASSEXW {
                    cbSize        = (uint)sizeof(WNDCLASSEXW),
                    style         = CS_HREDRAW | CS_VREDRAW,
                    lpfnWndProc   = &WindowProc,
                    hInstance     = hInstance,
                    hCursor       = LoadCursorW(IntPtr.Zero, (ushort *)IDC_ARROW),
                    lpszClassName = (ushort *)lpszClassName
                };

                _ = RegisterClassExW(&windowClass);

                // Create the window and store a handle to it.
                s_hwnd = CreateWindowExW(
                    0,
                    windowClass.lpszClassName,
                    (ushort *)lpWindowName,
                    WS_OVERLAPPEDWINDOW,
                    CW_USEDEFAULT,
                    CW_USEDEFAULT,
                    CW_USEDEFAULT,
                    CW_USEDEFAULT,
                    HWND.NULL,                              // We have no parent window.
                    HMENU.NULL,                             // We aren't using menus.
                    hInstance,
                    ((IntPtr)GCHandle.Alloc(pSample)).ToPointer()
                    );
            }

            RECT windowRect;

            _ = GetClientRect(s_hwnd, &windowRect);

            // Initialize the sample. OnInit is defined in each child-implementation of DXSample.
            var backgroundColor = new Vector4(0.0f, 0.2f, 0.4f, 1.0f);

            var size = new Size((windowRect.right - windowRect.left), (windowRect.bottom - windowRect.top));

            pSample.OnInit(DXGI_FORMAT_UNKNOWN, backgroundColor, DXGI_FORMAT_UNKNOWN, 1.0f, 2, s_hwnd, true, size, useWarpDevice);

            _ = ShowWindow(s_hwnd, nCmdShow);

            // Main sample loop.
            MSG msg;

            do
            {
                // Process any messages in the queue.
                if (PeekMessageW(&msg, IntPtr.Zero, 0, 0, PM_REMOVE) != 0)
                {
                    _ = TranslateMessage(&msg);
                    _ = DispatchMessageW(&msg);
                }
            }while (msg.message != WM_QUIT);

            pSample.OnDestroy();

            // Return this part of the WM_QUIT message to Windows.
            return((int)msg.wParam);
        }
示例#21
0
 public static extern HCURSOR LoadCursorW(HINSTANCE hInstance, uint lpCursorName);
示例#22
0
 public static extern void CoFreeLibrary(HINSTANCE hInst);
示例#23
0
 public static extern int LoadString(HINSTANCE hInstance, uint uID, [Out] StringBuilder lpBuffer, int nBufferMax);
示例#24
0
 public static extern IntPtr LoadImage(HINSTANCE hinst, SafeResourceId lpszName, LoadImageType uType, int cxDesired, int cyDesired, LoadImageOptions fuLoad);
示例#25
0
 public static extern bool UnregisterClass(string hlpClass, HINSTANCE hInstance);
示例#26
0
 /// <summary>Loads a cursor or animated cursor.</summary>
 /// <param name="hinst">
 /// A handle to the module of either a DLL or executable (.exe) that contains the image to be loaded. For more information, see
 /// GetModuleHandle. Note that as of 32-bit Windows, an instance handle (HINSTANCE), such as the application instance handle exposed
 /// by system function call of WinMain, and a module handle (HMODULE) are the same thing.
 /// <para>To load an OEM image, set this parameter to NULL.</para>
 /// <para>To load a stand-alone resource (icon, cursor, or bitmap file)—for example, c:\myimage.bmp—set this parameter to NULL.</para>
 /// </param>
 /// <param name="lpszName">
 /// The image to be loaded. If the hinst parameter is non-NULL and the fuLoad parameter omits LR_LOADFROMFILE, lpszName specifies the
 /// image resource in the hinst module. If the image resource is to be loaded by name from the module, the lpszName parameter is a
 /// pointer to a null-terminated string that contains the name of the image resource. If the image resource is to be loaded by
 /// ordinal from the module, use the MAKEINTRESOURCE macro to convert the image ordinal into a form that can be passed to the
 /// LoadImage function. For more information, see the Remarks section below.
 /// <para>
 /// If the hinst parameter is NULL and the fuLoad parameter omits the LR_LOADFROMFILE value, the lpszName specifies the OEM image to load.
 /// </para>
 /// <para>
 /// To pass these constants to the LoadImage function, use the MAKEINTRESOURCE macro. For example, to load the OCR_NORMAL cursor,
 /// pass MAKEINTRESOURCE(OCR_NORMAL) as the lpszName parameter, NULL as the hinst parameter, and LR_SHARED as one of the flags to the
 /// fuLoad parameter.
 /// </para>
 /// <para>
 /// If the fuLoad parameter includes the LR_LOADFROMFILE value, lpszName is the name of the file that contains the stand-alone
 /// resource (icon, cursor, or bitmap file). Therefore, set hinst to NULL.
 /// </para>
 /// </param>
 /// <param name="cxDesired">
 /// The width, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function
 /// uses the SM_CXICON or SM_CXCURSOR system metric value to set the width. If this parameter is zero and LR_DEFAULTSIZE is not used,
 /// the function uses the actual resource width.
 /// </param>
 /// <param name="cyDesired">
 /// The height, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function
 /// uses the SM_CYICON or SM_CYCURSOR system metric value to set the height. If this parameter is zero and LR_DEFAULTSIZE is not
 /// used, the function uses the actual resource height.
 /// </param>
 /// <param name="fuLoad">Loading options.</param>
 /// <returns>
 /// If the function succeeds, the return value is the handle of the newly loaded image. If the function fails, the return value is
 /// NULL.To get extended error information, call GetLastError.
 /// </returns>
 public static SafeHCURSOR LoadImage_Cursor(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
 new SafeHCURSOR(LoadImage(hinst, lpszName, LoadImageType.IMAGE_CURSOR, cxDesired, cyDesired, fuLoad), true);
示例#27
0
文件: API.cs 项目: jpbruyere/opentk
 internal static extern BOOL GetClassInfoEx(HINSTANCE hinst,
     [MarshalAs(UnmanagedType.LPTStr)] LPCTSTR lpszClass, ref ExtendedWindowClass lpwcx);
示例#28
0
 /// <summary>Loads an icon.</summary>
 /// <param name="hinst">
 /// A handle to the module of either a DLL or executable (.exe) that contains the image to be loaded. For more information, see
 /// GetModuleHandle. Note that as of 32-bit Windows, an instance handle (HINSTANCE), such as the application instance handle exposed
 /// by system function call of WinMain, and a module handle (HMODULE) are the same thing.
 /// <para>To load an OEM image, set this parameter to NULL.</para>
 /// <para>To load a stand-alone resource (icon, cursor, or bitmap file)—for example, c:\myimage.bmp—set this parameter to NULL.</para>
 /// </param>
 /// <param name="lpszName">
 /// The image to be loaded. If the hinst parameter is non-NULL and the fuLoad parameter omits LR_LOADFROMFILE, lpszName specifies the
 /// image resource in the hinst module. If the image resource is to be loaded by name from the module, the lpszName parameter is a
 /// pointer to a null-terminated string that contains the name of the image resource. If the image resource is to be loaded by
 /// ordinal from the module, use the MAKEINTRESOURCE macro to convert the image ordinal into a form that can be passed to the
 /// LoadImage function. For more information, see the Remarks section below.
 /// <para>
 /// If the hinst parameter is NULL and the fuLoad parameter omits the LR_LOADFROMFILE value, the lpszName specifies the OEM image to load.
 /// </para>
 /// <para>
 /// To pass these constants to the LoadImage function, use the MAKEINTRESOURCE macro. For example, to load the OCR_NORMAL cursor,
 /// pass MAKEINTRESOURCE(OCR_NORMAL) as the lpszName parameter, NULL as the hinst parameter, and LR_SHARED as one of the flags to the
 /// fuLoad parameter.
 /// </para>
 /// <para>
 /// If the fuLoad parameter includes the LR_LOADFROMFILE value, lpszName is the name of the file that contains the stand-alone
 /// resource (icon, cursor, or bitmap file). Therefore, set hinst to NULL.
 /// </para>
 /// </param>
 /// <param name="cxDesired">
 /// The width, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function
 /// uses the SM_CXICON or SM_CXCURSOR system metric value to set the width. If this parameter is zero and LR_DEFAULTSIZE is not used,
 /// the function uses the actual resource width.
 /// </param>
 /// <param name="cyDesired">
 /// The height, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function
 /// uses the SM_CYICON or SM_CYCURSOR system metric value to set the height. If this parameter is zero and LR_DEFAULTSIZE is not
 /// used, the function uses the actual resource height.
 /// </param>
 /// <param name="fuLoad">Loading options.</param>
 /// <returns>
 /// If the function succeeds, the return value is the handle of the newly loaded image. If the function fails, the return value is
 /// NULL.To get extended error information, call GetLastError.
 /// </returns>
 public static SafeHICON LoadImage_Icon(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
 new SafeHICON(LoadImage(hinst, lpszName, LoadImageType.IMAGE_ICON, cxDesired, cyDesired, fuLoad), true);
示例#29
0
文件: API.cs 项目: jpbruyere/opentk
 public static extern HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName);
示例#30
0
 public static extern HWND CreateToolbarEx64(HWND hwnd, [NativeTypeName("DWORD")] uint ws, uint wID, int nBitmaps, HINSTANCE hBMInst, [NativeTypeName("UINT_PTR")] nuint wBMID, [NativeTypeName("LPCTBBUTTON")] TBBUTTON64 *lpButtons, int iNumButtons, int dxButton, int dyButton, int dxBitmap, int dyBitmap, uint uStructSize);
示例#31
0
文件: API.cs 项目: jpbruyere/opentk
 public static extern HCURSOR LoadCursor(HINSTANCE hInstance, IntPtr lpCursorName);
示例#32
0
 public static extern HWND CreateUpDownControl(uint dwStyle, int x, int y, int cx, int cy, HWND hParent, int nID, HINSTANCE hInst, HWND hBuddy, int nUpper, int nLower, int nPos);
示例#33
0
 public static extern SafeHookHandle SetWindowsHookEx(HookType idHook, HookProc lpfn, HINSTANCE hMod, int dwThreadId);
示例#34
0
 public static extern HWND CreateWindowEx(uint dwExStyle, string stClassName, string stTitle, uint dwStyle, int x, int y, int w, int h, HWND hwndParent, HMENU hmenu, HINSTANCE hinst, [MarshalAs(UnmanagedType.AsAny)] object pvParam);
示例#35
0
 /// <summary>Loads a bitmap.</summary>
 /// <param name="hinst">
 /// A handle to the module of either a DLL or executable (.exe) that contains the image to be loaded. For more information, see
 /// GetModuleHandle. Note that as of 32-bit Windows, an instance handle (HINSTANCE), such as the application instance handle exposed
 /// by system function call of WinMain, and a module handle (HMODULE) are the same thing.
 /// <para>To load an OEM image, set this parameter to NULL.</para>
 /// <para>To load a stand-alone resource (icon, cursor, or bitmap file)—for example, c:\myimage.bmp—set this parameter to NULL.</para>
 /// </param>
 /// <param name="lpszName">
 /// The image to be loaded. If the hinst parameter is non-NULL and the fuLoad parameter omits LR_LOADFROMFILE, lpszName specifies the
 /// image resource in the hinst module. If the image resource is to be loaded by name from the module, the lpszName parameter is a
 /// pointer to a null-terminated string that contains the name of the image resource. If the image resource is to be loaded by
 /// ordinal from the module, use the MAKEINTRESOURCE macro to convert the image ordinal into a form that can be passed to the
 /// LoadImage function. For more information, see the Remarks section below.
 /// <para>
 /// If the hinst parameter is NULL and the fuLoad parameter omits the LR_LOADFROMFILE value, the lpszName specifies the OEM image to load.
 /// </para>
 /// <para>
 /// To pass these constants to the LoadImage function, use the MAKEINTRESOURCE macro. For example, to load the OCR_NORMAL cursor,
 /// pass MAKEINTRESOURCE(OCR_NORMAL) as the lpszName parameter, NULL as the hinst parameter, and LR_SHARED as one of the flags to the
 /// fuLoad parameter.
 /// </para>
 /// <para>
 /// If the fuLoad parameter includes the LR_LOADFROMFILE value, lpszName is the name of the file that contains the stand-alone
 /// resource (icon, cursor, or bitmap file). Therefore, set hinst to NULL.
 /// </para>
 /// </param>
 /// <param name="cxDesired">
 /// The width, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function
 /// uses the SM_CXICON or SM_CXCURSOR system metric value to set the width. If this parameter is zero and LR_DEFAULTSIZE is not used,
 /// the function uses the actual resource width.
 /// </param>
 /// <param name="cyDesired">
 /// The height, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function
 /// uses the SM_CYICON or SM_CYCURSOR system metric value to set the height. If this parameter is zero and LR_DEFAULTSIZE is not
 /// used, the function uses the actual resource height.
 /// </param>
 /// <param name="fuLoad">Loading options.</param>
 /// <returns>
 /// If the function succeeds, the return value is the handle of the newly loaded image. If the function fails, the return value is
 /// NULL.To get extended error information, call GetLastError.
 /// </returns>
 public static SafeHBITMAP LoadImage_Bitmap(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
 new SafeHBITMAP(LoadImage(hinst, lpszName, LoadImageType.IMAGE_BITMAP, cxDesired, cyDesired, fuLoad), true);
示例#36
0
 public static extern HICON ExtractIcon(HINSTANCE hinst, string stExeFileName, int nIconIndex);
示例#37
0
 /// <summary>Loads an enhanced metafile.</summary>
 /// <param name="hinst">
 /// A handle to the module of either a DLL or executable (.exe) that contains the image to be loaded. For more information, see
 /// GetModuleHandle. Note that as of 32-bit Windows, an instance handle (HINSTANCE), such as the application instance handle exposed
 /// by system function call of WinMain, and a module handle (HMODULE) are the same thing.
 /// <para>To load an OEM image, set this parameter to NULL.</para>
 /// <para>To load a stand-alone resource (icon, cursor, or bitmap file)—for example, c:\myimage.bmp—set this parameter to NULL.</para>
 /// </param>
 /// <param name="lpszName">
 /// The image to be loaded. If the hinst parameter is non-NULL and the fuLoad parameter omits LR_LOADFROMFILE, lpszName specifies the
 /// image resource in the hinst module. If the image resource is to be loaded by name from the module, the lpszName parameter is a
 /// pointer to a null-terminated string that contains the name of the image resource. If the image resource is to be loaded by
 /// ordinal from the module, use the MAKEINTRESOURCE macro to convert the image ordinal into a form that can be passed to the
 /// LoadImage function. For more information, see the Remarks section below.
 /// <para>
 /// If the hinst parameter is NULL and the fuLoad parameter omits the LR_LOADFROMFILE value, the lpszName specifies the OEM image to load.
 /// </para>
 /// <para>
 /// To pass these constants to the LoadImage function, use the MAKEINTRESOURCE macro. For example, to load the OCR_NORMAL cursor,
 /// pass MAKEINTRESOURCE(OCR_NORMAL) as the lpszName parameter, NULL as the hinst parameter, and LR_SHARED as one of the flags to the
 /// fuLoad parameter.
 /// </para>
 /// <para>
 /// If the fuLoad parameter includes the LR_LOADFROMFILE value, lpszName is the name of the file that contains the stand-alone
 /// resource (icon, cursor, or bitmap file). Therefore, set hinst to NULL.
 /// </para>
 /// </param>
 /// <param name="cxDesired">
 /// The width, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function
 /// uses the SM_CXICON or SM_CXCURSOR system metric value to set the width. If this parameter is zero and LR_DEFAULTSIZE is not used,
 /// the function uses the actual resource width.
 /// </param>
 /// <param name="cyDesired">
 /// The height, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function
 /// uses the SM_CYICON or SM_CYCURSOR system metric value to set the height. If this parameter is zero and LR_DEFAULTSIZE is not
 /// used, the function uses the actual resource height.
 /// </param>
 /// <param name="fuLoad">Loading options.</param>
 /// <returns>
 /// If the function succeeds, the return value is the handle of the newly loaded image. If the function fails, the return value is
 /// NULL.To get extended error information, call GetLastError.
 /// </returns>
 public static SafeHENHMETAFILE LoadImage_EnhMetaFile(HINSTANCE hinst, SafeResourceId lpszName, int cxDesired, int cyDesired, LoadImageOptions fuLoad) =>
 new SafeHENHMETAFILE(LoadImage(hinst, lpszName, LoadImageType.IMAGE_ENHMETAFILE, cxDesired, cyDesired, fuLoad), true);
示例#38
0
 public static extern bool FreeLibrary(HINSTANCE hinst);
示例#39
0
 public static extern int LoadString(HINSTANCE hInstance, int uID, StringBuilder lpBuffer, int nBufferMax);
示例#40
0
 public static extern HCURSOR LoadCursor(HINSTANCE hinstance, string stCursorName);
示例#41
0
        /// <summary>Initializes a new instance of the <see cref="Window" /> class.</summary>
        internal Window(IDispatchManager dispatchManager, LPWSTR lpClassName, LPWSTR lpWindowName, HINSTANCE hInstance)
        {
            var hWnd = CreateWindowEx(
                WS_EX.OVERLAPPEDWINDOW,
                lpClassName,
                lpWindowName,
                WS.OVERLAPPEDWINDOW,
                unchecked ((int)(CW.USEDEFAULT)),
                unchecked ((int)(CW.USEDEFAULT)),
                unchecked ((int)(CW.USEDEFAULT)),
                unchecked ((int)(CW.USEDEFAULT)),
                HWND.NULL,
                HMENU.NULL,
                hInstance,
                null
                );

            if (hWnd == HWND.NULL)
            {
                ExceptionUtilities.ThrowExternalExceptionForLastError(nameof(CreateWindowEx));
            }

            _hWnd       = hWnd;
            _dispatcher = dispatchManager.DispatcherForCurrentThread;
            _properties = new PropertySet();

            var succeeded = GetWindowRect(_hWnd, out var lpRect);

            if (!succeeded)
            {
                ExceptionUtilities.ThrowExternalExceptionForLastError(nameof(GetWindowRect));
            }

            _bounds = new Rectangle(lpRect.left, lpRect.top, (lpRect.right - lpRect.left), (lpRect.bottom - lpRect.top));

            var activeWindow = GetActiveWindow();

            _isActive = (activeWindow == _hWnd);

            _isVisible = IsWindowVisible(hWnd);
        }
示例#42
0
 public static extern IntPtr LoadImage(HINSTANCE hinst, string stName, uint nType, int cxDesired, int cyDesired, uint nFlags);
 public HRESULT SetAnimation(HINSTANCE hInstAnimation, uint idAnimation)
 {
     return(((delegate * unmanaged <IProgressDialog *, HINSTANCE, uint, int>)(lpVtbl[6]))((IProgressDialog *)Unsafe.AsPointer(ref this), hInstAnimation, idAnimation));
 }
示例#44
0
 public static string LoadString(HINSTANCE hInstance, uint uID)
 {
     return LoadString(hInstance, uID, 0x100000);
 }