|
후킹으로 해결하는 방법도 있군요.
[팁] Twebbrowser에 Context메뉴 얼리기
Twebbrowser에 Context메뉴 얼리기
var
Form1 : TForm;
HookID : THandle;
DisableRButton : boolean;
implementation
function MouseProc(nCode: integer; wParam,
lParam: longint): longint; stdcall;
function GetClassNameEnh(Handle: Hwnd): string;
var
ClassName: PChar;
Buffer: integer;
begin
Buffer := 40;
getmem(ClassName, Buffer);
windows.GetClassName(Handle, ClassName, Buffer);
Result := ClassName;
Freemem(ClassName);
end;
var
P: TPoint;
begin
if (nCode < 0) then
Result := CallNextHookEx(HookID, nCode, wParam, lParam)
else if DisableRButton and ((wParam = WM_RBUTTONDOWN) or (wParam =
WM_RBUTTONUP)) then
begin
GetCursorPos(P);
if Pos('Internet Explorer_', GetClassNameEnh(WindowFromPoint(P))) <> 0 then
Result := HC_SKIP
else
Result := CallNextHookEx(HookID, nCode, wParam, lParam);
end
else
Result := CallNextHookEx(HookID, nCode, wParam, lParam);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DisableRButton := True;
HookID := SetWindowsHookEx(WH_MOUSE, MouseProc, 0, GetCurrentThreadId());
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if HookID <> 0 then
UnHookWindowsHookEx(HookID);
end;
김태선 님이 쓰신 글 :
: 분명히 컴포넌트에 PopUpMenu를 지정할수 있는 프로퍼티가 있어 지정했는데,
: 오른쪽 버턴을 클릭하면 원래의 IE 팝업메뉴가 나오네요...
: 사실 그걸 막고 싶어서 팝업메뉴를 나오게 하려는 것인데
: 왜 동작을 하지 않을까요?
:
: IE Control이 먼저 키를 인터셉트하는 것 같은데요?
: 혹 비슷한 증상에 고민해 보신분 없으십니까?
:
|