这个TApplicationEvents组件要手动添加,在Additional选项页里;
你也可不要,直接指定Application.OnMessage := ApplicationEvents1Message;//你定义的OnMessage过程。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AppEvnts;
type
TForm1 = class(TForm)
ApplicationEvents1: TApplicationEvents;
procedure ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
const
AStdKeys = [VK_TAB, VK_RETURN]; { standard keys }
ExtKeys = [VK_DELETE, VK_BACK, VK_LEFT, VK_RIGHT]; { extended keys }
fExtended = $01000000; { extended key flag }
begin
Handled := False;
with Msg do // ((Message >= WM_KEYDOWN)and (Message <= WM_KEYLAST))
if (Message = WM_KEYDOWN)and
((wParam in AStdKeys) or
{$IFDEF VER120}(GetKeyState(VK_CONTROL) < 0) or {$ENDIF}
(wParam in ExtKeys) and ((lParam and fExtended) = fExtended)) then
try
if IsChild(pgc_WEB.ActivePage.Handle, hWnd) then { handles all browser related messages }
begin
AppActivate(PChar(pgc_WEB.ActivePage.Controls[0].Name));
case Message of
VK_RETURN: begin
Sendkeys('~',true);
Handled := False;
end;
end;
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
except
end;
end;
end.