Added interfaces from imagetranscode.h and inputpanelconfiguration to PInvoke.Shell

pull/299/head
dahall 2022-05-12 15:41:04 -06:00
parent e79edfe6e9
commit 38fe3335f3
2 changed files with 196 additions and 0 deletions

View File

@ -0,0 +1,76 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Vanara.PInvoke;
public static partial class Shell32
{
/// <summary>Indicates the format of the resulting image.</summary>
[PInvokeData("imagetranscode.h", MSDNShortId = "NN:imagetranscode.ITranscodeImage")]
public enum TI_FLAGS
{
/// <summary>Convert the image to BMP format.</summary>
TI_BITMAP = 1,
/// <summary>Convert the image to JPEG format.</summary>
TI_JPEG = 2
}
/// <summary>Exposes a method that allows conversion to JPEG or bitmap (BMP) image formats from any image type supported by Windows.</summary>
// https://docs.microsoft.com/en-us/windows/win32/api/imagetranscode/nn-imagetranscode-itranscodeimage
[PInvokeData("imagetranscode.h", MSDNShortId = "NN:imagetranscode.ITranscodeImage")]
[ComImport, Guid("BAE86DDD-DC11-421c-B7AB-CC55D1D65C44"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(ImageTranscode))]
public interface ITranscodeImage
{
/// <summary>Converts an image to JPEG or bitmap (BMP) image format.</summary>
/// <param name="pShellItem">
/// <para>Type: <c>IShellItem*</c></para>
/// <para>The Shell Item for the image to convert.</para>
/// </param>
/// <param name="uiMaxWidth">
/// <para>Type: <c>UINT</c></para>
/// <para>The requested height in pixels. Should be less than or equal to the actual height of the original image. See Remarks.</para>
/// </param>
/// <param name="uiMaxHeight">
/// <para>Type: <c>UINT</c></para>
/// <para>The requested width in pixels. Should be less than or equal to the actual width of the original image. See Remarks.</para>
/// </param>
/// <param name="flags">
/// <para>Type: <c>TI_FLAGS</c></para>
/// <para>One of the following flags.</para>
/// <para>TI_BITMAP</para>
/// <para>Convert the image to BMP format.</para>
/// <para>TI_JPEG</para>
/// <para>Convert the image to JPEG format.</para>
/// </param>
/// <param name="pvImage">
/// <para>Type: <c>IStream*</c></para>
/// <para>A stream to receive the converted image. The stream must be created by the calling code prior to calling <c>TranscodeImage</c>.</para>
/// </param>
/// <param name="puiWidth">
/// <para>Type: <c>UINT*</c></para>
/// <para>The actual width of the converted image.</para>
/// </param>
/// <param name="puiHeight">
/// <para>Type: <c>UINT*</c></para>
/// <para>The actual height of the converted image.</para>
/// </param>
/// <remarks>
/// <para>
/// The aspect ratio of the original image is preserved. The new image is resized so that it will fit into a box of width
/// <c>uiMaxWidth</c> and height <c>uiMaxHeight</c>.
/// </para>
/// <para>The image size will not be changed if the original image already fits in this bounding box.</para>
/// <para>If both uiMaxWidth and uiMaxHeight are zero, the returned image will be the same size as the original.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/imagetranscode/nf-imagetranscode-itranscodeimage-transcodeimage HRESULT
// TranscodeImage( [in] IShellItem *pShellItem, UINT uiMaxWidth, UINT uiMaxHeight, DWORD flags, IStream *pvImage, [out, optional]
// UINT *puiWidth, [out, optional] UINT *puiHeight );
void TranscodeImage([In] IShellItem pShellItem, uint uiMaxWidth, uint uiMaxHeight, TI_FLAGS flags, [In, Out] IStream pvImage, out uint puiWidth, out uint puiHeight);
}
/// <summary>CLSID_ImageTranscode</summary>
[ComImport, Guid("17B75166-928F-417d-9685-64AA135565C1"), ClassInterface(ClassInterfaceType.None)]
public class ImageTranscode { }
}

View File

@ -0,0 +1,120 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke;
public static partial class Shell32
{
/// <summary>Provides functionality for desktop apps to opt in to the focus tracking mechanism used in Windows Store apps.</summary>
/// <remarks>
/// <para><c>Warning</c>
/// <para></para>
/// <c>IInputPanelConfiguration</c> will not work in Windows 10.
/// </para>
/// <para>
/// Implement the <c>IInputPanelConfiguration</c> interface if your Desktop client processes need to leverage the invoking and dismissing
/// semantics of the touch keyboard and handwriting input panel.
/// </para>
/// <para>
/// The <c>IInputPanelConfiguration</c> interface enables your app to opt in to the focus tracking mechanism for Windows Store apps.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/inputpanelconfiguration/nn-inputpanelconfiguration-iinputpanelconfiguration
[PInvokeData("inputpanelconfiguration.h", MSDNShortId = "NN:inputpanelconfiguration.IInputPanelConfiguration")]
[ComImport, Guid("41C81592-514C-48BD-A22E-E6AF638521A6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(InputPanelConfiguration))]
public interface IInputPanelConfiguration
{
/// <summary>
/// Enables a client process to opt-in to the focus tracking mechanism for Windows Store apps that controls the invoking and
/// dismissing semantics of the touch keyboard.
/// </summary>
/// <returns>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</returns>
/// <remarks>
/// <c>Note</c>
/// <para></para>
/// This method will not work in Windows 10. A user can manually configure settings through the notification center or through the
/// <c>Typing</c> settings to enable pulling up a touch keyboard automatically when focusing on an edit control.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/inputpanelconfiguration/nf-inputpanelconfiguration-iinputpanelconfiguration-enablefocustracking
// HRESULT EnableFocusTracking();
[PreserveSig]
HRESULT EnableFocusTracking();
}
/// <summary>Enables Windows Store apps to opt out of the automatic invocation behavior.</summary>
/// <remarks>
/// Clients can request that the touch keyboard and handwriting input panel check to see that a user tapped in the edit control with
/// focus before invoking.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/inputpanelconfiguration/nn-inputpanelconfiguration-iinputpanelinvocationconfiguration
[PInvokeData("inputpanelconfiguration.h", MSDNShortId = "NN:inputpanelconfiguration.IInputPanelInvocationConfiguration")]
[ComImport, Guid("A213F136-3B45-4362-A332-EFB6547CD432"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IInputPanelInvocationConfiguration
{
/// <summary>Requires an explicit user tap in an edit field before the touch keyboard invokes.</summary>
/// <returns>The <c>RequireTouchInEditControl</c> method always returns <c>S_OK</c>.</returns>
/// <remarks>
/// <para>
/// When the <c>RequireTouchInEditControl</c> method is called, all future focus changes require an explicit user tap in an edit
/// field before the touch keyboard invokes. You can call the <c>RequireTouchInEditControl</c> method multiple times, but there's no
/// way to undo the setting.
/// </para>
/// <para>
/// This setting applies for any focus event that takes place to a window that is running in the process that called it. The
/// <c>RequireTouchInEditControl</c> method doesn't affect owned windows in another process that have an ownership chain to the
/// current process that called <c>RequireTouchInEditControl</c>.
/// </para>
/// <para>
/// The <c>RequireTouchInEditControl</c> method always returns <c>S_OK</c>. If this API is used, then the <c>IsUIBusy</c> property
/// has no effect. The two interaction models are essentially mutually exclusive.
/// </para>
/// <para>The following code shows how to call the <c>RequireTouchInEditControl</c> method.</para>
/// <para>
/// <code>#include &lt;inputpanelconfiguration.h&gt;
/// #include &lt;inputpanelconfiguration_i.c&gt;
///
/// IInputPanelInvocationConfiguration *pInputPanelInvocationConfiguration;
/// CoCreateInstance(CLSID_InputPanelConfiguration, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&amp;pInputPanelInvocationConfiguration));
/// pInputPanelInvocationConfiguration-&gt;RequireTouchInEditControl();</code>
/// </para>
/// <para>
/// <c>Note</c> Calling Release before the app finishes drawing UI can cause undefined behavior. If the touch keyboard isn't already
/// running, calling <c>Release</c> could cause tiptsf.dll to be unloaded, because there are no more references to the dll. If this
/// occurs, the state set by the <c>RequireTouchInEditControl</c> method is lost.
/// </para>
/// <para>
/// If you need to delay the invocation of the touch keyboard until a later time, like when animations or direct manipulation have
/// completed, use the <c>IsUIBusy</c> custom UI automation property. For more info, see Registering Custom Properties, Events, and
/// Control Patterns.
/// </para>
/// <para>
/// When you set <c>IsUIBusy</c> to <c>True</c>, the touch keyboard doesn't change visual state based on focus changes within the
/// app. It's still able to change visual state based on overriding user action, like using a physical keyboard or manual dismissal.
/// </para>
/// <para>
/// When you set <c>IsUIBusy</c> to <c>False</c>, the touch keyboard resumes its default behavior and queries synchronously for the
/// control that has focus.
/// </para>
/// <para>The following code shows how to register the <c>IsUIBusy</c> custom UI automation property.</para>
/// <para>
/// <code>/* 03391bea-6681-474b-955c-60f664397ac6 */
/// DEFINE_GUID( GUID_UIBusy, 0x03391bea, 0x6681, 0x474b, 0x95, 0x5c, 0x60, 0xf6, 0x64, 0x39, 0x7a, 0xc6);
/// UIAutomationPropertyInfo customPropertyInfo = { GUID_UIBusy, L"IsUIBusy", UIAutomationType_Bool };
/// CComPtr&lt;IUIAutomationRegistrar&gt; spRegistrar;
/// hr = spRegistrar.CoCreateInstance( CLSID_CUIAutomationRegistrar, nullptr, CLSCTX_INPROC_SERVER);
/// if (SUCCEEDED(hr)) {
/// PATTERNID customPropertyId;
/// hr = spRegistrar-&gt;RegisterProperty(&amp;customPropertyInfo, &amp;customPropertyId);
/// }</code>
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/inputpanelconfiguration/nf-inputpanelconfiguration-iinputpanelinvocationconfiguration-requiretouchineditcontrol
// HRESULT RequireTouchInEditControl();
[PreserveSig]
HRESULT RequireTouchInEditControl();
}
/// <summary>CLSID_InputPanelConfiguration</summary>
[ComImport, Guid("2853ADD3-F096-4C63-A78F-7FA3EA837FB7"), ClassInterface(ClassInterfaceType.None)]
public class InputPanelConfiguration { }
}