extension.pas 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. unit Extension;
  2. interface
  3. const
  4. // dialog messages
  5. DM_FIRST = 0;
  6. DM_CLOSE = DM_FIRST+1; // A signal that the dialog is about to close
  7. DM_ENABLE = DM_FIRST+2;
  8. DM_GETDLGDATA = DM_FIRST+3;
  9. DM_GETDLGBOUNDS = DM_FIRST+4;
  10. DM_GETITEMBOUNDS = DM_FIRST+5;
  11. DM_GETTEXT = DM_FIRST+6; // Retrieve the text of an edit string or the caption of an item
  12. DM_KEYDOWN = DM_FIRST+7;
  13. DM_KEYUP = DM_FIRST+8;
  14. DM_SETDLGDATA = DM_FIRST+9;
  15. DM_SETFOCUS = DM_FIRST+10; // Set the keyboard focus to the given dialog item
  16. DM_REDRAW = DM_FIRST+11; // Redraw the whole dialog
  17. DM_SETTEXT = DM_FIRST+12; // Set a new string value for an edit line or a new caption for an item
  18. DM_SETMAXTEXTLENGTH = DM_FIRST+13; // Set the maximum length of an edit string
  19. DM_SHOWDIALOG = DM_FIRST+14; // Show/hide the dialog window
  20. DM_SHOWITEM = DM_FIRST+15; // Show/hide a dialog item
  21. DM_GETCHECK = DM_FIRST+16; // Retrieve the state of TCheckBox or TRadioButton items
  22. DM_SETCHECK = DM_FIRST+17; // Change the state of TCheckBox and TRadioButton items
  23. DM_LISTGETITEM = DM_FIRST+18; // Retrieve a list item
  24. DM_LISTGETITEMINDEX = DM_FIRST+19; // Get current item index in a list
  25. DM_LISTSETITEMINDEX = DM_FIRST+20; // Set current item index in a list
  26. DM_LISTDELETE = DM_FIRST+21;
  27. DM_LISTADD = DM_FIRST+22;
  28. DM_LISTADDSTR = DM_FIRST+23;
  29. DM_LISTUPDATE = DM_FIRST+24;
  30. DM_LISTINSERT = DM_FIRST+25;
  31. DM_LISTINDEXOF = DM_FIRST+26;
  32. DM_LISTGETCOUNT = DM_FIRST+27;
  33. DM_LISTGETDATA = DM_FIRST+28;
  34. DM_LISTSETDATA = DM_FIRST+29;
  35. DM_SETDLGBOUNDS = DM_FIRST+30;
  36. DM_SETITEMBOUNDS = DM_FIRST+31;
  37. DM_GETDROPPEDDOWN = DM_FIRST+32;
  38. DM_SETDROPPEDDOWN = DM_FIRST+33;
  39. DM_GETITEMDATA = DM_FIRST+34;
  40. DM_SETITEMDATA = DM_FIRST+35;
  41. DM_LISTSET = DM_FIRST+36;
  42. DM_SETPROGRESSVALUE = DM_FIRST+37;
  43. DM_SETPROGRESSSTYLE = DM_FIRST+38;
  44. DM_SETPASSWORDCHAR = DM_FIRST+39;
  45. DM_LISTCLEAR = DM_FIRST+40;
  46. DM_TIMERSETINTERVAL = DM_FIRST+41;
  47. // events messages
  48. DN_FIRST = $1000;
  49. DN_CLICK = DN_FIRST+1; // Sent after mouse click
  50. DN_DBLCLICK = DN_FIRST+2; // Sent after mouse double click
  51. DN_CHANGE = DN_FIRST+3; // Sent after the dialog item is changed
  52. DN_GOTFOCUS = DN_FIRST+4; // Sent when the dialog item gets input focus
  53. DN_INITDIALOG = DN_FIRST+5; // Sent before showing the dialog
  54. DN_KILLFOCUS = DN_FIRST+6; // Sent before a dialog item loses the input focus
  55. DN_TIMER = DN_FIRST+7; // Sent when a timer expires
  56. DN_KEYDOWN = DM_KEYDOWN;
  57. DN_KEYUP = DM_KEYUP;
  58. DN_CLOSE = DM_CLOSE; // Sent before the dialog is closed
  59. DM_USER = $4000; // Starting value for user defined messages
  60. const
  61. // Set/Get Property
  62. TK_STRING = 1;
  63. TK_FLOAT = 2;
  64. TK_INT32 = 3;
  65. TK_INT64 = 4;
  66. TK_BOOL = 5;
  67. const
  68. // MessageBox: To indicate the buttons displayed in the message box,
  69. // specify one of the following values.
  70. MB_OK = $00000000;
  71. MB_OKCANCEL = $00000001;
  72. MB_ABORTRETRYIGNORE = $00000002;
  73. MB_YESNOCANCEL = $00000003;
  74. MB_YESNO = $00000004;
  75. MB_RETRYCANCEL = $00000005;
  76. MB_ICONHAND = $00000010;
  77. MB_ICONQUESTION = $00000020;
  78. MB_ICONEXCLAMATION = $00000030;
  79. MB_ICONASTERICK = $00000040;
  80. MB_ICONWARNING = MB_ICONEXCLAMATION;
  81. MB_ICONERROR = MB_ICONHAND;
  82. MB_ICONSTOP = MB_ICONHAND;
  83. MB_ICONINFORMATION = MB_ICONASTERICK;
  84. // MessageBox: To indicate the default button, specify one of the following values.
  85. MB_DEFBUTTON1 = $00000000;
  86. MB_DEFBUTTON2 = $00000100;
  87. MB_DEFBUTTON3 = $00000200;
  88. MB_DEFBUTTON4 = $00000300;
  89. // MessageBox: Return values
  90. ID_OK = 1;
  91. ID_CANCEL = 2;
  92. ID_ABORT = 3;
  93. ID_RETRY = 4;
  94. ID_IGNORE = 5;
  95. ID_YES = 6;
  96. ID_NO = 7;
  97. ID_CLOSE = 8;
  98. ID_HELP = 9;
  99. // DialogBoxParam: Flags
  100. DB_LFM = 0; // Data contains a form in the LFM format
  101. DB_LRS = 1; // Data contains a form in the LRS format
  102. DB_FILENAME = 2; // Data contains a form file name (*.lfm)
  103. const
  104. EXT_MAX_PATH = 16384; // 16 Kb
  105. { For compatibility with Delphi use $IFDEF's to set calling convention }
  106. type
  107. { Dialog window callback function }
  108. TDlgProc = function(pDlg: PtrUInt; DlgItemName: PAnsiChar; Msg, wParam, lParam: PtrInt): PtrInt; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  109. { Definition of callback functions called by the DLL }
  110. TInputBoxProc = function(Caption, Prompt: PAnsiChar; MaskInput: LongBool; Value: PAnsiChar; ValueMaxLen: Integer): LongBool; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  111. TMessageBoxProc = function(Text, Caption: PAnsiChar; Flags: Longint): Integer; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  112. TMsgChoiceBoxProc = function(Text, Caption: PAnsiChar; Buttons: PPAnsiChar; BtnDef, BtnEsc: Integer): Integer; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  113. TDialogBoxLFMProc = function(LFMData: Pointer; DataSize: LongWord; DlgProc: TDlgProc): LongBool; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  114. TDialogBoxLRSProc = function(LRSData: Pointer; DataSize: LongWord; DlgProc: TDlgProc): LongBool; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  115. TDialogBoxLFMFileProc = function(lfmFileName: PAnsiChar; DlgProc: TDlgProc): LongBool; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  116. TDialogBoxParamProc = function(Data: Pointer; DataSize: LongWord; DlgProc: TDlgProc; Flags: LongWord; UserData, Reserved: Pointer): UIntPtr; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  117. TTranslateStringProc = function(Translation: Pointer; Identifier, Original: PAnsiChar; Output: PAnsiChar; OutLen: Integer): Integer {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  118. TSetProperty = function(pDlg: UIntPtr; DlgItemName, PropName: PAnsiChar; PropValue: Pointer; PropType: Integer): PtrInt; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  119. TGetProperty = function(pDlg: UIntPtr; DlgItemName, PropName: PAnsiChar; PropValue: Pointer; PropType, PropSize: Integer): PtrInt; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  120. TCreateComponent = function(pDlg: UIntPtr; Parent, DlgItemName, DlgItemClass: PAnsiChar; Reserved: Pointer): UIntPtr; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  121. type
  122. PExtensionStartupInfo = ^TExtensionStartupInfo;
  123. TExtensionStartupInfo = packed record
  124. // The size of the structure, in bytes
  125. StructSize: LongWord;
  126. // Directory where plugin is located (UTF-8 encoded)
  127. PluginDir: packed array [0..Pred(EXT_MAX_PATH)] of AnsiChar;
  128. // Directory where plugin configuration file must be located (UTF-8 encoded)
  129. PluginConfDir: packed array [0..Pred(EXT_MAX_PATH)] of AnsiChar;
  130. // Dialog API
  131. InputBox: TInputBoxProc;
  132. MessageBox: TMessageBoxProc;
  133. DialogBoxLFM: TDialogBoxLFMProc;
  134. DialogBoxLRS: TDialogBoxLRSProc;
  135. DialogBoxLFMFile: TDialogBoxLFMFileProc;
  136. SendDlgMsg: TDlgProc;
  137. Translation: Pointer;
  138. TranslateString: TTranslateStringProc;
  139. VersionAPI: UIntPtr;
  140. MsgChoiceBox: TMsgChoiceBoxProc;
  141. DialogBoxParam: TDialogBoxParamProc;
  142. SetProperty: TSetProperty;
  143. GetProperty: TGetProperty;
  144. CreateComponent: TCreateComponent;
  145. LanguageID: packed array [0..15] of AnsiChar;
  146. // Reserved for future API extension
  147. Reserved: packed array [0..Pred(4086 * SizeOf(Pointer))] of Byte;
  148. end;
  149. type
  150. TExtensionInitializeProc = procedure(StartupInfo: PExtensionStartupInfo); {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  151. TExtensionFinalizeProc = procedure(Reserved: Pointer); {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  152. implementation
  153. (* Plugin must implement this function for working with Extension API
  154. procedure ExtensionInitialize(StartupInfo: PExtensionStartupInfo); {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  155. procedure ExtensionFinalize(Reserved: Pointer); {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
  156. *)
  157. end.