Autor Beitrag
Magic2001
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32


Delphi XE2
BeitragVerfasst: Mi 21.01.09 14:22 
Habe mit einen kleinen Browser selbst programmiert und bin auch zufrieden damit. Heute musste ich aber mit entsetzen feststellen das es im TwebBrowser scheinbar nicht möglich ist die Tasten zu benutzen. Zb um Flash Spiele zu spielen.

Weis von euch jemand wie ich es hinbekomme das im TwebBrowser auch die Steuerungstasten (pfeile) usw. funktionieren?
Manfred
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 90



BeitragVerfasst: Mi 28.01.09 12:05 
Hi!
Du benötigst einen MessageHandler, der die Tastatureingaben abfängt und an den WebBrowser weiterleitet.
Z.B. so:

ausblenden volle Höhe Delphi-Quelltext
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:
procedure TForm1.MsgHandler(var Msg: TMsg; var Handled: Boolean);
const
  DialogKeys: set of Byte = [VK_LEFT, VK_RIGHT, VK_BACK, VK_UP, VK_DOWN,
    $30..$39$41..$42$44..$55$57$59..$5A];
var
  iOIPAO: IOleInPlaceActiveObject;
  Dispatch: IDispatch;
begin
  { exit if we don't get back a webbrowser object }
  if (WebBrowser1 = nilthen
  begin
    Handled := System.False;
    Exit;
  end;

  Handled := (IsDialogMessage(WebBrowser1.Handle, Msg) = System.True);

  if (Handled) and (not WebBrowser1.Busy) then
  begin
    if FOleInPlaceActiveObject = nil then
    begin
      Dispatch := WebBrowser1.Application ; // oder auch DefaultDispatch;
      if Dispatch <> nil then begin
        Dispatch.QueryInterface(IOleInPlaceActiveObject, iOIPAO);
        if iOIPAO <> nil then
          FOleInPlaceActiveObject := iOIPAO;
      end;
    end;

    if FOleInPlaceActiveObject <> nil then
      if ((Msg.message = WM_KEYDOWN) (* or (Msg.message = WM_KEYUP) *) ) and
        (Msg.wParam in DialogKeys) then
        // nothing - do not pass on the DialogKeys
      else
        FOleInPlaceActiveObject.TranslateAccelerator(Msg);
  end;
end;

Um den Handler anzumelden:
ausblenden Delphi-Quelltext
1:
  Application.OnMessage := MsgHandler;					

_________________
Computer können schneller rechnen als wir, deshalb machen sie auch mehr Fehler
Magic2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32


Delphi XE2
BeitragVerfasst: Do 29.01.09 12:55 
da kann er das nicht finden: FOleInPlaceActiveObject (undefinierter bezeichner)
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 29.01.09 18:52 
Und darauf hin hättest du nach Suche bei Google FOLEINPLACEACTIVEOBJECT suchen können und hättest die komplette Lösung mit Deklaration von FOleInPlaceActiveObject hier gefunden:
www.swissdelphicente...showcode.php?id=1055

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Magic2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32


Delphi XE2
BeitragVerfasst: Do 29.01.09 22:10 
Danke.