using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Shell32 { /// Values that indicate the reason that a docked accessibility app window has been undocked. Used by IAccessibilityDockingServiceCallback::Undocked. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/ne-shobjidl-undock_reason typedef enum UNDOCK_REASON { // UR_RESOLUTION_CHANGE, UR_MONITOR_DISCONNECT } ; [PInvokeData("shobjidl.h", MSDNShortId = "NE:shobjidl.UNDOCK_REASON")] public enum UNDOCK_REASON { /// The accessibility window was undocked because the screen resolution has changed. UR_RESOLUTION_CHANGE, /// The monitor on which the accessibility window was docked has been disconnected. UR_MONITOR_DISCONNECT, } /// /// Docks an application window to the bottom of a monitor when a Windows Store app is visible and not snapped, or when the launcher /// is visible. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nn-shobjidl-iaccessibilitydockingservice [ComImport, Guid("8849DC22-CEDF-4C95-998D-051419DD3F76"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(AccessibilityDockingService))] public interface IAccessibilityDockingService { /// Retrieves the dimensions available on a specific screen for displaying an accessibility window. /// /// Type: HMONITOR /// /// The handle of the monitor whose available docking size is to be retrieved. For information on how to retrieve an /// HMONITOR, see MonitorFromWindow. /// /// /// /// Type: UINT* /// /// When this method returns successfully, this parameter receives the fixed width, in physical pixels, available for docking on /// the specified monitor. Any window docked to this monitor will be sized to this width. /// /// If the method fails, this value is set to 0. /// If this value is NULL, an access violation will occur. /// /// /// Type: UINT* /// /// When this method returns successfully, this parameter receives the maximum height, in physical pixels, available for a /// docked window on the specified monitor. /// /// If the method fails, this value is set to 0. /// If this value is NULL, an access violation will occur. /// /// /// When to use /// /// A docked accessibility window is limited in the amount of space that it can use on any screen. Therefore, before trying to /// dock an accessibility window, call this function to get the available dimensions. You cannot dock any window that would /// cause a Windows Store app to have access to less than 768 vertical screen pixels. /// /// Examples /// This example shows this method in use. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-iaccessibilitydockingservice-getavailablesize HRESULT // GetAvailableSize( HMONITOR hMonitor, UINT *pcxFixed, UINT *pcyMax ); void GetAvailableSize(HMONITOR hMonitor, out uint pcxFixed, out uint pcyMax); /// Docks the specified window handle to the specified monitor handle. /// The accessibility application window that will be docked on the passed monitor handle. /// The monitor on which the accessibility application window will be docked. /// TBD /// The callback pointer on which the accessibility application will receive the Undock notification. /// /// This method can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// Success. /// /// /// E_INVALIDARG /// The window handle or monitor handle is not valid. /// /// /// E_ACCESSDENIED /// The calling process is not a UIAcess accessibility application or the calling process does not own the window. /// /// /// IMM_E_DOCKOCCUPIED /// There is already another window occupying the docking space. Only one window can be docked at a time. /// /// /// IMM_E_INSUFFICIENTHEIGHT /// /// The requested uHeight is larger than the maximum allowed docking height for the specified monitor. However, if this error /// code is being returned, it means that this monitor does support docking, though at a height indicated by a call to the /// GetAvailableSize method. /// /// /// /// HRESULT_FROM_WIN32(ERROR_INVALID_MONITOR_HANDLE) /// The monitor specified by the monitor handle does not support docking. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-iaccessibilitydockingservice-dockwindow HRESULT // DockWindow( HWND hwnd, HMONITOR hMonitor, UINT cyRequested, IAccessibilityDockingServiceCallback *pCallback ); void DockWindow(HWND hwnd, HMONITOR hMonitor, [Optional] uint cyRequested, IAccessibilityDockingServiceCallback pCallback); /// Undocks the specified window handle if it is currently docked. /// TBD /// /// This method can only be used to undock windows that belong to the calling process. /// Examples /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-iaccessibilitydockingservice-undockwindow HRESULT // UndockWindow( HWND hwnd ); void UndockWindow(HWND hwnd); } /// Receives Acessibility Window Docking events. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nn-shobjidl-iaccessibilitydockingservicecallback [PInvokeData("shobjidl.h", MSDNShortId = "NN:shobjidl.IAccessibilityDockingServiceCallback")] [ComImport, Guid("157733FD-A592-42E5-B594-248468C5A81B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAccessibilityDockingServiceCallback { /// Undocks the accessibility window so that it will not be automatically moved to its previous location. /// Specifies the reason why the accessibility application's window was undocked. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-iaccessibilitydockingservicecallback-undocked HRESULT // Undocked( UNDOCK_REASON undockReason ); [PreserveSig] HRESULT Undocked(UNDOCK_REASON undockReason); } /// CoClass for IAccessibilityDockingService [PInvokeData("shobjidl.h")] [ComImport, Guid("29CE1D46-B481-4AA0-A08A-D3EBC8ACA402"), ClassInterface(ClassInterfaceType.None)] public class AccessibilityDockingService { } } }