<< Click to Display Table of Contents >> Navigation: »No topics above this level« Commands |
WPViewPDF exposes all its methods through a set of methods which all mainly execute a command inside the library.
The list of all commands is installed by the setup in pascal language in file WPDF_ViewCommands.PAS.
The command at least needs an ID as parameter, and, depending on the feature other parameters as integer, cardinal, character pointer or record pointer.
VB6
When using VisualBasic 6 with the WPViewPDF OCX please use the method CommandStrEx. Pass an empty string parameter if no string parameter is expected by a certain command.
VCL
When You are using the CXL in Delphi or C++Builder the following methods can be used to execute commands.
In any case a command is send to the viewer window. The different methods are used to add different parameters.
function command(command: Integer): Integer; overload;
function command(command, Param: Integer): Integer; overload;
This methods can also be used. They are provided to offer compatibility with older compilers.
function CommandEx(command: Integer; Param: Cardinal): Integer;
function CommandStr(command: Integer; str: AnsiString): Integer; overload;
function CommandStrEx(command: Integer; str: AnsiString; Param: Cardinal)
: Integer; overload;
function CommandStr(command: Integer; str: WideString): Integer; overload;
function CommandStrEx(command: Integer; str: WideString; Param: Cardinal)
: Integer; overload;
This commands are used when a string result is expected:
function CommandGetStr(command: Integer; Str:String; Param: Cardinal): WideString;
function CommandGetStrA(command: Integer; Str:String; Param: Cardinal): AnsiString;
The commands are defined in the unit WPDF_ViewCommands. They all start with "COMPDF_..."
.NET
The .NET assembly implements this variants of the command function:
public int Command(int commandnr, string StrParam, uint Param)
public int Command(int commandnr, string StrParam, int Param)
public int Command(int commandnr, string StrParam, byte[] BufferParam)
public int Command(int commandnr, string StrParam, int Param)
Also implemented are this two methods to make it easier to convert code provided for the VCL edition to .NET:
public int CommandStrEx(int commandnr, string StrParam="", int Param=0)
public int CommandStr(int commandnr, string StrParam = "")
If a command shoud return a string or a buffer use this functions:
public string CommandGetStr(int CommandID, string StrPar = "", int IntPar = 0)
public byte[] CommandGetStrA(int CommandID, string StrPar = "", int IntPar = 0)
The commands are defined in the namespace WPViewPDF inside the class "commands". So you need to write
Command(commands.COMPDF_.....)
Here you can use an implementation like this to call the "EX" command which not only passes a string but also an integer parameter.
struct TWPComRecStruct
{
int StrParam;
int WStrParam;
int StrLen;
unsigned int Param;
int IParam1; // not used
int IParam2;
int IParam3;
int IParam4;
int Reserved; // Must be 0
};
int PDFWindow::CommandEx(int cmd, CString StrParam, int Param)
{
int i = StrParam.GetLength()+1;
char *pmb = (char *)malloc( i );
wchar_t *pwc = (wchar_t *)malloc( sizeof( wchar_t ) * i);
strcpy(pmb, StrParam);
mbstowcs( pwc, pmb, i );
TWPComRecStruct rec;
memset(&rec, 0, sizeof(TWPComRecStruct));
rec.Param = Param;
rec.WStrParam = (int)pwc;
rec.StrLen = StrParam.GetLength();
int iRes = SendMessage(WM_PDF_COMMANDEX, cmd, (LPARAM)&rec);
free(pmb);
free(pwc);
return iRes;
}
IDs of the following command groups can be used: