@ghisler(Author): feel free to use this modified code if you want.
Here is the list of changes. Thanks to these changes, "listplug.pas" works properly also with modern Delphi versions, and is also coherent with "listplug.h":
1) Modern Delphi versions, starting from Delphi 2009, use unicode chars and strings by default, so they map "Char" to "WideChar" and "PChar" to "PWideChar". But we need to have ANSI statements there, so I explicitly changed "Char" to "AnsiChar" and "PChar" to "PAnsiChar". Without this change the code could be compiled, but wouldn't work properly.
2) I added "uses Windows" - without this the file couldn't be compiled.
3) I replaced :
Code: Select all
{$ifdef win64}
function ListNotificationReceived(ListWin:thandle;Message:integer;wParam:WPARAM;lParam:LPARAM):integer; stdcall;
{$else}
ListNotificationReceived(ListWin:thandle;Message:integer;wParam,lParam:integer):integer; stdcall;
{$endif}
Code: Select all
function ListNotificationReceived(ListWin:thandle;Message:integer;wParam:WPARAM;lParam:LPARAM):integer; stdcall;
4) To be coherent with "listplug.h", I changed "THandle" to "HWND" in all places. "THandle" and "HWND" have same size and in most cases are compatible each other (in particular in this code), so this change shouldn't cause any problems.
5) To be coherent with "listplug.h", I corrected field types in "tListDefaultParamStruct" record - "size" became "Integer", and "PluginInterfaceVersionLow" and "PluginInterfaceVersionHi" became "Cardinal".
6) To avoid potential problems with $ALIGN compiler directive, I added "packed" to the definition of "tListDefaultParamStruct" type and also to the "DefaultIniName" buffer inside.
7) I changed case of type definitions, to be coherent with Delphi definitions - for example "integer" to "Integer" and "hbitmap" to "HBITMAP".
8) Finally I inserted some spaces, so the code is more readable.
Here is the modified code:
Code: Select all
unit listplug; { Contents of file listplug.pas }
interface
uses
Windows;
const
lc_copy = 1;
lc_newparams = 2;
lc_selectall = 3;
lc_setpercent = 4;
lcp_wraptext = 1;
lcp_fittowindow = 2;
lcp_ansi = 4;
lcp_ascii = 8;
lcp_variable = 12;
lcp_forceshow = 16;
lcp_fitlargeronly = 32;
lcp_center = 64;
lcs_findfirst = 1;
lcs_matchcase = 2;
lcs_wholewords = 4;
lcs_backwards = 8;
itm_percent = $FFFE;
itm_fontstyle = $FFFD;
itm_wrap = $FFFC;
itm_fit = $FFFB;
itm_next = $FFFA;
itm_center = $FFF9;
LISTPLUGIN_OK = 0;
LISTPLUGIN_ERROR = 1;
type
tListDefaultParamStruct = packed record
size : Integer;
PluginInterfaceVersionLow : Cardinal;
PluginInterfaceVersionHi : Cardinal;
DefaultIniName : packed array[0..MAX_PATH-1] of AnsiChar;
end;
pListDefaultParamStruct = ^tListDefaultParamStruct;
{ Function prototypes: Functions need to be defined exactly like this!}
{
function ListLoad(ParentWin : HWND; FileToLoad : PAnsiChar; ShowFlags : Integer) : HWND; stdcall;
function ListLoadW(ParentWin : HWND; FileToLoad : PWideChar; ShowFlags : Integer) : HWND; stdcall;
function ListLoadNext(ParentWin, PluginWin : HWND; FileToLoad : PAnsiChar; ShowFlags : Integer) : Integer; stdcall;
function ListLoadNextW(ParentWin, PluginWin : HWND; FileToLoad : PWideChar; ShowFlags : Integer) : Integer; stdcall;
procedure ListCloseWindow(ListWin : HWND); stdcall;
procedure ListGetDetectString(DetectString : PAnsiChar; maxlen : Integer); stdcall;
function ListSearchText(ListWin : HWND; SearchString : PAnsiChar;
SearchParameter : Integer) : Integer; stdcall;
function ListSearchTextW(ListWin : HWND; SearchString : PWideChar;
SearchParameter : Integer) : Integer; stdcall;
function ListSearchDialog(ListWin : HWND; FindNext : Integer) : Integer; stdcall;
function ListSendCommand(ListWin : HWND; Command, Parameter : Integer) : Integer; stdcall;
function ListPrint(ListWin : HWND; FileToPrint, DefPrinter : PAnsiChar;
PrintFlags : Integer; var Margins : TRect) : Integer; stdcall;
function ListPrintW(ListWin : HWND; FileToPrint, DefPrinter : PWideChar;
PrintFlags : Integer; var Margins : TRect) : Integer; stdcall;
function ListNotificationReceived(ListWin : HWND; Message : Integer; wParam : WPARAM; lParam : LPARAM) : Integer; stdcall;
procedure ListSetDefaultParams(dps : pListDefaultParamStruct); stdcall;
function ListGetPreviewBitmap(FileToLoad : PAnsiChar; width, height : Integer;
contentbuf : PAnsiChar; contentbuflen : Integer) : HBITMAP; stdcall;
function ListGetPreviewBitmapW(FileToLoad : PWideChar; width, height : Integer;
contentbuf : PAnsiChar; contentbuflen : Integer) : HBITMAP; stdcall;
}
implementation
end.