var
hHk: HHOOK;
// 钩子函数
function MouseHookProc(nCode: Integer; WParam: WParam; LParam: LParam)
: LRESULT; stdcall;
var
MouseHookStruct: ^TMOUSEHOOKSTRUCT;
begin
Result := 0;
if nCode < 0 then
Result := CallNextHookEx(hHk, nCode, WParam, LParam)
else if WParam = WM_RBUTTONDOWN then
begin
MouseHookStruct := Pointer(LParam);
if MouseHookStruct.hwnd = form1.ShockwaveFlash1.Handle then
Result := 1;
end;
end;
// 加载钩子
if hHk = 0 then
Begin
hHk := SetWindowsHookEx(WH_MOUSE, @MouseHookProc, Hinstance, 0);
end;
// 卸掉钩子
if hHk <> 0 then
begin
UnHookWindowsHookEx(hHk);
hHk := 0;
end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if Msg.message = WM_RBUTTONDOWN then
Handled := True;
end;
If by chance you wanted to place your own popupmenu, then
do the following:
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if Msg.message = WM_RBUTTONDOWN then
begin
popupmenu1.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
Handled := True;
end;
end;