Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows Message/TWebBrowser Problem

Posted on 1999-06-26
4
Medium Priority
?
321 Views
Last Modified: 2010-04-06
I am using a Twebbrowser and I am am using the procedure below for message handling...  I do this to make the tab and delete buttons work.  The only problem is that it makes the backspace button work TWICE!  Can someone help me stop making it do this?

Here is what I have done...

procedure TfrmMain.MyMessageHandler(var Msg: TMsg; var Handled: Boolean);
var
  iOIPAO: IOleInPlaceActiveObject;
  Dispatch: IDispatch;
  mouse:Tpoint;
begin
  if (Msg.Message = WM_RBUTTONDOWN) or (Msg.Message = WM_RBUTTONUP) then
    begin
      handled:=True;
      getcursorpos(Mouse);
      popupmenu1.popup(Mouse.x,Mouse.y);
    end
  else
    begin
     if Msg.Message = then
       ShowMessage('AAAA');
     { exit if we don't get back a webbrowser object }
     if WebBrowser = nil then
       begin
         Handled := False;
         Exit;
       end;

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

     if (Handled) and (not WebBrowser.Busy) then
       begin
         if FOleInPlaceActiveObject = nil then
           begin
             Dispatch := WebBrowser.Application_;
               if Dispatch <> nil then
                 begin
                   Dispatch.QueryInterface(IOleInPlaceActiveObject, iOIPAO);
                   if iOIPAO <> nil then
                     FOleInPlaceActiveObject := iOIPAO;
                 end;
           end;
           
         if FOleInPlaceActiveObject <> nil then
             FOleInPlaceActiveObject.TranslateAccelerator(Msg);
       end;
    end;
end;


Thanks
0
Comment
Question by:LeeT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 1384737
if Msg.Message = then
  ShowMessage('AAAA');



What's that? Think you stripped it too much  :o)
0
 
LVL 17

Accepted Solution

by:
inthe earned 2000 total points
ID: 1384738
hi,
does this one work better for you?

var
  Form1: TForm1;
   FOleInPlaceActiveObject: IOleInPlaceActiveObject;
implementation

{$R *.DFM}
procedure TForm1.MyMessageHandler(var Msg: TMsg; var Handled: Boolean);
var mouse:Tpoint;
  iOIPAO: IOleInPlaceActiveObject;
  Dispatch: IDispatch;
 begin
 if (Msg.Message = WM_RBUTTONDOWN) or (Msg.Message = WM_RBUTTONUP) then begin
handled:=True;
getcursorpos(Mouse);
popupmenu1.popup(Mouse.x,Mouse.y);
end
else if WebBrowser1 = nil then
  begin
    Handled := False;
    Exit;
  end;

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

  if (Handled) and (not WebBrowser1.Busy) then
  begin
    if FOleInPlaceActiveObject = nil then
    begin
      Dispatch := WebBrowser1.ControlInterface;
      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 = VK_BACK) or (Msg.wParam = VK_LEFT) or
(Msg.wParam =VK_RIGHT) or (Msg.wParam = VK_SHIFT) or
(Msg.wParam = VK_TAB) or (Msg.wParam = VK_DELETE)) then
{ nothing - do not pass on Backspace, Left or Right arrows or tab or delete }
      else
          FOleInPlaceActiveObject.TranslateAccelerator(Msg)
  end;
end;



note the lines that stop the keys being passed this should stop the message from going twice.
Regards Barry
0
 

Author Comment

by:LeeT
ID: 1384739
Epsylon, I was testing stuff and I forgot to remove it :)

InThe,

It worked, except I had to remove the Tab and delete from the if statement so it would work....
0
 
LVL 17

Expert Comment

by:inthe
ID: 1384740
oh whoops musta missed them :-)

Cheers
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question