using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using Vanara.Collections;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Ole32
{
/// The highest allowed value for an OLE error code.
public const uint OLE_E_LAST = 0x800400FF;
/// The lowest allowed value for an OLE command error code.
public const uint OLECMDERR_E_FIRST = OLE_E_LAST+1;
/// Command parameter is not recognized as a valid command
public const uint OLECMDERR_E_NOTSUPPORTED = OLECMDERR_E_FIRST;
/// The command identified by nCmdID is currently disabled and cannot be executed.
public const uint OLECMDERR_E_DISABLED = OLECMDERR_E_FIRST+1;
/// The caller has asked for help on the command identified by nCmdID, but no help is available.
public const uint OLECMDERR_E_NOHELP = OLECMDERR_E_FIRST+2;
/// The user canceled the execution of the command.
public const uint OLECMDERR_E_CANCELED = OLECMDERR_E_FIRST+3;
/// Command group parameter is non-NULL but does not specify a recognized command group
public const uint OLECMDERR_E_UNKNOWNGROUP = OLECMDERR_E_FIRST+4;
/// Indicates that all the remaining pages should be printed.
public const ushort PAGESET_TOLASTPAGE = unchecked((ushort)-1);
/// Provides miscellaneous property information about a document object.
///
///
/// Objects that have a limited user interface for activation purposes should set DOCMISC_CANTOPENEDIT. Those that support
/// IPersistStorage only as a persistence mechanism should specify DOCMISC_NOFILESUPPORT. Otherwise, an object must also implement IPersistFile.
///
/// A combination of values from DOCMISC is returned at the location specified by the pdwStatus parameter in IOleDocument::GetDocMiscStatus.
/// If an object requires none of these flags, it must write a zero to the pdwStatus parameter.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/ne-docobj-docmisc typedef enum __MIDL_IOleDocument_0001 {
// DOCMISC_CANCREATEMULTIPLEVIEWS, DOCMISC_SUPPORTCOMPLEXRECTANGLES, DOCMISC_CANTOPENEDIT, DOCMISC_NOFILESUPPORT } DOCMISC;
[PInvokeData("docobj.h", MSDNShortId = "NE:docobj.__MIDL_IOleDocument_0001")]
[Flags]
public enum DOCMISC
{
/// Object supports multiple views.
DOCMISC_CANCREATEMULTIPLEVIEWS = 1,
/// Object supports complex rectangles and therefore implements IOleDocumentView::SetRectComplex.
DOCMISC_SUPPORTCOMPLEXRECTANGLES = 2,
/// Object supports activation in a separate window and therefore implements IOleDocumentView::Open.
DOCMISC_CANTOPENEDIT = 4,
/// Object does not support file read/write.
DOCMISC_NOFILESUPPORT = 8,
}
///
[PInvokeData("docobj.h")]
[Flags]
public enum IGNOREMIME
{
///
IGNOREMIME_PROMPT = 0x00000001,
///
IGNOREMIME_TEXT = 0x00000002,
}
///
[PInvokeData("docobj.h")]
public enum MEDIAPLAYBACK_STATE
{
///
MEDIAPLAYBACK_RESUME = 0,
///
MEDIAPLAYBACK_PAUSE = 1,
///
MEDIAPLAYBACK_PAUSE_AND_SUSPEND = 2,
///
MEDIAPLAYBACK_RESUME_FROM_SUSPEND = 3,
}
/// Specifies command execution options.
[PInvokeData("docobj.h")]
public enum OLECMDEXECOPT
{
/// Prompt the user for input or not, whichever is the default behavior.
OLECMDEXECOPT_DODEFAULT = 0,
/// Execute the command after obtaining user input.
OLECMDEXECOPT_PROMPTUSER = 1,
///
/// Execute the command without prompting the user. For example, clicking the Print toolbar button causes a document to be
/// immediately printed without user input.
///
OLECMDEXECOPT_DONTPROMPTUSER = 2,
/// Show help for the corresponding command, but do not execute.
OLECMDEXECOPT_SHOWHELP = 3
}
/// Specifies the type of support provided by an object for the command specified in an OLECMD structure.
[PInvokeData("docobj.h")]
[Flags]
public enum OLECMDF
{
/// The command is supported by this object.
OLECMDF_SUPPORTED = 0x00000001,
/// The command is available and enabled.
OLECMDF_ENABLED = 0x00000002,
/// The command is an on-off toggle and is currently on.
OLECMDF_LATCHED = 0x00000004,
/// Reserved for future use.
OLECMDF_NINCHED = 0x00000008,
/// The command is hidden.
OLECMDF_INVISIBLE = 0x00000010,
/// The command is hidden on the context menu.
OLECMDF_DEFHIDEONCTXTMENU = 0x00000020,
}
///
/// Specifies which standard command is to be executed. A single value from this enumeration is passed in the nCmdID argument of IOleCommandTarget::Exec.
///
///
///
/// In OLE Compound Documents technology, an object that is being edited in-place disables the Zoom control on its toolbar
/// and the Zoom command on its View menu, because, the Zoom command applies logically to the container
/// document, not to the object. The OLECMDID_ZOOM and OLECMDID_GETZOOMRANGE commands notify the container's frame object of the
/// zoom range it should use to display a document object in its user interface. The container frame is the client-side object that
/// implements IOleInPlaceFrame and, optionally, IOleCommandTarget.
///
///
/// The OLECMDID_ZOOM command takes one LONG argument as input and writes one LONG argument on output. This command is
/// used for three purposes:
///
///
/// -
///
/// To query the current zoom value. The caller of IOleCommandTarget::Exec passes OLECMDEXECOPT_DONTPROMPTUSER as the execute option
/// in nCmdExecOpt and NULL for pvIn. The object returns the current zoom value in pvaOut. When the object goes UI active, it
/// retrieves the current zoom value from the container's frame object using this same mechanism and updates its zoom control with
/// the returned value.
///
///
/// -
///
/// To display the Zoom dialog box. The caller of IOleCommandTarget::Exec passes OLECMDEXECOPT_PROMPTUSER in nCmdExecOpt. The
/// caller can optionally pass the initial value for the dialog box through pvaIn; otherwise pvaIn must be NULL. If the user
/// clicks Cancel, the object returns OLECMDERR_E_CANCELED. If the user clicks OK, the object passes the user-selected
/// value in pvaOut. When user chooses the Zoom command from the View menu, the object calls the container's frame
/// object in the same manner. The container then zooms the document to the user selected value, and the object updates its
/// Zoom control with that value.
///
///
/// -
///
/// To set a Zoom value. The caller of IOleCommandTarget::Exec passes OLECMDEXECOPT_DONTPROMPTUSER in nCmdExecOpt and passes
/// the zoom value to apply through pvaIn. The object validates and normalizes the new value and returns the validated value in
/// pvaOut. When the user selects a new zoom value (using the Zoom control on the toolbar, for instance), the object calls
/// the container's frame object in this manner. The container zooms the document to 100 percent, and the object updates the
/// Zoom control with that value.
///
///
///
///
/// The OLECMDID_GETZOOMRANGE command is used to determine the range of valid zoom values from an object that implements
/// IOleCommandTarget. The caller passes MSOCMDEXECOPT_DONTPROMPTUSER in nCmdExecOpt and NULL for pvaIn. The object returns
/// its zoom range in pvaOut where the HIWORD contains the maximum zoom value and the LOWORD contains the minimum zoom value.
/// Typically this command is used when the user drops down the Zoom control on the toolbar of the UI-active object. The
/// applications and objects that support this command are required to support all the integral zoom values that are within the
/// (min,max) pair they return.
///
///
/// The OLECMDID_ACTIVEXINSTALLSCOPE command notifies Trident to use the indicated Install Scope to install the ActiveX Control
/// specified by the indicated class ID. The Install Scope is passed in a VT_ARRAY in pvaIn of the IOleCommandTarget::Exec method
/// whose elements are as follows.
///
///
///
/// Data
/// VARIANT Type
/// Index
///
/// -
/// Class ID
/// VT_BSTR
/// 0
///
/// -
/// Install Scope
/// VT_UI4
/// 1
///
///
/// The Install Scope must be one of the following values.
///
///
/// Value
/// Description
///
/// -
/// INSTALL_SCOPE_USERS
/// The ActiveX control should register to HKCU and for the instant user only.
///
/// -
/// INSTALL_SCOPE_MACHINE
/// The ActiveX control should register to HKLM and across the computer
///
///
/// The following is an example use of the OLECMDID_ACTIVEXINSTALLSCOPE command.
///
/// IOleCommandTarget::Exec( NULL, // Pointer to command group OLECMDARGINDEX_ACTIVEXINSTALL_INSTALLSCOPE, // ID of command to execute NULL, // Options &varArgs, // pvain pointer to input arguments NULL) // pointer to command output
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/ne-docobj-olecmdid
[PInvokeData("docobj.h", MSDNShortId = "NE:docobj.OLECMDID")]
public enum OLECMDID
{
/// File menu, Open command
OLECMDID_OPEN = 1,
/// File menu, New command
OLECMDID_NEW,
/// File menu, Save command
OLECMDID_SAVE,
/// File menu, Save As command
OLECMDID_SAVEAS,
/// File menu, Save Copy As command
OLECMDID_SAVECOPYAS,
/// File menu, Print command
OLECMDID_PRINT,
/// File menu, Print Preview command
OLECMDID_PRINTPREVIEW,
/// File menu, Page Setup command
OLECMDID_PAGESETUP,
/// Tools menu, Spelling command
OLECMDID_SPELL,
/// File menu, Properties command
OLECMDID_PROPERTIES,
/// Edit menu, Cut command
OLECMDID_CUT,
/// Edit menu, Copy command
OLECMDID_COPY,
/// Edit menu, Paste command
OLECMDID_PASTE,
/// Edit menu, Paste Special command
OLECMDID_PASTESPECIAL,
/// Edit menu, Undo command
OLECMDID_UNDO,
/// Edit menu, Redo command
OLECMDID_REDO,
/// Edit menu, Select All command
OLECMDID_SELECTALL,
/// Edit menu, Clear command
OLECMDID_CLEARSELECTION,
/// View menu, Zoom command (see below for details.)
OLECMDID_ZOOM,
/// Retrieves zoom range applicable to View Zoom (see below for details.)
OLECMDID_GETZOOMRANGE,
///
/// Informs the receiver, usually a frame, of state changes. The receiver can then query the status of the commands whenever convenient.
///
OLECMDID_UPDATECOMMANDS,
/// Asks the receiver to refresh its display. Implemented by the document/object.
OLECMDID_REFRESH,
/// Stops all current processing. Implemented by the document/object.
OLECMDID_STOP,
/// View menu, Toolbars command. Implemented by the document/object to hide its toolbars.
OLECMDID_HIDETOOLBARS,
///
/// Sets the maximum value of a progress indicator if one is owned by the receiving object, usually a frame. The minimum value
/// is always zero.
///
OLECMDID_SETPROGRESSMAX,
/// Sets the current value of a progress indicator if one is owned by the receiving object, usually a frame.
OLECMDID_SETPROGRESSPOS,
///
/// Sets the text contained in a progress indicator if one is owned by the receiving object, usually a frame. If the receiver
/// currently has no progress indicator, this text should be displayed in the status bar (if one exists) as with IOleInPlaceFrame::SetStatusText.
///
OLECMDID_SETPROGRESSTEXT,
/// Sets the title bar text of the receiving object, usually a frame.
OLECMDID_SETTITLE,
///
/// Called by the object when downloading state changes. Takes a VT_BOOL parameter, which is TRUE if the object is downloading
/// data and FALSE if it not. Primarily implemented by the frame.
///
OLECMDID_SETDOWNLOADSTATE,
///
/// Stops the download when executed. Typically, this command is propagated to all contained objects. When queried, sets
/// MSOCMDF_ENABLED. Implemented by the document/object.
///
OLECMDID_STOPDOWNLOAD,
///
OLECMDID_ONTOOLBARACTIVATED,
/// Edit menu, Find command
OLECMDID_FIND,
/// Edit menu, Delete command
OLECMDID_DELETE,
///
/// Issued in response to HTTP-EQUIV metatag and results in a call to the deprecated OnHttpEquiv method with the fDone parameter
/// set to false. This command takes a VT_BSTR parameter which is passed to OnHttpEquiv.
///
OLECMDID_HTTPEQUIV,
///
/// Issued in response to HTTP-EQUIV metatag and results in a call to the deprecated OnHttpEquiv method with the fDone parameter
/// set to true. This command takes a VT_BSTR parameter which is passed to OnHttpEquiv.
///
OLECMDID_HTTPEQUIV_DONE,
///
/// Pauses or resumes receiver interaction. This command takes a VT_BOOL parameter that pauses interaction when set to FALSE and
/// resumes interaction when set to TRUE.
///
OLECMDID_ENABLE_INTERACTION,
///
/// Notifies the receiver of an intent to close the window imminently. This command takes a VT_BOOL output parameter that
/// returns TRUE if the receiver can close and FALSE if it can't.
///
OLECMDID_ONUNLOAD,
/// This command has no effect.
OLECMDID_PROPERTYBAG2,
/// Notifies the receiver that a refresh is about to start.
OLECMDID_PREREFRESH,
/// Tells the receiver to display the script error message.
OLECMDID_SHOWSCRIPTERROR,
/// This command takes an IHTMLEventObj input parameter that contains a message that the receiver shows.
OLECMDID_SHOWMESSAGE,
/// Tells the receiver to show the Find dialog box. It takes a VT_DISPATCH input param.
OLECMDID_SHOWFIND,
/// Tells the receiver to show the Page Setup dialog box. It takes an IHTMLEventObj2 input parameter.
OLECMDID_SHOWPAGESETUP,
/// Tells the receiver to show the Print dialog box. It takes an IHTMLEventObj2 input parameter.
OLECMDID_SHOWPRINT,
/// The exit command for the File menu.
OLECMDID_CLOSE,
/// Supports the QueryStatus method.
OLECMDID_ALLOWUILESSSAVEAS,
/// Notifies the receiver that CSS files should not be downloaded when in DesignMode.
OLECMDID_DONTDOWNLOADCSS,
/// This command has no effect.
OLECMDID_UPDATEPAGESTATUS,
/// File menu, updated Print command
OLECMDID_PRINT2,
/// File menu, updated Print Preview command
OLECMDID_PRINTPREVIEW2,
/// Sets an explicit Print Template value of TRUE or FALSE, based on a VT_BOOL input parameter.
OLECMDID_SETPRINTTEMPLATE,
/// Gets a VT_BOOL output parameter indicating whether the Print Template value is TRUE or FALSE.
OLECMDID_GETPRINTTEMPLATE,
///
/// Indicates that a page action has been blocked. PAGEACTIONBLOCKED is designed for use with applications that host the
/// Internet Explorer WebBrowser control to implement their own UI.
///
OLECMDID_PAGEACTIONBLOCKED = 55,
/// Specifies which actions are displayed in the Internet Explorer notification band.
OLECMDID_PAGEACTIONUIQUERY,
///
/// Causes the Internet Explorer WebBrowser control to focus its default notification band. Hosts can send this command at any
/// time. The return value is S_OK if the band is present and is in focus, or S_FALSE otherwise.
///
OLECMDID_FOCUSVIEWCONTROLS,
///
/// This notification event is provided for applications that display Internet Explorers default notification band
/// implementation. By default, when the user presses the ALT-N key combination, Internet Explorer treats it as a request to
/// focus the notification band.
///
OLECMDID_FOCUSVIEWCONTROLSQUERY,
/// Causes the Internet Explorer WebBrowser control to show the Information Bar menu.
OLECMDID_SHOWPAGEACTIONMENU,
///
/// Causes the Internet Explorer WebBrowser control to create an entry at the current Travel Log offset. The Docobject should
/// implement ITravelLogClient and IPersist interfaces, which are used by the Travel Log as it processes this command with calls
/// to GetWindowData and GetPersistID, respectively.
///
OLECMDID_ADDTRAVELENTRY,
///
/// Called when LoadHistory is processed to update the previous Docobject state. For synchronous handling, this command can be
/// called before returning from the LoadHistory call. For asynchronous handling, it can be called later.
///
OLECMDID_UPDATETRAVELENTRY,
/// Updates the state of the browser's Back and Forward buttons.
OLECMDID_UPDATEBACKFORWARDSTATE,
///
/// Windows Internet Explorer 7 and later. Sets the zoom factor of the browser. Takes a VT_I4 parameter in the range of 10 to
/// 1000 (percent).
///
OLECMDID_OPTICAL_ZOOM,
///
/// Windows Internet Explorer 7 and later. Retrieves the minimum and maximum browser zoom factor limits. Returns a VT_I4
/// parameter; the LOWORD is the minimum zoom factor, the HIWORD is the maximum.
///
OLECMDID_OPTICAL_GETZOOMRANGE,
///
/// Windows Internet Explorer 7 and later. Notifies the Internet Explorer WebBrowser control of changes in window states, such
/// as losing focus, or becoming hidden or minimized. The host indicates what has changed by setting OLECMDID_WINDOWSTATE_FLAG
/// option flags in nCmdExecOpt.
///
OLECMDID_WINDOWSTATECHANGED,
///
/// Windows Internet Explorer 8 with Windows Vista. Has no effect with Windows Internet Explorer 8 with Windows XP. Notifies
/// Trident to use the indicated Install Scope to install the ActiveX Control specified by the indicated Class ID. For more
/// information, see the Remarks section.
///
OLECMDID_ACTIVEXINSTALLSCOPE,
///
/// Internet Explorer 8. Unlike OLECMDID_UPDATETRAVELENTRY, this updates a Travel Log entry that is not initialized from a
/// previous Docobject state. While this command is not called from IPersistHistory::LoadHistory, it can be called separately to
/// save browser state that can be used later to recover from a crash.
///
OLECMDID_UPDATETRAVELENTRY_DATARECOVERY,
///
OLECMDID_SHOWTASKDLG,
///
OLECMDID_POPSTATEEVENT,
///
OLECMDID_VIEWPORT_MODE,
///
OLECMDID_LAYOUT_VIEWPORT_WIDTH,
///
OLECMDID_VISUAL_VIEWPORT_EXCLUDE_BOTTOM,
///
OLECMDID_USER_OPTICAL_ZOOM,
///
OLECMDID_PAGEAVAILABLE,
///
OLECMDID_GETUSERSCALABLE,
///
OLECMDID_UPDATE_CARET,
///
OLECMDID_ENABLE_VISIBILITY,
///
OLECMDID_MEDIA_PLAYBACK,
///
OLECMDID_SETFAVICON,
///
OLECMDID_SET_HOST_FULLSCREENMODE,
///
OLECMDID_EXITFULLSCREEN,
///
OLECMDID_SCROLLCOMPLETE,
///
OLECMDID_ONBEFOREUNLOAD,
///
OLECMDID_SHOWMESSAGE_BLOCKABLE,
///
OLECMDID_SHOWTASKDLG_BLOCKABLE,
}
/// Specifies the window state.
[PInvokeData("docobj.h")]
[Flags]
public enum OLECMDID_WINDOWSTATE_FLAG
{
/// The window is visible.
OLECMDIDF_WINDOWSTATE_USERVISIBLE = 0x01,
/// The window has focus.
OLECMDIDF_WINDOWSTATE_ENABLED = 0x02,
/// The window is visible and valid.
OLECMDIDF_WINDOWSTATE_USERVISIBLE_VALID = 0x00010000,
/// The window has focus and is valid.
OLECMDIDF_WINDOWSTATE_ENABLED_VALID = 0x00020000
}
///
/// Specifies the type of information that an object should store in the OLECMDTEXT structure passed in
/// IOleCommandTarget::QueryStatus. One value from this enumeration is stored in to indicate the
/// desired information.
///
[PInvokeData("docobj.h")]
public enum OLECMDTEXTF
{
/// No extra information is requested.
OLECMDTEXTF_NONE = 0,
/// The object should provide the localized name of the command.
OLECMDTEXTF_NAME = 1,
/// The object should provide a localized status string for the command.
OLECMDTEXTF_STATUS = 2,
}
///
[PInvokeData("docobj.h")]
[Flags]
public enum PRINTFLAG
{
///
PRINTFLAG_MAYBOTHERUSER = 1,
///
PRINTFLAG_PROMPTUSER = 2,
///
PRINTFLAG_USERMAYCHANGEPRINTER = 4,
///
PRINTFLAG_RECOMPOSETODEVICE = 8,
///
PRINTFLAG_DONTACTUALLYPRINT = 16,
///
PRINTFLAG_FORCEPROPERTIES = 32,
///
PRINTFLAG_PRINTTOFILE = 64
}
///
[PInvokeData("docobj.h")]
[Flags]
public enum WPCSETTING
{
///
WPCSETTING_LOGGING_ENABLED = 0x00000001,
///
WPCSETTING_FILEDOWNLOAD_BLOCKED = 0x00000002,
}
///
/// Provides a generic callback mechanism for interruptible processes that should periodically ask an object whether to continue.
///
/// The FContinue method is a generic continuation request. FContinuePrinting carries extra information pertaining to a printing
/// process and is used in the context of IPrint.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nn-docobj-icontinuecallback
[PInvokeData("docobj.h", MSDNShortId = "NN:docobj.IContinueCallback")]
[ComImport, Guid("b722bcca-4e68-101b-a2bc-00aa00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IContinueCallback
{
/// Indicates whether a generic operation should continue.
///
/// This method can return the following values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Continue the operation.
///
/// -
/// S_FALSE
/// Cancel the operation as soon as possible.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-icontinuecallback-fcontinue HRESULT FContinue();
[PreserveSig]
HRESULT FContinue();
/// Indicates whether a lengthy printing operation should continue.
/// The total number of pages that have been printed at the time the object receives a call to FContinuePrinting.
/// The page number of the page being printed at the time the object receives a call to FContinuePrinting.
///
/// A pointer to the message about the current status of the print job. The object being printed may or may not display this
/// message to the user. This parameter can be NULL.
///
///
/// This method can return the standard return value E_UNEXPECTED, as well as the following values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Continue the printing operation.
///
/// -
/// S_FALSE
/// Cancel the printing operation as soon as possible.
///
///
///
///
/// Implementations of IPrint::Print call this method at periodic intervals during the printing process. The IPrint
/// implementation should call back at least after printing each page, so that its client can, if necessary, display useful
/// visual feedback to the user. IPrint::Print can call back multiple times with the same nCntPrinted and nCurPage
/// values, which is sometimes useful when a page being printed is complex and it is appropriate to give a user an opportunity
/// to cancel in mid-page.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-icontinuecallback-fcontinueprinting HRESULT
// FContinuePrinting( LONG nCntPrinted, LONG nCurPage, wchar_t *pwszPrintStatus );
[PreserveSig]
HRESULT FContinuePrinting(int nCntPrinted, int nCurPage, [In, Optional, MarshalAs(UnmanagedType.LPWStr)] string pwszPrintStatus);
}
/// Enumerates the views supported by a document object.
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nn-docobj-ienumoledocumentviews
[PInvokeData("docobj.h", MSDNShortId = "NN:docobj.IEnumOleDocumentViews")]
[ComImport, Guid("b722bcc8-4e68-101b-a2bc-00aa00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEnumOleDocumentViews : ICOMEnum
{
/// Retrieves the specified number of items in the enumeration sequence.
///
///
/// The number of items to be retrieved. If there are fewer than the requested number of items left in the sequence, this method
/// retrieves the remaining elements.
///
/// If pcFetched is NULL, this parameter must be 1.
///
///
/// An array of enumerated items.
///
/// The enumerator is responsible for calling AddRef, and the caller is responsible for calling Release through each pointer
/// enumerated. If cViews is greater than 1, the caller must also pass a non- NULL pointer passed to pcFetched to know
/// how many pointers to release.
///
///
///
/// The number of items that were retrieved. This parameter is always less than or equal to the number of items requested. This
/// parameter can be NULL, in which case the cViews parameter must be 1.
///
/// If the method retrieves the number of items requested, the return value is S_OK. Otherwise, it is S_FALSE.
///
/// E_NOTIMPL is not allowed as a return value. If an error value is returned, no entries in the rgpView array are valid and no
/// calls to Release are required.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ienumoledocumentviews-next HRESULT Next( ULONG cViews,
// IOleDocumentView **rgpView, ULONG *pcFetched );
[PreserveSig]
HRESULT Next(uint cViews, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 0)] IOleDocumentView rgpView, out uint pcFetched);
/// Skips over the specified number of items in the enumeration sequence.
/// The number of items to be skipped.
/// If the method skips the number of items requested, the return value is S_OK. Otherwise, it is S_FALSE.
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ienumoledocumentviews-skip HRESULT Skip( ULONG cViews );
[PreserveSig]
HRESULT Skip(uint cViews);
/// Resets the enumeration sequence to the beginning.
/// This method returns S_OK on success.
///
/// There is no guarantee that the same set of objects will be enumerated after the reset operation has completed. A static
/// collection is reset to the beginning, but it can be too expensive for some collections, such as files in a directory, to
/// guarantee this condition.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ienumoledocumentviews-reset HRESULT Reset();
[PreserveSig]
HRESULT Reset();
///
/// Creates a new enumerator that contains the same enumeration state as the current one.
///
/// This method makes it possible to record a particular point in the enumeration sequence and then return to that point at a
/// later time. The caller must release this new enumerator separately from the first enumerator.
///
///
///
/// A pointer to the IEnumOleDocumentViews interface pointer on the newly created enumerator. The caller must release this
/// enumerator separately from the one from which it was cloned.
///
///
/// This method returns S_OK on success. Other possible values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_UNEXPECTED
/// An unexpected error has occurred.
///
/// -
/// E_INVALIDARG
/// The specified enumerator is invalid.
///
/// -
/// E_OUTOFMEMORY
/// Insufficient memory available for this operation.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ienumoledocumentviews-clone HRESULT Clone(
// IEnumOleDocumentViews **ppEnum );
[PreserveSig]
HRESULT Clone(out IEnumOleDocumentViews ppEnum);
}
///
///
/// Enables objects and their containers to dispatch commands to each other. For example, an object's toolbars may contain buttons
/// for commands such as Print, Print Preview, Save, New, and Zoom.
///
///
/// Normal in-place activation guidelines recommend that you remove or disable such buttons because no efficient, standard mechanism
/// has been available to dispatch them to the container. Similarly, a container has heretofore had no efficient means to send
/// commands such as Print, Page Setup, and Properties to an in-place active object. Such simple command
/// routing could have been handled through existing OLE Automation standards and the IDispatch interface, but the overhead
/// with IDispatch is more than is required in the case of document objects. The IOleCommandTarget interface provides a
/// simpler means to achieve the same ends.
///
///
/// Available commands are defined by integer identifiers in a group. The group itself is identified with a GUID. The interface
/// allows a caller both to query for support of one or more commands within a group and to issue a supported command to the object.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/docobj/nn-docobj-iolecommandtarget
[PInvokeData("docobj.h", MSDNShortId = "5c8b455e-7740-4f71-aef6-27390a11a1a3")]
[ComImport, Guid("B722BCCB-4E68-101B-A2BC-00AA00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleCommandTarget
{
/// Queries the object for the status of one or more commands generated by user interface events.
///
/// The unique identifier of the command group; can be NULL to specify the standard group. All the commands that are passed in
/// the prgCmds array must belong to the group specified by pguidCmdGroup.
///
/// The number of commands in the prgCmds array.
///
/// A caller-allocated array of OLECMD structures that indicate the commands for which the caller needs status information. This
/// method fills the member of each structure with values taken from the OLECMDF enumeration.
///
///
/// A pointer to an OLECMDTEXT structure in which to return name and/or status information of a single command. This parameter
/// can be NULL to indicate that the caller does not need this information.
///
/// This method returns S_OK on success.
[PreserveSig]
HRESULT QueryStatus([In, Optional] GuidPtr pguidCmdGroup, uint cCmds, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] OLECMD[] prgCmds, [In, Out, Optional] IntPtr /* OLECMDTEXT* */ pCmdText);
/// Executes the specified command or displays help for the command.
/// The unique identifier of the command group; can be NULL to specify the standard group.
/// The command to be executed. This command must belong to the group specified with pguidCmdGroup.
///
/// Specifies how the object should execute the command. Possible values are taken from the OLECMDEXECOPT and
/// OLECMDID_WINDOWSTATE_FLAG enumerations.
///
/// A pointer to a VARIANTARG structure containing input arguments. This parameter can be NULL.
/// Pointer to a VARIANTARG structure to receive command output. This parameter can be NULL.
/// This method returns S_OK on success.
[PreserveSig]
HRESULT Exec([In, Optional] GuidPtr pguidCmdGroup, uint nCmdID, uint nCmdexecopt, [In, Optional] /* VARIANT* */ IntPtr pvaIn, [In, Out, Optional] /* VARIANT* */ IntPtr pvaOut);
}
///
/// Enables a document object to communicate to containers its ability to create views of its data. This interface also enables a
/// document object to enumerate its views and to provide containers with miscellaneous information about itself, such as whether it
/// supports multiple views or complex rectangles.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nn-docobj-ioledocument
[PInvokeData("docobj.h", MSDNShortId = "NN:docobj.IOleDocument")]
[ComImport, Guid("b722bcc5-4e68-101b-a2bc-00aa00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleDocument
{
///
/// Creates a document view object in the caller's process and obtains a pointer to that object's IOleDocumentView interface.
///
///
/// A pointer to the IOleInPlaceSite interface that represents the view site object to be associated with the new document view
/// object. This parameter can be NULL, for example, when the view is contained in a new, uninitialized document object,
/// in which case the caller must initialize the view with a subsequent call to IOleDocumentView::SetInPlaceSite.
///
///
/// A pointer to a stream containing data from which the new document view object should initialize itself. If NULL, the
/// document object initializes the new document view object with a default state.
///
/// This parameter is reserved and must be zero.
///
/// A pointer to an IOleDocumentView pointer variable that receives the interface pointer to the new document view object. When
/// successful, the caller is responsible for calling IUnknown::Release on the ppview pointer when the view object is no longer needed.
///
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_FAIL
/// The operation failed.
///
/// -
/// E_OUTOFMEMORY
/// Insufficient memory available for the operation.
///
/// -
/// E_UNEXPECTED
/// An unexpected error has occurred.
///
/// -
/// E_POINTER
/// The address in ppView is NULL.
///
///
///
///
///
/// A document object container's document site calls CreateView to instruct a document object to create a new view of
/// itself in the container's process, either from default data or using the contents of an existing stream.
///
///
/// Calling CreateView does not cause the new view to display itself. To do so requires a call to either
/// IOleDocumentView::Show or IOleDocumentView::UIActivate.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocument-createview HRESULT CreateView(
// IOleInPlaceSite *pIPSite, IStream *pstm, DWORD dwReserved, IOleDocumentView **ppView );
[PreserveSig]
HRESULT CreateView([In, Optional] IOleInPlaceSite pIPSite, [In, Optional] IStream pstm, [In, Optional] uint dwReserved, out IOleDocumentView ppView);
/// Retrieves status information about the document object.
///
/// A pointer to the information on supported behaviors. Possible values are taken from the DOCMISC enumeration.
///
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_POINTER
/// The address in pdwStatus is NULL.
///
///
///
///
///
/// This method provides a way for containers to ascertain whether a document object supports multiple views, complex
/// rectangles, opening in a pop-up window, or file read/write.
///
/// Values from this enumerator are also stored in the registry as the value of the DocObject key.
/// Notes to Callers
///
/// By calling this method prior to activating a document object, containers can take whatever steps are necessary to support or
/// otherwise accommodate the specified behaviors.
///
/// Notes to Implementers
///
/// This method must be completely implemented in any document object, even if the dereferenced value of pdwStatus is zero.
/// E_NOTIMPL is not an acceptable return value. Normally, the returned DOCMISC value should be hard-coded for performance.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocument-getdocmiscstatus HRESULT GetDocMiscStatus(
// DWORD *pdwStatus );
[PreserveSig]
HRESULT GetDocMiscStatus(out DOCMISC pdwStatus);
///
/// Creates an object that enumerates the views supported by a document object, or if only one view is supported, returns a
/// pointer to that view.
///
///
/// A pointer to an IEnumOleDocumentViews pointer variable that receives the interface pointer to the enumerator object.
///
///
/// A pointer to an IOleDocumentView pointer variable that receives the interface pointer to a single view object.
///
///
///
/// This method returns S_OK if the object supports multiple views, then ppEnum contains a pointer to the enumerator object, and
/// ppView is NULL. Otherwise, ppEnum is NULL, and ppView contains an interface pointer on the single view.
///
/// Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// Insufficient memory available for the operation.
///
/// -
/// E_POINTER
/// The address in ppEnum or ppView is invalid. The caller must pass valid pointers for both arguments.
///
///
///
///
///
/// If a document object supports multiple views of its data, it must also implement IEnumOleDocumentViews and pass that
/// interface's pointer in the out parameter ppEnum. Using this pointer, the container can enumerate the views supported by the
/// document object.
///
///
/// If the document object supports only a single view, IOleDocument::EnumViews passes that view's IOleDocumentView
/// pointer in the out parameter ppView.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocument-enumviews HRESULT EnumViews(
// IEnumOleDocumentViews **ppEnum, IOleDocumentView **ppView );
[PreserveSig]
HRESULT EnumViews(out IEnumOleDocumentViews ppEnum, out IOleDocumentView ppView);
}
///
///
/// Enables a document that has been implemented as a document object to bypass the normal activation sequence for in-place-active
/// objects and to directly instruct its client site to activate it as a document object. A client site with this ability is called
/// a document site.
///
///
/// For each document object to be hosted, a container must provide a corresponding document site, which is an OLE Documents client
/// site that, in addition to implementing IOleClientSite and IAdviseSink, also implements IOleDocumentSite. Each document
/// site implements a separate document view site object for each view of a document to be activated. The document view site
/// implements IOleInPlaceSite and, optionally, IContinueCallback.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nn-docobj-ioledocumentsite
[PInvokeData("docobj.h", MSDNShortId = "NN:docobj.IOleDocumentSite")]
[ComImport, Guid("b722bcc7-4e68-101b-a2bc-00aa00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleDocumentSite
{
///
/// Asks a document site to activate the document making the call as a document object rather than an in-place-active object
/// and, optionally, specifies which view of the object document to activate.
///
///
/// A pointer to an IOleDocumentView interface pointer that represents the document view to be used in activating the document
/// object. This parameter can be NULL, in which case the container should call IOleDocument::CreateView to obtain a
/// document view pointer.
///
/// This method returns S_OK on success.
///
///
/// When a container calls IOleObject::DoVerb to activate a document, a document object bypasses the usual in-place activation
/// sequence by calling IOleDocumentSite::ActivateMe.
///
///
/// When calling IOleObject::DoVerb on a document object, the most appropriate activation verb is usually OLEIVERB_SHOW. Other
/// allowable verbs include OLEIVERB_PRIMARY and OLEIVERB_UIACTIVATE. OLEIVERB_OPEN is discouraged because it means opening an
/// embedded object in a separate window, which is contrary to the intent of document object activation.
///
/// Notes to Callers
///
/// Only document objects should call this method. A normal in-place active document should respond to a container's call to
/// IOleObject::DoVerb by calling IOleInPlaceSite.
///
///
/// A document object should initiate its activation by calling IOleDocumentSite::ActivateMe. If the container does not
/// implement IOleDocumentSite, then the document should default to the normal in-place activation sequence.
///
///
/// A document object that supports more than one view of its data can specify which view to activate by passing a pointer to
/// that view's IOleDocumentView interface in pViewToActivate.
///
/// However the IOleDocumentView pointer is obtained, the container should release the pointer when it is no longer needed.
/// Notes to Implementers
///
/// This function must be completely implemented in a document object container; E_NOTIMPL is not an acceptable return value.
///
///
/// If a document object passes an IOleDocumentView pointer in pViewToActivate, the container's implementation of
/// IOleDocumentSite::ActivateMe should call IOleDocumentView::SetInPlaceSite and pass a pointer to its IOleInPlaceSite
/// interface back to the view object. If the container is holding onto the IOleDocumentView pointer, which will normally
/// be the case, it should follow the call to IOleDocumentView::SetInPlaceSite with a call to IUnknown::AddRef.
///
///
/// If pViewToActivate is NULL, the container can obtain a pointer to a document view by querying the document for
/// IOleDocument, then calling IOleDocument::CreateView and passing its IOleInPlaceSite pointer.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentsite-activateme HRESULT ActivateMe(
// IOleDocumentView *pViewToActivate );
[PreserveSig]
HRESULT ActivateMe([In] IOleDocumentView pViewToActivate);
}
///
/// The IOleDocumentView interface enables a container to communicate with each view supported by a document object.
///
/// A document object that supports multiple views of its data represents each view as a separate object. Each document view object
/// implements IOleDocumentView, along with IOleInPlaceObject, IOleInPlaceActiveObject, and optional interfaces such as
/// IPrint and IOleCommandTarget. A document object that supports only a single view does not require that view to be implemented as
/// a separate object. Instead, both document and view can be implemented as a single class.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nn-docobj-ioledocumentview
[PInvokeData("docobj.h", MSDNShortId = "NN:docobj.IOleDocumentView")]
[ComImport, Guid("b722bcc6-4e68-101b-a2bc-00aa00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleDocumentView
{
/// Associates a container's document view site with a document's view object.
///
/// A pointer to the document view site's IOleInPlaceSite interface. This parameter can be NULL, in which case the
/// document view object loses all asociation with the container.
///
///
///
/// This method returns S_OK if a document view site was successfully associated (or disassociated if pIPSite is NULL)
/// with a document view object. Other possible return values include the following.
///
///
///
/// Return code
/// Description
///
/// -
/// E_FAIL
/// The operation failed.
///
///
///
///
///
/// As part of activating a document object, a container must pass the object a pointer to the container's implementation of
/// IOleInPlaceSite. This pointer designates the document view site that is to be associated with the view on which this method
/// is called.
///
///
/// A container normally passes this pointer in response to a document's request to be activated. A document makes such a
/// request by calling IOleDocumentSite::ActivateMe and passing the container a pointer to the view to be activated. The
/// container, in turn, uses this pointer to call IOleDocumentView::SetInPlaceSite.
///
/// Notes to Callers
///
/// If the container is requesting creation and activation of a new instance of a document object, rather than merely the
/// activation of a loaded instance of a document object, the view site is passed in the pIPSite argument of
/// IOleDocument::CreateView. Therefore, an explicit call to IOleDocumentView::SetInPlaceSite is unnecessary.
///
/// Notes to Implementers
///
/// If this method is called on a view that is already associated with a view site, the view must do some housekeeping in
/// preparation for activating itself in the new site. First, the view must deactivate itself in the current site and release
/// its pointer to that site. Next, if the new IOleInPlaceSite pointer is not NULL, the view should both save the pointer
/// and call IUnknown::AddRef on it. The view should then wait for the container to tell it when to activate itself in the new
/// view site.
///
/// A document view must implement this method completely; E_NOTIMPL is not an acceptable return value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-setinplacesite HRESULT SetInPlaceSite(
// IOleInPlaceSite *pIPSite );
[PreserveSig]
HRESULT SetInPlaceSite([In, Optional] IOleInPlaceSite pIPSite);
/// Retrieves the view site associated with this view object.
///
/// A pointer to an IOleInPlaceSite pointer variable that receives the interface pointer to the document's view site.
///
///
/// This method returns S_OK on success. Other possible values include:
///
///
/// Return code
/// Description
///
/// -
/// E_FAIL
/// The operation failed.
///
///
///
///
/// IOleDocumentView::GetInPlaceSite obtains the most recent IOleInPlaceSite pointer passed by
/// IOleDocumentView::SetInPlaceSite, or NULL if IOleDocumentView::SetInPlaceSite has not yet been called. If this
/// pointer is not NULL, this method will call IUnknown::AddRef on the pointer. The caller is responsible for releasing
/// it. A document view must implement this method completely; E_NOTIMPL is not an acceptable return value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-getinplacesite HRESULT GetInPlaceSite(
// IOleInPlaceSite **ppIPSite );
[PreserveSig]
HRESULT GetInPlaceSite(out IOleInPlaceSite ppIPSite);
/// Obtains the IUnknown interface pointer on the document object that owns this view.
///
/// A pointer to an IUnknown interface pointer that receives a pointer to the document object that owns this view.
///
/// This method returns S_OK on success. S_OK is the only valid return value for this method.
///
///
/// The caller is responsible for incrementing the reference count on the interface pointer obtained by this method. The caller
/// must call IUnknown::Release on this pointer when it is no longer needed.
///
///
/// Because a view object must always be contained or aggregated in a document object, this method will always succeed. Before
/// returning, this method should call IUnknown::AddRef on the pointer stored in ppunk.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-getdocument HRESULT GetDocument(
// IUnknown **ppunk );
[PreserveSig]
HRESULT GetDocument([Out, MarshalAs(UnmanagedType.IUnknown)] out object ppunk);
///
/// Sets the rectangular coordinates of the viewport in which the view is to be activated or resets the coordinates of the
/// viewport in which a view is currently activated.
///
/// A pointer to a RECT structure containing the coordinates of the viewport.
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_FAIL
/// The operation failed.
///
///
///
///
///
/// For a single document interface (SDI) application, the viewport is the client area of the frame window minus the space
/// allocated for toolbars, status bar, and such. For a multiple document interface (MDI) window, the viewport is the client
/// area of the MDI document window minus any other frame-level user-interface elements.
///
/// Notes to Callers
///
/// Calling IOleDocumentView::SetRect or IOleDocumentView::SetRectComplex is part of the normal activation sequece for
/// document objects, usually following a call to IOleDocumentView::UIActivate and preceding a call to IOleDocumentView::Show.
///
///
/// Whenever the window used to display a document object is resized, the container should call IOleDocumentView::SetRect
/// (or IOleDocumentView::SetRectComplex) to tell the document view object to resize itself to the new window dimensions.
///
/// Notes to Implementers
///
/// The coordinates of the viewport are within the coordinates of the view window, which is obtained through
/// IOleWindow::GetWindow. The view must resize itself to fit the new coordinates passed in prcView.
///
///
/// This method is defined with the [input_sync] attribute, which means that the view object cannot yield or make another, non
/// input_sync RPC call while executing this method.
///
/// A document view must implement this method completely; E_NOTIMPL is not an acceptable return value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-setrect HRESULT SetRect( LPRECT prcView );
[PreserveSig]
HRESULT SetRect(in RECT prcView);
/// Retrieves the rectangular coordinates of the viewport in which the view is or will be activated.
/// A pointer to a RECT structure to contain the coordinates of the current viewport set with IOleDocumentView::SetRect.
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_UNEXPECTED
///
/// This view has not yet seen a call to IOleDocumentView::SetRect or IOleDocumentView::SetRectComplex and therefore has no
/// rectangle to return.
///
///
///
///
///
///
/// For a single document interface (SDI) application, the viewport is the client area of the frame window minus the space
/// allocated for toolbars, status bar, and such. For a multiple document interface (MDI) window, the viewport is the client
/// area of the MDI document window minus any other frame-level user-interface elements.
///
///
/// The viewport coordinates obtained by this method are those set in the most recent call to either IOleDocumentView::SetRect
/// or IOleDocumentView::SetRectComplex.
///
/// A document view must implement this method completely; E_NOTIMPL is not an acceptable return value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-getrect HRESULT GetRect( LPRECT prcView );
[PreserveSig]
HRESULT GetRect(out RECT prcView);
/// Sets the rectangular coordinates of the viewport, scroll bars, and size box.
/// A pointer to a RECT structure containing the coordinates of the viewport.
/// A pointer to a RECT structure containing the coordinates of the horizontal scroll bar.
/// A pointer to a RECT structure containing the coordinates of the vertical scroll bar.
/// A pointer to a RECT structure containing the coordinates of the size box.
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_FAIL
/// The operation failed.
///
/// -
/// E_NOTIMPL
/// The document object that owns this view does not support complex rectangles.
///
///
///
///
///
/// View frames that support a workbook metaphor, in which a single document comprises multiple sheets or pages, typically call
/// this method to set the coordinates to be used in common by all the sheets or pages.
///
/// Notes to Callers
///
/// Calling IOleDocumentView::SetRectComplex is part of the normal activation sequence for document objects that support
/// complex rectangles, usually following a call to IOleDocumentView::UIActivate and preceding a call to IOleDocumentView::Show.
///
///
/// Whenever the window used to display a document object is resized, the container should call
/// IOleDocumentView::SetRectComplex or IOleDocumentView::SetRect to tell the view object to resize itself to the new
/// window dimensions.
///
/// Notes to Implementers
///
/// Document objects that support complex rectangles mark themselves with DOCMISC_SUPPORTCOMPLEXRECTANGLES, as described in
/// DOCMISC and IOleDocument::GetDocMiscStatus. Document objects that do not support this method can return E_NOTIMPL.
///
///
/// Upon receiving a call to this method, a view should resize itself to fit the coordinates specified in prcView and fit its
/// scrollbars and size box to the areas described in prcHScroll, prcVScroll, and prcSizeBox.
///
///
/// This method is defined with the [input_sync] attribute, which means that the implementing object cannot yield or make
/// another, non input_sync RPC call while executing this method.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-setrectcomplex HRESULT SetRectComplex(
// LPRECT prcView, LPRECT prcHScroll, LPRECT prcVScroll, LPRECT prcSizeBox );
[PreserveSig]
HRESULT SetRectComplex([In, Optional] PRECT prcView, [In, Optional] PRECT prcHScroll, [In, Optional] PRECT prcVScroll, [In, Optional] PRECT prcSizeBox);
/// Activates or deactivates a view.
/// If TRUE, the view is to show itself. If FALSE, the view is to hide itself.
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_FAIL
/// The operation failed.
///
/// -
/// E_OUTOFMEMORY
/// Insufficient memory available for operation.
///
/// -
/// E_UNEXPECTED
/// An unexpected error occurred.
///
///
///
///
///
/// Calling Show is the last step in the activation sequence, because before showing itself a document object must know
/// exactly what space it occupies and have all its tools available.
///
/// Notes to Callers
///
/// A call to this method for the purpose of activating a view should follow calls to IOleDocumentView::SetInPlaceSite,
/// IOleDocumentView::UIActivate, and IOleDocumentView::SetRect (or IOleDocumentView::SetRectComplex).
///
/// Notes to Implementers
/// Implementations of this method should embody the following pseudocode.
///
/// if (fShow) { In-place activate the view but do not UI activate it. Show the view window. } else { Call IOleDocumentView::UIActivate(FALSE) on this view Hide the view window }
///
/// All views of a document object must at least support in-place activation; E_NOTIMPL is not an acceptable value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-show HRESULT Show( BOOL fShow );
[PreserveSig]
HRESULT Show([MarshalAs(UnmanagedType.Bool)] bool fShow);
/// Activates or deactivates a document view's user interface elements, such as menus, toolbars, and accelerators.
///
/// If TRUE, the view is to activate its user interface. If FALSE, the view is to deactivate its user interface.
///
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_FAIL
/// The operation failed.
///
/// -
/// E_OUTOFMEMORY
/// Insufficient memory available for operation.
///
/// -
/// E_UNEXPECTED
/// An unexpected error occurred.
///
///
///
///
/// Notes to Callers
///
/// Calling this method before calling IOleDocumentView::SetInPlaceSite returns E_UNEXPECTED, because the view must be
/// associated with a view site before it can activate itself.
///
///
/// When IOleDocumentView::UIActivate is called as part of the activation sequence, the call should precede a call to
/// IOleDocumentView::SetRect or IOleDocumentView::SetRectComplex, because otherwise the view dimensions would not account for
/// toolbar space.
///
///
/// To deactivate a view, the container should call IOleDocumentView::Show with FALSE, followed by
/// IOleDocumentView::UIActivate with FALSE.
///
/// Notes to Implementers
/// Implementations of this method should embody the following pseudocode.
///
/// if (fActivate) { UI activate the view (do menu merging, show frame level tools, process accelerators) Take focus, and bring the view window forward. } else call IOleInPlaceObject::UIDeactivate on this view
///
/// In addition, the view can and should participate in extended Help menu merging.
/// All views of a document object must support in-place activation. E_NOTIMPL is not an acceptable return value.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-uiactivate HRESULT UIActivate( BOOL
// fUIActivate );
[PreserveSig]
HRESULT UIActivate([MarshalAs(UnmanagedType.Bool)] bool fUIActivate);
///
/// Displays a document view in a separate pop-up window. The semantics are equivalent to IOleObject::DoVerb with OLEIVERB_OPEN.
///
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_FAIL
/// The operation failed.
///
/// -
/// E_OUTOFMEMORY
/// Insufficient memory available for the operation.
///
/// -
/// E_UNEXPECTED
/// An unexpected error occurred.
///
/// -
/// E_NOTIMPL
/// The document object that owns this view does not support separate window activation.
///
///
///
///
///
/// A user viewing a document object in a container application such as a browser or "binder" may want to see two or more views
/// or documents at once. Because the browser displays only one view at a time, the container needs a way to ask the other views
/// or documents to display themselves, as required, in separate windows. The IOleDocumentView::Open method provides that way.
///
/// Notes to Callers
///
/// A successful call to IOleDocumentView::Open should be followed by a call to IOleDocumentView::Show to hide the window
/// or to show the window and bring it to the foreground. While the view is active in its separate window, a container can show
/// or hide the window as many times as it may require.
///
/// Notes to Implementers
///
/// A document object indicates that it does not support activation in a separate window by setting the DOCMISC_CANTOPENEDIT
/// status flag and returning E_NOTIMPL to containers that call this method.
///
///
/// Implementation consists mainly of the view object calling its own IOleInPlaceObject::InPlaceDeactivate method, which leaves
/// the document object in a running state but without in-place activation. The document object's user interface is not visible
/// until the container calls IOleDocumentView::Show (see Notes to Callers above).
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-open HRESULT Open();
[PreserveSig]
HRESULT Open();
/// Instructs a document view to close itself and release its IOleInPlaceSite pointer.
/// This parameter is reserved and cannot be NULL.
/// This method returns S_OK on success.
///
///
/// When a separate window is no longer needed, the container calls IOleDocumentView::CloseView, whereupon the view
/// releases its site pointer to the separate window and destroys the window. Unlike the normal in-place deactivation sequence
/// for active documents, a document view continues to hold the IOleInPlaceSite pointer. This pointer is released only when the
/// view's container calls SetInPlaceSite, with pIPSite set to NULL, or calls IOleDocumentView::CloseView.
///
///
/// When a user closes a view's separate window, the view should not shut itself down. Instead, it should call
/// IOleInPlaceSite::OnInPlaceActivate. The view site then decides whether to call IOleDocumentView::UIActivate with
/// FALSE immediately or later. In this way, a document view displayed in a separate window remains available for
/// activation in the container's own window.
///
///
/// The container must call this method before it deletes the view, that is, releases its last reference to the view. In
/// general, implementation of this method will call IOleDocumentView::Show with FALSE to hide the view if it is not
/// already hidden, then call SetInPlaceSite with NULL to deactivate itself and release the view site pointer.
///
///
/// Because IOleDocumentView::CloseView is called when a container is going to completely shut down a view, this method
/// must be implemented and has no reason to fail.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-closeview HRESULT CloseView( DWORD
// dwReserved );
[PreserveSig]
HRESULT CloseView([In, Optional] uint dwReserved);
/// Saves the view state into the specified stream.
/// A pointer to the stream in which the view is to save its state data.
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_POINTER
/// The value in pstm is NULL.
///
/// -
/// E_NOTIMPL
///
/// This view has no meaningful state to save. This error should be rare because most views have at least some state information
/// worth saving.
///
///
///
///
///
///
/// The view's state includes properties such as the view type, zoom factor, and location of insertion point. The container
/// typically calls this function before deactivating the view. The stream can then later be used to reinitialize a view of the
/// same document to this saved state through IOleDocumentView::ApplyViewState.
///
///
/// According to the rules governing IPersistStream, a view must write its CLSID as the first element in the stream. Any
/// cross-platform file format compatibility issues that apply to the document's storage representation also apply to this context.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-saveviewstate HRESULT SaveViewState(
// LPSTREAM pstm );
[PreserveSig]
HRESULT SaveViewState(IStream pstm);
/// Initializes a view with view state previously saved in call to IOleDocumentView::SaveViewState.
/// A pointer to a stream containing data from which the view should initialize itself.
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_POINTER
/// The value in pstm is NULL.
///
/// -
/// E_NOTIMPL
///
/// This view has no meaningful state to load. This error should be rare because most views will have at least some state
/// information worth loading.
///
///
///
///
///
/// Typically, this function is called after an existing view has been created in the container but before that view has been
/// displayed. It is the responsibility of the view to validate the data in the view stream; the container does not attempt to
/// interpret the view's state data.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-applyviewstate HRESULT ApplyViewState(
// LPSTREAM pstm );
[PreserveSig]
HRESULT ApplyViewState(IStream pstm);
/// Creates a duplicate view object with an internal state identical to that of the current view.
///
/// A pointer to a IOleInPlaceSite interface that represents the view site in which the new view object will be activated. On
/// receiving this pointer, the view being cloned should pass it to the new view's IOleDocumentView::SetInPlaceSite method. This
/// pointer can be NULL, in which case the caller is responsible for calling IOleDocumentView::SetInPlaceSite on
/// the new view directly.
///
///
/// A pointer to an IOleDocumentView pointer variable that receives the interface pointer to the new view object. The caller is
/// responsible for releasing ppViewNew when it is no longer needed.
///
///
/// This method returns S_OK on success. Other possible return values include the following.
///
///
/// Return code
/// Description
///
/// -
/// E_FAIL
/// The operation failed.
///
/// -
/// E_POINTER
/// The value in ppViewNew is NULL.
///
/// -
/// E_NOTIMPL
/// The view object does not implement this interface.
///
///
///
///
/// This method is useful for creating a new view with a different viewport and view site but with the same view context as the
/// view being cloned. Typically, containers hosting an MDI application will call this method to provide "Window/New window" capability.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-ioledocumentview-clone HRESULT Clone( IOleInPlaceSite
// *pIPSiteNew, IOleDocumentView **ppViewNew );
[PreserveSig]
HRESULT Clone(IOleInPlaceSite pIPSiteNew, out IOleDocumentView ppViewNew);
}
/// Enables compound documents in general and active documents in particular to support programmatic printing.
///
///
/// After a document is loaded, containers and other clients can call IPrint::Print to instruct a document to print itself,
/// specifying printing control flags, the target device, the particular pages to print, and other options. The client can control
/// the continuation of printing by calling the IContinueCallback interface.
///
/// An object that implements IPrint registers itself with the Printable key stored under its CLSID as follows:
/// HKEY_CLASSES_ROOT\CLSID{...}\Printable
///
/// Callers determine whether a particular object class supports programmatic printing of its persistent state by looking in the
/// registry for this key.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nn-docobj-iprint
[PInvokeData("docobj.h", MSDNShortId = "NN:docobj.IPrint")]
[ComImport, Guid("b722bcc9-4e68-101b-a2bc-00aa00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPrint
{
/// Sets the page number of the first page of a document.
/// The page number of the first page.
/// This method can return the standard return values E_UNEXPECTED, E_FAIL, and S_OK.
///
///
/// Setting the first page to a negative number is valid. This may be useful in printing a portion of the document with page
/// numbers that specify an offset from the usual pagination.
///
///
/// Not all implementations permit the initial page number to be set, as some implementations simply lack the information as to
/// how the page number should be presented in the final output.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-iprint-setinitialpagenum HRESULT SetInitialPageNum( LONG
// nFirstPage );
[PreserveSig]
HRESULT SetInitialPageNum(int nFirstPage);
/// Retrieves the number of a document's first page and the total number of pages.
///
/// A pointer to a variable that receives the page number of the first page. This parameter can be NULL, indicating that
/// the caller is not interested in this number. If IPrint::SetInitialPageNum has been called, this parameter should contain the
/// same value passed to that method. Otherwise, the value is the document's internal first page number.
///
///
/// A pointer to a variable that receives the total number of pages in this document. This parameter can be NULL,
/// indicating that the caller is not interested in this number.
///
/// This method can return the standard return values E_UNEXPECTED and S_OK.
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-iprint-getpageinfo HRESULT GetPageInfo( LONG
// *pnFirstPage, LONG *pcPages );
[PreserveSig]
HRESULT GetPageInfo(out int pnFirstPage, out int pcPages);
/// Prints an object on the specified printer, using the specified job requirements.
///
/// A bitfield specifying print options from the PRINTFLAG enumeration.
/// PRINTFLAG_MAYBOTHERUSER (1)
/// PRINTFLAG_PROMPTUSER (2)
/// PRINTFLAG_USERMAYCHANGEPRINTER (4)
/// PRINTFLAG_RECOMPOSETODEVICE (8)
/// PRINTFLAG_DONTACTUALLYPRINT (16)
/// PRINTFLAG_FORCEPROPERTIES (32)
/// PRINTFLAG_PRINTTOFILE (64)
///
/// A pointer to a DVTARGETDEVICE structure that describes the target print device.
///
/// A pointer to a PAGESET pointer variable that receives a pointer to the structure that indicates which pages are to be printed.
///
///
/// A pointer to object-specific printing options in a serialized OLE property set. This parameter can be NULL on input
/// or return.
///
///
/// A pointer to the IContinueCallback interface on the view site, which is to be periodically polled at human-response speeds
/// to determine whether printing should be abandoned. This parameter can be NULL.
///
///
/// The page number of the first page to be printed. This value overrides any value previously passed to IPrint::SetInitialPageNum.
///
/// A pointer to a variable that receives the actual number of pages that were successfully printed.
/// A pointer to a variable that receives the page number of the last page that was printed.
///
/// This method can return the standard return value E_UNEXPECTED, as well as the following values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The method completed successfully.
///
/// -
/// PRINT_E_CANCELED
///
/// The print process was canceled before completion. *pcPagesPrinted indicates the number of pages that were in fact
/// successfully printed before this error occurred.
///
///
/// -
/// PRINT_E_NOSUCHPAGE
/// A page specified in **ppPageSet or nFirstPage does not exist.
///
///
///
///
///
/// The printer on which the object is to be printed is indicated by the DVTARGETDEVICE structure pointed to by pptd. The
/// DEVMODE structure in the target device indicates whole-job printer-specific options, such as number of copies, paper size,
/// and print quality. The DEVMODE structure may also contain orientation information in the dmOrientation member
/// (this is indicated in the dmFields member). If present, then this paper orientation should be used; if absent, then
/// natural orientation as determined by the object content is to be used.
///
///
/// Due to the possibility of user input, the parameters pptd and ppPageSet are both [in,out] structures. In the absence of user
/// interaction (that is, if the PRINTFLAG_PROMPTUSER flag is not set), both the target device and the page set will necessarily
/// be the same for input and output. However, if the user is prompted for print options, then the object returns target device
/// and page-set information appropriate to what the user has actually chosen.
///
///
/// The pstgmOptions parameter is also [in,out]. On exit, the object should write to *pstgmOptions any object-specific
/// information that it would need to reproduce this exact print job. Examples might include whether the user selected "sheet,
/// notes, or both" in a spreadsheet application. The data passed is in the format of a serialized property set. The data is
/// normally useful only when passed back in a subsequent call to the same object. Because a subsequent call may specify
/// different user interaction flags, target device, or other settings, the caller can cause the document to be printed multiple
/// times in the same way in slightly different printing contexts.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/nf-docobj-iprint-print HRESULT Print( DWORD grfFlags,
// DVTARGETDEVICE **pptd, PAGESET **ppPageSet, STGMEDIUM *pstgmOptions, IContinueCallback *pcallback, LONG nFirstPage, LONG
// *pcPagesPrinted, LONG *pnLastPage );
[PreserveSig]
HRESULT Print(PRINTFLAG grfFlags, [In, Out] IntPtr /*DVTARGETDEVICE** */ pptd, [In, Out] IntPtr /*PAGESET***/ ppPageSet,
[In, Out, Optional] IntPtr /*STGMEDIUM**/ pstgmOptions, [In] IContinueCallback pcallback, int nFirstPage,
out int pcPagesPrinted, out int pnLastPage);
}
/// Enables embedded documents to correctly merge menus with Windows Internet Explorer 7 in Protected Mode.
///
///
/// Typically, a menu merge requires an Active document (DocObject) to create and own the menu object. When the DocObject server is
/// hosted from an out-of-proc, medium integrity level process in Protected Mode, a standard menu merge causes the menu to be
/// nonfunctional. Internet Explorer 7 in Protected Mode is a low integrity level process and the out-of-proc DocObject server is a
/// medium integrity level process, so the User Interface Privilege Isolation (UIPI) mechanism of Windows Vista prevents Internet
/// Explorer 7 from accessing or expanding the menus.
///
///
/// The IProtectedModeMenuServices interface is implemented by the DocObject host (Internet Explorer 7) and can be queried by using
/// IID_IProtectedModeMenuServices
/// from the IOleInPlaceFrame interface used by DocObject servers for menu merging.
///
///
// https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767957(v=vs.85)
[PInvokeData("Docobj.h")]
[ComImport, Guid("73c105ee-9dff-4a07-b83c-7eff290c266e"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IProtectedModeMenuServices
{
/// Creates an empty low integrity menu.
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
// https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767956(v=vs.85)
// HRESULT CreateMenu( [out] HMENU *phMenu );
[PreserveSig]
HRESULT CreateMenu(out HMENU phMenu);
/// Creates a low integrity menu from a named resource.
///
/// [in] A pointer to a null-terminated string that specifies the name of language-neutral resource DLL or executable. The name
/// of the folder that contains the language-specific resource files is interpreted by using language name format. See
/// LoadMUILibrary for more information.
///
/// [in] A pointer to a null-terminated string that specifies the named menu resource.
/// [out] A variable that receives a handle to the low integrity menu.
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
// https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767958(v=vs.85)
// HRESULT LoadMenu( [in] LPCWSTR pszModuleName, [in] LPCWSTR pszMenuName, [out] HMENU *phMenu );
[PreserveSig]
HRESULT LoadMenu([MarshalAs(UnmanagedType.LPWStr)] string pszModuleName, [MarshalAs(UnmanagedType.LPWStr)] string pszMenuName, out HMENU phMenu);
/// Creates a low integrity menu from a resource ID.
///
/// [in] A pointer to a null-terminated string that specifies the name of language-neutral resource DLL or executable. The name
/// of the folder that contains the language-specific resource files is interpreted by using language name format. See
/// LoadMUILibrary for more information.
///
/// [in] An unsigned integer that specifies the menu resource by ID.
/// [out] A variable that receives a handle to the low integrity menu.
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
// https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767959(v=vs.85)
// HRESULT LoadMenuID( [in] LPCWSTR pszModuleName, [in] WORD wResourceID, [out] HMENU *phMenu );
[PreserveSig]
HRESULT LoadMenuID([MarshalAs(UnmanagedType.LPWStr)] string pszModuleName, ushort wResourceID, out HMENU phMenu);
}
/// Provides a method that queries for permission to grab the focus.
///
/// IProtectFocus was introduced in Windows Internet Explorer 7.
/// Hosts of MSHTML and the Web Browser control should respond to a IServiceProvider::QueryService for
/// SID_SProtectFocus
/// .
///
///
/// Implement this interface to prevent web pages hosted in MSHTML or the Web Browser control from stealing focus from other parts
/// of the user interface, for example when a user is entering data into an edit field in the host application.
///
///
// https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa770059(v=vs.85)
[PInvokeData("Docobj.h")]
[ComImport, Guid("d81f90a3-8156-44f7-ad28-5abb87003274"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IProtectFocus
{
/// Queries for permission to grab the focus when loading the page or when a script attempts to focus an element.
///
/// [out] Type: BOOL
/// Indicates whether permission was obtained to grab focus.
///
///
/// Type: HRESULT
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
/// IProtectFocus::AllowFocusChange was introduced in Windows Internet Explorer 7.
// https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa770058(v=vs.85)
// HRESULT retVal = object.AllowFocusChange(pfAllow);
[PreserveSig]
HRESULT AllowFocusChange([MarshalAs(UnmanagedType.Bool)] out bool pfAllow);
}
/// Provides a method that notifies hosts of changes in the zoom state.
///
/// IZoomEvents was introduced in Windows Internet Explorer 7.
///
/// To be notified of changes in the zoom level of a Web page, hosts of MSHTML should implement this interface on the same object
/// that implements IOleClientSite. The WebBrowser control does not delegate IZoomEvents to its host.
///
///
/// Note The optical zoom keyboard shortcuts (CTRL+mouse wheel forward/back, CTRL+PLUS SIGN, and CTRL+MINUS SIGN) are not
/// enabled by default when hosting the WebBrowser control. To enable this behavior, call IWebBrowser2::ExecWB with
/// OLECMDID_OPTICAL_ZOOM, passing
/// 100
/// in pvaIn. Once set, the keyboard shortcuts remain available as long as the host navigates to HTML content because the same
/// instance of MSHTML is used. However, if the host navigates to Active documents, such as XML or Portable Document Format (PDF)
/// files, optical zoom is disabled and will need to be enabled again.
///
///
// https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa770056(v=vs.85)
[PInvokeData("Docobj.h")]
[ComImport, Guid("41B68150-904C-4e17-A0BA-A438182E359D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IZoomEvents
{
/// Notifies hosts of changes in the zoom state.
/// The ul zoom percent.
///
// https://docs.microsoft.com/en-us/previous-versions/aa770057(v=vs.85)
[PreserveSig]
HRESULT OnZoomPercentChanged(uint ulZoomPercent);
}
/// Associates command flags from the OLECMDF enumeration with a command identifier through a call to IOleCommandTarget::QueryStatus.
[PInvokeData("docobj.h")]
[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
/// A command identifier; taken from the OLECMDID enumeration.
public OLECMDID cmdID;
/// Flags associated with cmdID; taken from the OLECMDF enumeration.
public OLECMDF cmdf;
}
/// Specifies a text name or status string for a single command identifier.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct OLECMDTEXT
{
///
/// A value from the OLECMDTEXTF enumeration describing whether the member contains a command name or status text.
///
public OLECMDTEXTF cmdtextf;
///
/// The number of characters actually written into the buffer before IOleCommandTarget::QueryStatus returns.
///
private uint cwActual;
/// The number of elements in the array.
public readonly uint cwBuf;
private readonly StrPtrUni _rgwz;
#pragma warning disable IDE1006 // Naming Styles
///
/// Gets or sets the command name or status text. When setting, this value must not be longer than and the
/// field will be updated based on the character count of the value provided.
///
public string rgwz
#pragma warning restore IDE1006 // Naming Styles
{
get => cwBuf > 0 ? _rgwz.ToString() : null;
set
{
if (value == null) value = string.Empty;
if (value.Length + 1 > cwBuf)
throw new ArgumentOutOfRangeException(nameof(rgwz), "Set value must be of a length that will fit into supplied buffer of length 'cwBuf'.");
unsafe
{
fixed (char* p = value)
{
var dest = (byte*)(IntPtr)_rgwz;
System.Text.Encoding.Unicode.GetEncoder().Convert(p, value.Length, dest, (int)cwBuf, true, out var actual, out var offset, out var _);
cwActual = (uint)actual;
dest[offset] = dest[offset + 1] = 0;
}
}
}
}
/// Returns a that represents this instance.
/// A that represents this instance.
public override string ToString() => rgwz ?? string.Empty;
}
/// Specifies a range of pages.
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/ns-docobj-pagerange typedef struct tagPAGERANGE { LONG nFromPage; LONG
// nToPage; } PAGERANGE;
[PInvokeData("docobj.h", MSDNShortId = "NS:docobj.tagPAGERANGE")]
[StructLayout(LayoutKind.Sequential)]
public struct PAGERANGE
{
///
/// The first page of the range. This member can have any page number as a value. If this value is greater than the value
/// specified in nToPage, the document will be printed in reverse page order.
///
public int nFromPage;
///
/// The last page of the range. A special value, PAGESET_TOLASTPAGE, indicates that all the remaining pages should be
/// printed. This member can have any page number as a value. If this value is less than the value specified in
/// nFromPage, the document will be printed in reverse page order.
///
public int nToPage;
}
///
/// Identifies one or more page-ranges to be printed and, optionally, identifies only the even or odd pages as part of a pageset.
///
// https://docs.microsoft.com/en-us/windows/win32/api/docobj/ns-docobj-pageset typedef struct tagPAGESET { ULONG cbStruct; BOOL
// fOddPages; BOOL fEvenPages; ULONG cPageRange; PAGERANGE rgPages[1]; } PAGESET;
[PInvokeData("docobj.h", MSDNShortId = "NS:docobj.tagPAGESET")]
[VanaraMarshaler(typeof(SafeAnysizeStructMarshaler), nameof(cPageRange))]
[StructLayout(LayoutKind.Sequential)]
public struct PAGESET
{
/// The number of bytes in this instance of the PAGESET structure. This member must be a multiple of 4.
public uint cbStruct;
/// If TRUE, only the odd-numbered pages in the page-set indicated by rgPages are to be printed.
[MarshalAs(UnmanagedType.Bool)]
public bool fOddPages;
/// If TRUE, only the even-numbered pages in the page-set indicated by rgPages are to be printed.
[MarshalAs(UnmanagedType.Bool)]
public bool fEvenPages;
/// The number of page-range pairs specified in rgPages.
public uint cPageRange;
///
/// Pointer to an array of PAGERANGE structures specifying the pages to be printed. One or more page ranges can be specified, so
/// long as the number of page ranges is the value of cPageRange. The page ranges must be sorted in ascending order and
/// must be non-overlapping.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public PAGERANGE[] rgPages;
}
}
}