Thema: Delphi EnterKey activate ?

Einzelnen Beitrag anzeigen

Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#11

Re: EnterKey activate ?

  Alt 20. Jun 2008, 08:01
Hab's noch etwas abgeändert. Sollte nun funktionieren.
(Alternative: Den EmbeddedWB verwenden)

Delphi-Quellcode:
function TForm1.GetCurrentWB: TWebbrowser;
begin
  Result := nil;
  with PageControl1 do
    if ActivePage.Controls[0] is TWebbrowser then
      Result := (TWebbrowser(ActivePage.Controls[0]));
end;

procedure TForm1.MsgHandler(var Msg: TMsg; var Handled: Boolean);
const
  StdKeys = [VK_TAB, VK_RETURN]; { standard keys }
  ExtKeys = [VK_DELETE, VK_BACK, VK_LEFT, VK_RIGHT]; { extended keys }
  fExtended = $01000000; { extended key flag }
var
  CurrentWB: TWebbrowser;
begin
  CurrentWB := FCurrentWB;
  // exit if we don't get back a webbrowser object
  if not Assigned(CurrentWB) then
  begin
    Handled := False;
    Exit;
  end;

  if IsChild(CurrentWB.Handle, Msg.Hwnd) then
  begin
    if (Msg.Message = WM_CLOSE) then
      msg.message := 0
    else
      if ((Msg.Message >= WM_KEYFIRST) and (Msg.Message <= WM_KEYLAST)) and
        ((Msg.wParam in StdKeys) or (GetKeyState(VK_CONTROL) < 0) or
        (Msg.wParam in ExtKeys) and ((Msg.lParam and fExtended) = fExtended)) then
      begin
        Handled := (CurrentWB.Application as IOleInPlaceActiveObject).TranslateAccelerator(Msg) = S_OK;
        if not Handled then
        begin
          Handled := True;
          TranslateMessage(Msg);
          DispatchMessage(Msg);
        end;
      end;
  end;
end;

procedure TForm1.PageControl1Change(Sender: TObject);
begin
begin
  FCurrentWB := GetCurrentWB;
end;
Thomas
  Mit Zitat antworten Zitat