mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: Rename DialogAPI to ExtensionAPI, reserved some extra space for future extension without breaking ABI, use UTF-8 encoding
This commit is contained in:
parent
68ca3e924c
commit
0c0a0db153
5 changed files with 152 additions and 141 deletions
|
|
@ -52,33 +52,42 @@
|
|||
|
||||
#define DM_USER 0x4000 /* Starting value for user defined messages */
|
||||
|
||||
/* other */
|
||||
#define EXT_MAX_PATH 16384 /* 16 Kb */
|
||||
|
||||
/* Dialog window callback function */
|
||||
typedef intptr_t (__stdcall *tDlgProc)(uintptr_t pDlg, char* DlgItemName, intptr_t Msg, intptr_t wParam, intptr_t lParam);
|
||||
/* Definition of callback functions called by the DLL */
|
||||
typedef BOOL (__stdcall *tInputBoxProc)(WCHAR* Caption, WCHAR* Prompt, BOOL MaskInput, WCHAR* Value, int ValueMaxLen);
|
||||
typedef int (__stdcall *tMessageBoxProc)(WCHAR* Text, WCHAR* Caption, long Flags);
|
||||
typedef BOOL (__stdcall *tInputBoxProc)(char* Caption, char* Prompt, BOOL MaskInput, char* Value, int ValueMaxLen);
|
||||
typedef int (__stdcall *tMessageBoxProc)(char* Text, char* Caption, long Flags);
|
||||
typedef BOOL (__stdcall *tDialogBoxLFMProc)(intptr_t LFMData, unsigned long DataSize, tDlgProc DlgProc);
|
||||
typedef BOOL (__stdcall *tDialogBoxLRSProc)(intptr_t LRSData, unsigned long DataSize, tDlgProc DlgProc);
|
||||
typedef BOOL (__stdcall *tDialogBoxLFMFileProc)(WCHAR* LFMFileName, tDlgProc DlgProc);
|
||||
typedef BOOL (__stdcall *tDialogBoxLFMFileProc)(char* LFMFileName, tDlgProc DlgProc);
|
||||
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
WCHAR* PluginDir;
|
||||
WCHAR* PluginConfDir;
|
||||
unsigned long StructSize;
|
||||
char PluginDir[EXT_MAX_PATH];
|
||||
char PluginConfDir[EXT_MAX_PATH];
|
||||
tInputBoxProc InputBox;
|
||||
tMessageBoxProc MessageBox;
|
||||
tDialogBoxLFMProc DialogBoxLFM;
|
||||
tDialogBoxLRSProc DialogBoxLRS;
|
||||
tDialogBoxLFMFileProc DialogBoxLFMFile;
|
||||
tDlgProc SendDlgMsg;
|
||||
} tSetDlgProcInfo;
|
||||
unsigned char Reserved[4096 * sizeof(void *)];
|
||||
} tExtensionStartupInfo;
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef void (__stdcall tSetDlgProc)(tSetDlgProcInfo* SetDlgProcInfo);
|
||||
typedef void (__stdcall tExtensionInitializeProc)(tExtensionStartupInfo* StartupInfo);
|
||||
typedef void (__stdcall tExtensionFinalizeProc)(void* Reserved);
|
||||
|
||||
/* Plugin must implement this function for working with Dialog API
|
||||
void __stdcall SetDlgProc(tSetDlgProcInfo* SetDlgProcInfo);
|
||||
*/
|
||||
/* Plugin must implement this function for working with Extension API
|
||||
|
||||
void __stdcall ExtensionInitialize(tExtensionStartupInfo* StartupInfo);
|
||||
|
||||
void __stdcall ExtensionFinalize(void* Reserved);
|
||||
|
||||
*/
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
unit DialogAPI;
|
||||
unit Extension;
|
||||
|
||||
interface
|
||||
|
||||
|
|
@ -90,36 +90,50 @@ const
|
|||
ID_CLOSE = 8;
|
||||
ID_HELP = 9;
|
||||
|
||||
const
|
||||
EXT_MAX_PATH = 16384; // 16 Kb
|
||||
|
||||
type
|
||||
{ Dialog window callback function }
|
||||
TDlgProc = function(pDlg: PtrUInt; DlgItemName: PAnsiChar; Msg, wParam, lParam: PtrInt): PtrInt; stdcall;
|
||||
{ Definition of callback functions called by the DLL }
|
||||
TInputBoxProc = function(Caption, Prompt: PWideChar; MaskInput: LongBool; Value: PWideChar; ValueMaxLen: Integer): LongBool; stdcall;
|
||||
TMessageBoxProc = function(Text, Caption: PWideChar; Flags: Longint): Integer; stdcall;
|
||||
TInputBoxProc = function(Caption, Prompt: PAnsiChar; MaskInput: LongBool; Value: PAnsiChar; ValueMaxLen: Integer): LongBool; stdcall;
|
||||
TMessageBoxProc = function(Text, Caption: PAnsiChar; Flags: Longint): Integer; stdcall;
|
||||
TDialogBoxLFMProc = function(LFMData: Pointer; DataSize: LongWord; DlgProc: TDlgProc): LongBool; stdcall;
|
||||
TDialogBoxLRSProc = function(LRSData: Pointer; DataSize: LongWord; DlgProc: TDlgProc): LongBool; stdcall;
|
||||
TDialogBoxLFMFileProc = function(lfmFileName: PWideChar; DlgProc: TDlgProc): LongBool; stdcall;
|
||||
TDialogBoxLFMFileProc = function(lfmFileName: PAnsiChar; DlgProc: TDlgProc): LongBool; stdcall;
|
||||
|
||||
type
|
||||
TSetDlgProcInfo = packed record
|
||||
PluginDir: PWideChar;
|
||||
PluginConfDir: PWideChar;
|
||||
PExtensionStartupInfo = ^TExtensionStartupInfo;
|
||||
TExtensionStartupInfo = record
|
||||
// The size of the structure, in bytes
|
||||
StructSize: LongWord;
|
||||
// Directory where plugin is located (UTF-8 encoded)
|
||||
PluginDir: array [0..Pred(EXT_MAX_PATH)] of AnsiChar;
|
||||
// Directory where plugin configuration file must be located (UTF-8 encoded)
|
||||
PluginConfDir: array [0..Pred(EXT_MAX_PATH)] of AnsiChar;
|
||||
// Dialog API
|
||||
InputBox: TInputBoxProc;
|
||||
MessageBox: TMessageBoxProc;
|
||||
DialogBoxLFM: TDialogBoxLFMProc;
|
||||
DialogBoxLRS: TDialogBoxLRSProc;
|
||||
DialogBoxLFMFile: TDialogBoxLFMFileProc;
|
||||
SendDlgMsg: TDlgProc;
|
||||
// Reserved for future API extension
|
||||
Reserved: array [0..Pred(4096 * SizeOf(Pointer))] of Byte;
|
||||
end;
|
||||
|
||||
type
|
||||
TSetDlgProc = procedure(var SetDlgProcInfo: TSetDlgProcInfo);stdcall;
|
||||
TExtensionInitializeProc = procedure(StartupInfo: PExtensionStartupInfo); stdcall;
|
||||
TExtensionFinalizeProc = procedure(Reserved: Pointer); stdcall;
|
||||
|
||||
implementation
|
||||
|
||||
{ Plugin must implement this function for working with Dialog API
|
||||
{ Plugin must implement this function for working with Extension API
|
||||
|
||||
procedure SetDlgProc(var SetDlgProcInfo: TSetDlgProcInfo);stdcall;
|
||||
procedure ExtensionInitialize(StartupInfo: PExtensionStartupInfo); stdcall;
|
||||
|
||||
procedure ExtensionFinalize(Reserved: Pointer); stdcall;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
This unit contains realization of Dialog API functions.
|
||||
|
||||
Copyright (C) 2008-2009 Koblov Alexander (Alexx2000@mail.ru)
|
||||
Copyright (C) 2008-2011 Koblov Alexander (Alexx2000@mail.ru)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -28,7 +28,7 @@ interface
|
|||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
Types, DialogAPI;
|
||||
Types, Extension;
|
||||
|
||||
type
|
||||
|
||||
|
|
@ -82,43 +82,34 @@ type
|
|||
{ public declarations }
|
||||
end;
|
||||
|
||||
function InputBox(Caption, Prompt: PWideChar; MaskInput: LongBool; Value: PWideChar; ValueMaxLen: Integer): LongBool; stdcall;
|
||||
function MessageBox(Text, Caption: PWideChar; Flags: Longint): Integer; stdcall;
|
||||
function InputBox(Caption, Prompt: PAnsiChar; MaskInput: LongBool; Value: PAnsiChar; ValueMaxLen: Integer): LongBool; stdcall;
|
||||
function MessageBox(Text, Caption: PAnsiChar; Flags: Longint): Integer; stdcall;
|
||||
function DialogBoxLFM(LFMData: Pointer; DataSize: LongWord; DlgProc: TDlgProc): LongBool; stdcall;
|
||||
function DialogBoxLRS(LRSData: Pointer; DataSize: LongWord; DlgProc: TDlgProc): LongBool; stdcall;
|
||||
function DialogBoxLFMFile(lfmFileName: PWideChar; DlgProc: TDlgProc): LongBool; stdcall;
|
||||
function SendDlgMsg(pDlg: PtrUInt; DlgItemName: PChar; Msg, wParam, lParam: PtrInt): PtrInt; stdcall;
|
||||
function DialogBoxLFMFile(lfmFileName: PAnsiChar; DlgProc: TDlgProc): LongBool; stdcall;
|
||||
function SendDlgMsg(pDlg: PtrUInt; DlgItemName: PAnsiChar; Msg, wParam, lParam: PtrInt): PtrInt; stdcall;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uShowMsg, uClassesEx, uDCUtils;
|
||||
|
||||
function InputBox(Caption, Prompt: PWideChar; MaskInput: LongBool; Value: PWideChar; ValueMaxLen: Integer): LongBool; stdcall;
|
||||
function InputBox(Caption, Prompt: PAnsiChar; MaskInput: LongBool; Value: PAnsiChar; ValueMaxLen: Integer): LongBool; stdcall;
|
||||
var
|
||||
sCaption,
|
||||
sPrompt,
|
||||
sValue: UTF8String;
|
||||
begin
|
||||
Result:= False;
|
||||
sCaption:= UTF8Encode(WideString(Caption));
|
||||
sPrompt:= UTF8Encode(WideString(Prompt));
|
||||
sValue:= UTF8Encode(WideString(Value));
|
||||
if ShowInputQuery(sCaption, sPrompt, MaskInput, sValue) then
|
||||
sValue:= StrPas(Value);
|
||||
if ShowInputQuery(Caption, Prompt, MaskInput, sValue) then
|
||||
begin
|
||||
StrLCopyW(Value, PWideChar(UTF8Decode(sValue)), ValueMaxLen);
|
||||
StrLCopy(Value, PAnsiChar(sValue), ValueMaxLen);
|
||||
Result:= True;
|
||||
end;
|
||||
end;
|
||||
|
||||
function MessageBox(Text, Caption: PWideChar; Flags: Longint): Integer; stdcall;
|
||||
var
|
||||
sText,
|
||||
sCaption: String;
|
||||
function MessageBox(Text, Caption: PAnsiChar; Flags: Longint): Integer; stdcall;
|
||||
begin
|
||||
sText:= UTF8Encode(WideString(Text));
|
||||
sCaption:= UTF8Encode(WideString(Caption));
|
||||
Result:= ShowMessageBox(sText, sCaption, Flags);
|
||||
Result:= ShowMessageBox(Text, Caption, Flags);
|
||||
end;
|
||||
|
||||
procedure SetDialogBoxResourceLRS(LRSData: UTF8String);
|
||||
|
|
@ -195,7 +186,7 @@ begin
|
|||
Result := False;
|
||||
end;
|
||||
|
||||
function DialogBoxLFMFile(lfmFileName: PWideChar; DlgProc: TDlgProc): LongBool;stdcall;
|
||||
function DialogBoxLFMFile(lfmFileName: PAnsiChar; DlgProc: TDlgProc): LongBool;stdcall;
|
||||
var
|
||||
lfmStringList: TStringListEx;
|
||||
begin
|
||||
|
|
@ -203,7 +194,7 @@ begin
|
|||
begin
|
||||
lfmStringList:= TStringListEx.Create;
|
||||
try
|
||||
lfmStringList.LoadFromFile(UTF8Encode(WideString(lfmFileName)));
|
||||
lfmStringList.LoadFromFile(lfmFileName);
|
||||
SetDialogBoxResourceLFM(lfmStringList.Text);
|
||||
Result := DialogBox(DlgProc);
|
||||
finally
|
||||
|
|
@ -214,12 +205,11 @@ begin
|
|||
Result := False;
|
||||
end;
|
||||
|
||||
function SendDlgMsg(pDlg: PtrUInt; DlgItemName: PChar; Msg, wParam, lParam: PtrInt): PtrInt;stdcall;
|
||||
function SendDlgMsg(pDlg: PtrUInt; DlgItemName: PAnsiChar; Msg, wParam, lParam: PtrInt): PtrInt;stdcall;
|
||||
var
|
||||
DialogBox: TDialogBox;
|
||||
Control: TControl;
|
||||
sText: String;
|
||||
wText: WideString;
|
||||
sText: UTF8String;
|
||||
I: Integer;
|
||||
Rect: TRect;
|
||||
Key: Word;
|
||||
|
|
@ -229,7 +219,7 @@ begin
|
|||
for I:= 0 to DialogBox.ComponentCount - 1 do
|
||||
begin
|
||||
Control:= TControl(DialogBox.Components[I]);
|
||||
if CompareText(Control.Name,DlgItemName) = 0 then Break;
|
||||
if CompareText(Control.Name, DlgItemName) = 0 then Break;
|
||||
end;
|
||||
// process message
|
||||
case Msg of
|
||||
|
|
@ -283,7 +273,7 @@ begin
|
|||
end;
|
||||
DM_LISTADD:
|
||||
begin
|
||||
sText:= UTF8Encode(PChar(wParam));
|
||||
sText:= PAnsiChar(wParam);
|
||||
if Control is TComboBox then
|
||||
(Control as TComboBox).Items.AddObject(sText, TObject(Pointer(lParam)));
|
||||
if Control is TListBox then
|
||||
|
|
@ -291,7 +281,7 @@ begin
|
|||
end;
|
||||
DM_LISTADDSTR:
|
||||
begin
|
||||
sText:= UTF8Encode(PChar(wParam));
|
||||
sText:= PAnsiChar(wParam);
|
||||
if Control is TComboBox then
|
||||
(Control as TComboBox).Items.Add(sText);
|
||||
if Control is TListBox then
|
||||
|
|
@ -306,7 +296,7 @@ begin
|
|||
end;
|
||||
DM_LISTINDEXOF:
|
||||
begin
|
||||
sText:= UTF8Encode(WideString(PWideChar(lParam)));
|
||||
sText:= PAnsiChar(lParam);
|
||||
if Control is TComboBox then
|
||||
Result:= (Control as TComboBox).Items.IndexOf(sText);
|
||||
if Control is TListBox then
|
||||
|
|
@ -314,7 +304,7 @@ begin
|
|||
end;
|
||||
DM_LISTINSERT:
|
||||
begin
|
||||
sText:= UTF8Encode(WideString(PWideChar(lParam)));
|
||||
sText:= PAnsiChar(lParam);
|
||||
if Control is TComboBox then
|
||||
(Control as TComboBox).Items.Insert(wParam, sText);
|
||||
if Control is TListBox then
|
||||
|
|
@ -340,8 +330,7 @@ begin
|
|||
sText:= (Control as TComboBox).Items[wParam];
|
||||
if Control is TListBox then
|
||||
sText:= (Control as TListBox).Items[wParam];
|
||||
wText:= UTF8Decode(sText);
|
||||
Result:= PtrInt(PWideChar(wText));
|
||||
Result:= PtrInt(PAnsiChar(sText));
|
||||
end;
|
||||
DM_LISTGETITEMINDEX:
|
||||
begin
|
||||
|
|
@ -360,7 +349,7 @@ begin
|
|||
end;
|
||||
DM_LISTUPDATE :
|
||||
begin
|
||||
sText:= UTF8Encode(WideString(PWideChar(lParam)));
|
||||
sText:= PAnsiChar(lParam);
|
||||
if Control is TComboBox then
|
||||
(Control as TComboBox).Items[wParam]:= sText;
|
||||
if Control is TListBox then
|
||||
|
|
@ -378,8 +367,7 @@ begin
|
|||
sText:= (Control as TGroupBox).Caption;
|
||||
if Control is TLabel then
|
||||
sText:= (Control as TLabel).Caption;
|
||||
wText:= UTF8Decode(sText);
|
||||
Result:= PtrInt(PWideChar(wText));
|
||||
Result:= PtrInt(PAnsiChar(sText));
|
||||
end;
|
||||
DM_KEYDOWN:
|
||||
begin
|
||||
|
|
@ -468,7 +456,7 @@ begin
|
|||
end;
|
||||
DM_SETTEXT:
|
||||
begin
|
||||
sText:= UTF8Encode(WideString(PWideChar(wParam)));
|
||||
sText:= PAnsiChar(wParam);
|
||||
if Control is TButton then
|
||||
(Control as TButton).Caption:= sText;
|
||||
if Control is TComboBox then
|
||||
|
|
@ -501,139 +489,139 @@ end;
|
|||
procedure TDialogBox.DialogBoxShow(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_INITDIALOG,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_INITDIALOG,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ButtonClick(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_CLICK,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_CLICK,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ButtonEnter(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_GOTFOCUS,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_GOTFOCUS,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ButtonExit(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KILLFOCUS,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KILLFOCUS,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ButtonKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KEYDOWN,Key,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KEYDOWN,Key,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ButtonKeyUp(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KEYUP,Key,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KEYUP,Key,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ComboBoxClick(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_CLICK,PtrInt((Sender as TComboBox).ItemIndex),0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_CLICK,PtrInt((Sender as TComboBox).ItemIndex),0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ComboBoxDblClick(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_DBLCLICK,PtrInt((Sender as TComboBox).ItemIndex),0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_DBLCLICK,PtrInt((Sender as TComboBox).ItemIndex),0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ComboBoxChange(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
begin
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_CHANGE, PtrInt((Sender as TComboBox).ItemIndex),0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_CHANGE, PtrInt((Sender as TComboBox).ItemIndex),0);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ComboBoxEnter(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_GOTFOCUS,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_GOTFOCUS,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ComboBoxExit(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KILLFOCUS,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KILLFOCUS,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ComboBoxKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KEYDOWN,Key,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KEYDOWN,Key,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ComboBoxKeyUp(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KEYUP,Key,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KEYUP,Key,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.EditClick(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_CLICK,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_CLICK,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.EditDblClick(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_DBLCLICK,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_DBLCLICK,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.EditChange(Sender: TObject);
|
||||
var
|
||||
wText: WideString;
|
||||
sText: UTF8String;
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
begin
|
||||
wText:= UTF8Decode((Sender as TEdit).Text);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_CHANGE, PtrInt(PWideChar(wText)),0);
|
||||
sText:= (Sender as TEdit).Text;
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_CHANGE, PtrInt(PAnsiChar(sText)), 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDialogBox.EditEnter(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_GOTFOCUS,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_GOTFOCUS,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.EditExit(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KILLFOCUS,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KILLFOCUS,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.EditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KEYDOWN,Key,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KEYDOWN,Key,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.EditKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KEYUP,Key,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KEYUP,Key,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ListBoxClick(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
begin
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_CLICK, PtrInt((Sender as TListBox).ItemIndex),0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_CLICK, PtrInt((Sender as TListBox).ItemIndex),0);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -641,7 +629,7 @@ procedure TDialogBox.ListBoxDblClick(Sender: TObject);
|
|||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
begin
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_DBLCLICK, PtrInt((Sender as TListBox).ItemIndex),0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_DBLCLICK, PtrInt((Sender as TListBox).ItemIndex),0);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -649,41 +637,41 @@ procedure TDialogBox.ListBoxSelectionChange(Sender: TObject; User: boolean);
|
|||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
begin
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_CHANGE, PtrInt((Sender as TListBox).ItemIndex),0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_CHANGE, PtrInt((Sender as TListBox).ItemIndex),0);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ListBoxEnter(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_GOTFOCUS,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_GOTFOCUS,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ListBoxExit(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KILLFOCUS,0,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KILLFOCUS,0,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ListBoxKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KEYDOWN,Key,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KEYDOWN,Key,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.ListBoxKeyUp(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_KEYUP,Key,0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_KEYUP,Key,0);
|
||||
end;
|
||||
|
||||
procedure TDialogBox.CheckBoxChange(Sender: TObject);
|
||||
begin
|
||||
if Assigned(fDlgProc) then
|
||||
begin
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PChar((Sender as TControl).Name), DN_CHANGE, PtrInt((Sender as TCheckBox).Checked),0);
|
||||
fDlgProc(PtrUInt(Pointer(Self)), PAnsiChar((Sender as TControl).Name), DN_CHANGE, PtrInt((Sender as TCheckBox).Checked),0);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ interface
|
|||
|
||||
uses
|
||||
LCLType, Classes, Dialogs, dynlibs,
|
||||
uWCXprototypes, WcxPlugin, DialogAPI, uClassesEx, uTypes, uXmlConfig;
|
||||
uWCXprototypes, WcxPlugin, Extension, uClassesEx, uTypes, uXmlConfig;
|
||||
|
||||
Type
|
||||
TWCXOperation = (OP_EXTRACT, OP_PACK, OP_DELETE);
|
||||
|
|
@ -103,8 +103,9 @@ Type
|
|||
StartMemPackW: TStartMemPackW;
|
||||
CanYouHandleThisFileW: TCanYouHandleThisFileW;
|
||||
PkSetCryptCallbackW : TPkSetCryptCallbackW;
|
||||
{ Dialog API }
|
||||
SetDlgProc: TSetDlgProc;
|
||||
{ Extension API }
|
||||
ExtensionInitialize: TExtensionInitializeProc;
|
||||
ExtensionFinalize: TExtensionFinalizeProc;
|
||||
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
|
|
@ -180,7 +181,13 @@ end;
|
|||
|
||||
destructor TWCXModule.Destroy;
|
||||
begin
|
||||
UnloadModule;
|
||||
if IsLoaded then
|
||||
begin
|
||||
if Assigned(ExtensionFinalize) then
|
||||
ExtensionFinalize(nil);
|
||||
//------------------------------------------------------
|
||||
UnloadModule;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TWCXModule.OpenArchiveHandle(FileName: String; anOpenMode: Longint; out OpenResult: Longint): TArcHandle;
|
||||
|
|
@ -317,9 +324,7 @@ end;
|
|||
function TWCXModule.LoadModule(const sName:String):Boolean;
|
||||
var
|
||||
PackDefaultParamStruct : TPackDefaultParamStruct;
|
||||
SetDlgProcInfo: TSetDlgProcInfo;
|
||||
sPluginDir: WideString;
|
||||
sPluginConfDir: WideString;
|
||||
StartupInfo: TExtensionStartupInfo;
|
||||
begin
|
||||
FModuleHandle := mbLoadLibrary(sName);
|
||||
if FModuleHandle = 0 then
|
||||
|
|
@ -370,8 +375,9 @@ begin
|
|||
StartMemPackW:= TStartMemPackW(GetProcAddress(FModuleHandle,'StartMemPackW'));
|
||||
CanYouHandleThisFileW:= TCanYouHandleThisFileW(GetProcAddress(FModuleHandle,'CanYouHandleThisFileW'));
|
||||
PkSetCryptCallbackW:= TPkSetCryptCallbackW(GetProcAddress(FModuleHandle,'PkSetCryptCallbackW'));
|
||||
// Dialog API function
|
||||
SetDlgProc:= TSetDlgProc(GetProcAddress(FModuleHandle,'SetDlgProc'));
|
||||
// Extension API
|
||||
ExtensionInitialize:= TExtensionInitializeProc(GetProcAddress(FModuleHandle,'ExtensionInitialize'));
|
||||
ExtensionFinalize:= TExtensionFinalizeProc(GetProcAddress(FModuleHandle,'ExtensionFinalize'));
|
||||
|
||||
if Assigned(PackSetDefaultParams) then
|
||||
begin
|
||||
|
|
@ -390,16 +396,16 @@ begin
|
|||
else
|
||||
FBackgroundFlags:= GetBackgroundFlags();
|
||||
|
||||
// Dialog API
|
||||
if Assigned(SetDlgProc) then
|
||||
// Extension API
|
||||
if Assigned(ExtensionInitialize) then
|
||||
begin
|
||||
sPluginDir := UTF8Decode(ExtractFilePath(sName));
|
||||
sPluginConfDir := UTF8Decode(gpCfgDir);
|
||||
FillByte(StartupInfo, SizeOf(TStartupInfo), 0);
|
||||
|
||||
with SetDlgProcInfo do
|
||||
with StartupInfo do
|
||||
begin
|
||||
PluginDir:= PWideChar(sPluginDir);
|
||||
PluginConfDir:= PWideChar(sPluginConfDir);
|
||||
StructSize:= SizeOf(TExtensionStartupInfo);
|
||||
PluginDir:= PAnsiChar(ExtractFilePath(sName));
|
||||
PluginConfDir:= PAnsiChar(gpCfgDir);
|
||||
InputBox:= @fDialogBox.InputBox;
|
||||
MessageBox:= @fDialogBox.MessageBox;
|
||||
DialogBoxLFM:= @fDialogBox.DialogBoxLFM;
|
||||
|
|
@ -408,7 +414,7 @@ begin
|
|||
SendDlgMsg:= @fDialogBox.SendDlgMsg;
|
||||
end;
|
||||
|
||||
SetDlgProc(SetDlgProcInfo);
|
||||
ExtensionInitialize(@StartupInfo);
|
||||
end;
|
||||
|
||||
Result := True;
|
||||
|
|
@ -454,8 +460,9 @@ begin
|
|||
StartMemPackW:= nil;
|
||||
CanYouHandleThisFileW:= nil;
|
||||
PkSetCryptCallbackW:= nil;
|
||||
// DialogAPI
|
||||
SetDlgProc:= nil;
|
||||
// Extension API
|
||||
ExtensionInitialize:= nil;
|
||||
ExtensionFinalize:= nil;
|
||||
end;
|
||||
|
||||
function GetErrorMsg(iErrorMsg : Integer): String;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ interface
|
|||
|
||||
uses
|
||||
SysUtils, Classes, WfxPlugin, uWFXprototypes,
|
||||
dynlibs, uClassesEx, DialogAPI, uTypes, uXmlConfig;
|
||||
dynlibs, uClassesEx, Extension, uTypes, uXmlConfig;
|
||||
|
||||
const
|
||||
WFX_SUCCESS = 0;
|
||||
|
|
@ -124,8 +124,9 @@ type
|
|||
FsContentStopGetValueW: TFsContentStopGetValueW;
|
||||
FsContentSetValueW: TFsContentSetValueW;
|
||||
FsContentGetDefaultViewW: TFsContentGetDefaultViewW;
|
||||
{ Dialog API }
|
||||
SetDlgProc: TSetDlgProc;
|
||||
{ Extension API }
|
||||
ExtensionInitialize: TExtensionInitializeProc;
|
||||
ExtensionFinalize: TExtensionFinalizeProc;
|
||||
public
|
||||
function WfxFindFirst(Path: UTF8String; var FindData: TWfxFindData): THandle;
|
||||
function WfxFindNext(Hdl: THandle; var FindData: TWfxFindData): Boolean;
|
||||
|
|
@ -149,7 +150,6 @@ type
|
|||
function LoadModule(const sName: String):Boolean; {Load plugin}
|
||||
procedure UnloadModule;
|
||||
procedure VFSInit(Data: PtrInt);
|
||||
procedure VFSDestroy;
|
||||
|
||||
function VFSConfigure(Parent: THandle):Boolean;
|
||||
function VFSRootName: UTF8String;
|
||||
|
|
@ -445,14 +445,14 @@ end;
|
|||
destructor TWFXModule.Destroy;
|
||||
begin
|
||||
if IsLoaded then
|
||||
begin
|
||||
//TODO:Remove this and use VFSDestroy
|
||||
//------------------------------------------------------
|
||||
if Assigned(FsContentPluginUnloading) then
|
||||
FsContentPluginUnloading;
|
||||
//------------------------------------------------------
|
||||
UnloadModule;
|
||||
end;
|
||||
begin
|
||||
if Assigned(FsContentPluginUnloading) then
|
||||
FsContentPluginUnloading;
|
||||
if Assigned(ExtensionFinalize) then
|
||||
ExtensionFinalize(nil);
|
||||
//------------------------------------------------------
|
||||
UnloadModule;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TWFXModule.LoadModule(const sName: String): Boolean;
|
||||
|
|
@ -530,8 +530,9 @@ begin
|
|||
FsStatusInfoW := TFsStatusInfoW(GetProcAddress(FModuleHandle,'FsStatusInfoW'));
|
||||
FsExtractCustomIconW := TFsExtractCustomIconW(GetProcAddress(FModuleHandle,'FsExtractCustomIconW'));
|
||||
FsGetLocalNameW := TFsGetLocalNameW(GetProcAddress(FModuleHandle,'FsGetLocalNameW'));
|
||||
{ Dialog API }
|
||||
SetDlgProc:= TSetDlgProc(GetProcAddress(FModuleHandle,'SetDlgProc'));
|
||||
{ Extension API }
|
||||
ExtensionInitialize:= TExtensionInitializeProc(GetProcAddress(FModuleHandle,'ExtensionInitialize'));
|
||||
ExtensionFinalize:= TExtensionFinalizeProc(GetProcAddress(FModuleHandle,'ExtensionFinalize'));
|
||||
end;
|
||||
|
||||
procedure TWFXModule.UnloadModule;
|
||||
|
|
@ -596,16 +597,15 @@ begin
|
|||
FsStatusInfoW := nil;
|
||||
FsExtractCustomIconW := nil;
|
||||
FsGetLocalNameW := nil;
|
||||
{ Dialog API }
|
||||
SetDlgProc:= nil;
|
||||
// Extension API
|
||||
ExtensionInitialize:= nil;
|
||||
ExtensionFinalize:= nil;
|
||||
end;
|
||||
|
||||
procedure TWFXModule.VFSInit(Data: PtrInt);
|
||||
var
|
||||
dps: pFsDefaultParamStruct;
|
||||
SetDlgProcInfo: TSetDlgProcInfo;
|
||||
sPluginDir: WideString;
|
||||
sPluginConfDir: WideString;
|
||||
dps: PFsDefaultParamStruct;
|
||||
StartupInfo: TExtensionStartupInfo;
|
||||
begin
|
||||
if Assigned(FsSetDefaultParams) then
|
||||
begin
|
||||
|
|
@ -621,16 +621,16 @@ begin
|
|||
FreeMem(dps, SizeOf(tFsDefaultParamStruct));
|
||||
end;
|
||||
|
||||
// Dialog API
|
||||
if Assigned(SetDlgProc) then
|
||||
// Extension API
|
||||
if Assigned(ExtensionInitialize) then
|
||||
begin
|
||||
sPluginDir := UTF8Decode(ExtractFilePath(FModuleFileName));
|
||||
sPluginConfDir := UTF8Decode(gpCfgDir);
|
||||
FillByte(StartupInfo, SizeOf(TStartupInfo), 0);
|
||||
|
||||
with SetDlgProcInfo do
|
||||
with StartupInfo do
|
||||
begin
|
||||
PluginDir:= PWideChar(sPluginDir);
|
||||
PluginConfDir:= PWideChar(sPluginConfDir);
|
||||
StructSize:= SizeOf(TExtensionStartupInfo);
|
||||
PluginDir:= PAnsiChar(ExtractFilePath(FModuleFileName));
|
||||
PluginConfDir:= PAnsiChar(gpCfgDir);
|
||||
InputBox:= @fDialogBox.InputBox;
|
||||
MessageBox:= @fDialogBox.MessageBox;
|
||||
DialogBoxLFM:= @fDialogBox.DialogBoxLFM;
|
||||
|
|
@ -639,17 +639,10 @@ begin
|
|||
SendDlgMsg:= @fDialogBox.SendDlgMsg;
|
||||
end;
|
||||
|
||||
SetDlgProc(SetDlgProcInfo);
|
||||
ExtensionInitialize(@StartupInfo);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TWFXModule.VFSDestroy;
|
||||
begin
|
||||
//TODO: need to invoke this func
|
||||
if Assigned(FsContentPluginUnloading) then
|
||||
FsContentPluginUnloading;
|
||||
end;
|
||||
|
||||
function TWFXModule.VFSConfigure(Parent: THandle): Boolean;
|
||||
var
|
||||
RemoteName: UTF8String;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue