using System;
using System.Runtime.InteropServices;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
public static partial class User32
{
/// Flags used by .
[PInvokeData("winuser.h", MSDNShortId = "fce80bac-2a44-46e7-a87a-ef93f4599807")]
public enum HelpCmd : uint
{
/// Displays the topic identified by the specified context identifier defined in the [MAP] section of the .hpj file.
[CorrespondingType(typeof(int))]
HELP_CONTEXT = 0x0001,
///
/// Informs Windows Help that it is no longer needed. If no other applications have asked for help, Windows closes Windows Help.
///
HELP_QUIT = 0x0002,
///
/// Displays the topic specified by the Contents option in the [OPTIONS] section of the .hpj file. This command is for backward
/// compatibility. New applications should use the HELP_FINDER command.
///
HELP_INDEX = 0x0003,
///
/// Displays the topic specified by the Contents option in the [OPTIONS] section of the .hpj file. This command is for backward
/// compatibility. New applications should provide a .cnt file and use the HELP_FINDER command.
///
HELP_CONTENTS = 0x0003,
/// Displays help on how to use Windows Help, if the Winhlp32.hlp file is available.
HELP_HELPONHELP = 0x0004,
///
/// Displays the index of the specified help file. An application should use this value only for help files with a single index.
/// It should not use this value with HELP_SETINDEX.
///
[CorrespondingType(typeof(int))]
HELP_SETINDEX = 0x0005,
///
/// Specifies the Contents topic. Windows Help displays this topic when the user clicks the Contents button if the Help file does
/// not have an associated .cnt file.
///
[CorrespondingType(typeof(int))]
HELP_SETCONTENTS = 0x0005,
///
/// Displays the topic identified by the specified context identifier defined in the [MAP] section of the .hpj file in a pop-up window.
///
[CorrespondingType(typeof(int))]
HELP_CONTEXTPOPUP = 0x0008,
///
/// Ensures that Windows Help is displaying the correct Help file. If the incorrect Help file is being displayed, Windows Help
/// opens the correct one; otherwise, there is no action.
///
HELP_FORCEFILE = 0x0009,
///
/// Displays the topic in the keyword table that matches the specified keyword, if there is an exact match. If there is more than
/// one match, displays the Index with the topics listed in the Topics Found list box.
///
[CorrespondingType(typeof(string))]
HELP_KEY = 0x0101,
/// Executes a Help macro or macro string.
[CorrespondingType(typeof(string))]
HELP_COMMAND = 0x0102,
///
/// Displays the topic in the keyword table that matches the specified keyword, if there is an exact match. If there is more than
/// one match, displays the Topics Found dialog box. To display the index without passing a keyword, use a pointer to an empty string.
///
[CorrespondingType(typeof(string))]
HELP_PARTIALKEY = 0x0105,
/// Displays the topic specified by a keyword in an alternative keyword table.
[CorrespondingType(typeof(MULTIKEYHELP))]
HELP_MULTIKEY = 0x0201,
/// Displays the Windows Help window, if it is minimized or in memory, and sets its size and position as specified.
[CorrespondingType(typeof(HELPWININFO))]
HELP_SETWINPOS = 0x0203,
///
/// Displays the Help menu for the selected window, then displays the topic for the selected control in a pop-up window.
///
[CorrespondingType(typeof(byte[]))]
HELP_CONTEXTMENU = 0x000a,
/// Displays the Help Topics dialog box.
HELP_FINDER = 0x000b,
/// Displays the topic for the control identified by the hWndMain parameter in a pop-up window.
[CorrespondingType(typeof(byte[]))]
HELP_WM_HELP = 0x000c,
/// Sets the position of the subsequent pop-up window.
[CorrespondingType(typeof(int))]
HELP_SETPOPUP_POS = 0x000d,
///
/// Indicates that a command is for a training card instance of Windows Help. Combine this command with other commands using the
/// bitwise OR operator.
///
HELP_TCARD = 0x8000,
///
/// The user clicked an authorable button. The dwActionData parameter contains a long integer specified by the Help author.
///
HELP_TCARD_DATA = 0x0010,
/// Another application has requested training cards.
HELP_TCARD_OTHER_CALLER = 0x0011,
}
///
/// Launches Windows Help (Winhelp.exe) and passes additional data that indicates the nature of the help requested by the application.
///
///
/// Type: HWND
///
/// A handle to the window requesting help. The WinHelp function uses this handle to keep track of which applications have
/// requested help. If the uCommand parameter specifies HELP_CONTEXTMENU or HELP_WM_HELP, hWndMain identifies the
/// control requesting help.
///
///
///
/// Type: LPCTSTR
///
/// The address of a null-terminated string containing the path, if necessary, and the name of the Help file that WinHelp is
/// to display.
///
///
/// The file name can be followed by an angle bracket (>) and the name of a secondary window if the topic is to be displayed in a
/// secondary window rather than in the primary window. You must define the name of the secondary window in the [WINDOWS] section of
/// the Help project (.hpj) file.
///
///
///
/// Type: UINT
///
/// The type of help requested. For a list of possible values and how they affect the value to place in the dwData parameter, see the
/// Remarks section.
///
///
///
/// Type: ULONG_PTR
///
/// Additional data. The value used depends on the value of the uCommand parameter. For a list of possible dwData values, see the
/// Remarks section.
///
///
///
/// Type: BOOL
/// Returns nonzero if successful, or zero otherwise. To retrieve extended error information, call GetLastError.
///
///
///
/// Before closing the window that requested help, the application must call WinHelp with the uCommand parameter set to
/// HELP_QUIT. Until all applications have done this, Windows Help will not terminate. Note that calling Windows Help with the
/// HELP_QUIT command is not necessary if you used the HELP_CONTEXTPOPUP command to start Windows Help.
///
/// This function fails if called from any context but the current user.
/// The following table shows the possible values for the uCommand parameter and the corresponding formats of the dwData parameter.
///
///
/// uCommand
/// Action
/// dwData
///
/// -
/// HELP_COMMAND
/// Executes a Help macro or macro string.
///
/// Address of a string that specifies the name of the Help macro(s) to run. If the string specifies multiple macro names, the names
/// must be separated by semicolons. You must use the short form of the macro name for some macros because Windows Help does not
/// support the long name.
///
///
/// -
/// HELP_CONTENTS
///
/// Displays the topic specified by the Contents option in the [OPTIONS] section of the .hpj file. This command is for backward
/// compatibility. New applications should provide a .cnt file and use the HELP_FINDER command.
///
/// Ignored; set to 0.
///
/// -
/// HELP_CONTEXT
/// Displays the topic identified by the specified context identifier defined in the [MAP] section of the .hpj file.
/// Contains the context identifier for the topic.
///
/// -
/// HELP_CONTEXTMENU
/// Displays the Help menu for the selected window, then displays the topic for the selected control in a pop-up window.
///
/// Address of an array of DWORD pairs. The first DWORD in each pair is the control identifier, and the second is the context
/// identifier for the topic. The array must be terminated by a pair of zeros {0,0}. If you do not want to add Help to a particular
/// control, set its context identifier to -1.
///
///
/// -
/// HELP_CONTEXTPOPUP
///
/// Displays the topic identified by the specified context identifier defined in the [MAP] section of the .hpj file in a pop-up window.
///
/// Contains the context identifier for a topic.
///
/// -
/// HELP_FINDER
/// Displays the Help Topics dialog box.
/// Ignored; set to 0.
///
/// -
/// HELP_FORCEFILE
///
/// Ensures that Windows Help is displaying the correct Help file. If the incorrect Help file is being displayed, Windows Help opens
/// the correct one; otherwise, there is no action.
///
/// Ignored; set to 0.
///
/// -
/// HELP_HELPONHELP
/// Displays help on how to use Windows Help, if the Winhlp32.hlp file is available.
/// Ignored; set to 0.
///
/// -
/// HELP_INDEX
///
/// Displays the topic specified by the Contents option in the [OPTIONS] section of the .hpj file. This command is for backward
/// compatibility. New applications should use the HELP_FINDER command.
///
/// Ignored; set to 0.
///
/// -
/// HELP_KEY
///
/// Displays the topic in the keyword table that matches the specified keyword, if there is an exact match. If there is more than one
/// match, displays the Index with the topics listed in the Topics Found list box.
///
/// Address of a keyword string. Multiple keywords must be separated by semicolons.
///
/// -
/// HELP_MULTIKEY
/// Displays the topic specified by a keyword in an alternative keyword table.
/// Address of a MULTIKEYHELP structure that specifies a table footnote character and a keyword.
///
/// -
/// HELP_PARTIALKEY
///
/// Displays the topic in the keyword table that matches the specified keyword, if there is an exact match. If there is more than one
/// match, displays the Topics Found dialog box. To display the index without passing a keyword, use a pointer to an empty string.
///
/// Address of a keyword string. Multiple keywords must be separated by semicolons.
///
/// -
/// HELP_QUIT
///
/// Informs Windows Help that it is no longer needed. If no other applications have asked for help, Windows closes Windows Help.
///
/// Ignored; set to 0.
///
/// -
/// HELP_SETCONTENTS
///
/// Specifies the Contents topic. Windows Help displays this topic when the user clicks the Contents button if the Help file does not
/// have an associated .cnt file.
///
/// Contains the context identifier for the Contents topic.
///
/// -
/// HELP_SETPOPUP_POS
/// Sets the position of the subsequent pop-up window.
///
/// Contains the position data. Use MAKELONG to concatenate the horizontal and vertical coordinates into a single value. The pop-up
/// window is positioned as if the mouse cursor were at the specified point when the pop-up window was invoked.
///
///
/// -
/// HELP_SETWINPOS
/// Displays the Windows Help window, if it is minimized or in memory, and sets its size and position as specified.
/// Address of a HELPWININFO structure that specifies the size and position of either a primary or secondary Help window.
///
/// -
/// HELP_TCARD
///
/// Indicates that a command is for a training card instance of Windows Help. Combine this command with other commands using the
/// bitwise OR operator.
///
/// Depends on the command with which this command is combined.
///
/// -
/// HELP_WM_HELP
/// Displays the topic for the control identified by the hWndMain parameter in a pop-up window.
///
/// Address of an array of DWORD pairs. The first DWORD in each pair is a control identifier, and the second is a context identifier
/// for a topic. The array must be terminated by a pair of zeros {0,0}. If you do not want to add Help to a particular control, set
/// its context identifier to -1.
///
///
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-winhelpa BOOL WinHelpA( HWND hWndMain, LPCSTR lpszHelp,
// UINT uCommand, ULONG_PTR dwData );
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "fce80bac-2a44-46e7-a87a-ef93f4599807")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool WinHelp(HWND hWndMain, string lpszHelp, HelpCmd uCommand, IntPtr dwData);
///
/// Contains the size and position of either a primary or secondary Help window. An application can set this information by calling
/// the WinHelp function with the HELP_SETWINPOS value.
///
///
///
/// Windows Help divides the display into 1024 units in both the X and Y directions. To create a secondary window that fills the
/// upper-left quadrant of the display, for example, an application would specify zero for the x and y members and 512
/// for the dx and dy members.
///
///
/// To calculate wStructSize properly, the actual size of the string to be stored at rgchMember must be known. Since
/// sizeof(HELPWININFO) includes two TCHARs by definition, they must be taken into account in the final total. The following
/// example shows the proper calculation of an instance of wStructSize.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/ns-winuser-taghelpwininfoa typedef struct tagHELPWININFOA { int
// wStructSize; int x; int y; int dx; int dy; int wMax; CHAR rgchMember[2]; } HELPWININFOA, *PHELPWININFOA, *LPHELPWININFOA;
[PInvokeData("winuser.h", MSDNShortId = "0de0bf84-66f3-44bc-b4de-c2de7ca90cb2")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct HELPWININFO
{
///
/// Type: int
/// The size of this structure, in bytes.
///
public int wStructSize;
///
/// Type: int
/// X-coordinate of the upper-left corner of the window, in screen coordinates.
///
public int x;
///
/// Type: int
/// Y-coordinate of the upper-left corner of the window, in screen coordinates.
///
public int y;
///
/// Type: int
/// The width of the window, in pixels.
///
public int dx;
///
/// Type: int
/// The height of the window, in pixels.
///
public int dy;
///
/// Type: int
///
/// Options for display of the window. Several values also determine the activation (focus) state of the window or other windows.
/// This member must be one of the following values.
///
/// SW_HIDE
/// Hides the window and passes activation to another window.
/// SW_MINIMIZE
/// Minimizes the specified window and activates the top-level window in the z-order.
/// SW_RESTORE
/// Same as SW_SHOWNORMAL.
/// SW_SHOW
/// Activates a window and displays it in its current size and position.
/// SW_SHOWMAXIMIZED
/// Activates the window and displays it as a maximized window.
/// SW_SHOWMINIMIZED
/// Activates the window and displays it as an icon.
/// SW_SHOWMINNOACTIVE
/// Displays the window as an icon. The window that is currently active remains active.
/// SW_SHOWNA
/// Displays the window in its current state. The window that is currently active remains active.
/// SW_SHOWNOACTIVATE
/// Displays a window in its most recent size and position. The window that is currently active remains active.
/// SW_SHOWNORMAL
///
/// Activates and displays the window. Whether the window is minimized or maximized, Windows restores it to its original size and position.
///
///
public ShowWindowCommand wMax;
///
/// Type: TCHAR[2]
/// The name of the window.
///
/// The .
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]
public string rgchMember;
}
/// Specifies a keyword to search for and the keyword table to be searched by Windows Help.
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/ns-winuser-tagmultikeyhelpa typedef struct tagMULTIKEYHELPA { #if ...
// DWORD mkSize; #else WORD mkSize; #endif CHAR mkKeylist; CHAR szKeyphrase[1]; } MULTIKEYHELPA, *PMULTIKEYHELPA, *LPMULTIKEYHELPA;
[PInvokeData("winuser.h", MSDNShortId = "5fe0cd44-196c-4d9a-b9f8-2a97a92f2545")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MULTIKEYHELP
{
/// The mk size
public uint mkSize;
///
/// Type: TCHAR
/// A single character that identifies the keyword table to search.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)]
public string mkKeylist;
///
/// Type: TCHAR[1]
/// A null-terminated text string that specifies the keyword to locate in the keyword table.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 253)]
public string szKeyphrase;
}
}
}