Bonjour à tous,

j'ai une application MDI dans laquelle j'ai ajouté une fonction pour proposer mon propre popupmenu dans un TWebBrowser classique.
Le code est ci-dessous.

Mais voilà, je n'arrive pas à trouver quelle variable je dois mettre devant mon popupmenu (voir ligne en rouge) pour que celui-ci soit connu dans ma fiche MDI.

Si je mets Child, je n'ai pas d'erreur à la compil mais elle est égale à Nil à l'execution.
Self me provoque une erreur à la compilation (self non défini)

Est-ce que quelqu'un aurait une solution pour moi ?

Merci pour votre aide,
Amicalement,
Bruno

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
{
based on: http://www.swissdelphicenter.ch/de/showcode.php?id=571
}

var
  Form1: TForm1;
  HookID: THandle;

implementation

{$R *.DFM}


function MouseProc(nCode: Integer; wParam, lParam: Longint): Longint; stdcall;
var
  szClassName: array[0..255] of Char;
  MausPos: TPoint;
  X, Y: Integer;
const
  ie_name = 'Internet Explorer_Server';
begin
  GetCursorPos(MausPos);
  x := MausPos.x;
  y := MausPos.y;

  if (nCode < 0) then
    Result := CallNextHookEx(HookID, nCode, wParam, lParam)
  else if ((wParam = WM_RBUTTONDOWN) or (wParam = WM_RBUTTONUP)) then
  begin
    GetClassName(PMOUSEHOOKSTRUCT(lParam)^.HWND, szClassName,
      SizeOf(szClassName));
    if lstrcmp(@szClassName[0], @ie_name[1]) = 0 then
    begin
      Result := HC_SKIP;
      Child.popupmenu1.popup(X, Y);
    end
    else
      Result := CallNextHookEx(HookID, nCode, wParam, lParam);
  end
  else
    Result := CallNextHookEx(HookID, nCode, wParam, lParam);
end;



procedure TForm1.FormCreate(Sender: TObject);
begin
  HookID := SetWindowsHookEx(WH_MOUSE, MouseProc, 0, GetCurrentThreadId());
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  if HookID <> 0 then
    UnHookWindowsHookEx(HookID);
end;