summaryrefslogtreecommitdiff
path: root/plugins/Actman/hooks/hooks.pas
blob: 0bfa508afeca15515f58a5c7c51678ee7f6d7c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
unit hooks;

interface

implementation

uses
  windows, commctrl, messages,
  mirutils, common, dbsettings, m_api, wrapper,
  global, mApiCardM;

{$R hooks.res}

{$include i_hook.inc}
{$include i_hconst.inc}
{$include i_options.inc}
{$include i_opt_dlg.inc}

// ------------ base interface functions -------------

procedure Init;
begin

  MessageWindow:=CreateWindowExW(0,'STATIC',nil,0,1,1,1,1,HWND_MESSAGE,0,hInstance,nil);
  if MessageWindow<>0 then
    SetWindowLongPtrW(MessageWindow,GWL_WNDPROC,LONG_PTR(@HookWndProc));

  if LoadHooks=0 then
  begin
    MaxHooks:=8;
    GetMem  (HookList ,MaxHooks*SizeOf(tHookRec));
    FillChar(HookList^,MaxHooks*SizeOf(tHookRec),0);
  end
  else
    SetAllHooks;
end;

procedure DeInit;
begin
  ClearHooks;
  if MessageWindow<>0 then
    DestroyWindow(MessageWindow);
end;

function AddOptionPage(var tmpl:pAnsiChar;var proc:pointer;var name:PAnsiChar):integer;
begin
  result:=0;
  tmpl:=PAnsiChar(IDD_HOOKS);
  proc:=@DlgProcOpt;
  name:='Hooks';
end;

var
  amLink:tActionLink;

procedure InitLink;
begin
  amLink.Next     :=ActionLink;
  amLink.Init     :=@Init;
  amLink.DeInit   :=@DeInit;
  amLink.AddOption:=@AddOptionPage;
  ActionLink      :=@amLink;
end;

initialization
  InitLink;
end.