Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Command buttons in a form with a browser in it
Message
 
À
20/10/2012 08:53:27
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01555394
Message ID:
01555491
Vues:
66
J'aime (1)
Hi Fernando,

There are a number of problems with this unfortunately. When the Web Browser control has focus it doesn't forward any of the key or mouse events to Visual FoxPro. I don't think any of the solutions offered by the others here will actually work because what you have to do is capture the events inside of the browser and then forward them to the form.

In West Wind Html Help Builder I have a whole toolbar that's accessible from within the browser (for HTML editing mode). The way that I do it in there is that I implement the required HtmlDocument events and bind them to the Web Browser control. I can then capture the browser events in VFP and do what I need to. That said it's not a trivial task :-)

The interface you'll want to implement is IHtmlTextContainerEvents (you can drag and drop it out of the Object Browser for the shdocvw.dll)
DEFINE CLASS IHtmlTextContainerEvents AS RELATION OLEPUBLIC
   IMPLEMENTS HTMLTextContainerEvents IN "MSHTML.TLB"
...
ENDDEFINE
The events that might be interesting to you are:
PROCEDURE HTMLTextContainerEvents_oncontextmenu() AS LOGICAL
ENDPROC

PROCEDURE HTMLTextContainerEvents_onkeydown() AS VOID

 loEvent = this.oDoc.ParentWindow.Event
   
 lnKeyCode = loEvent.KeyCode
   
 *** F5 -  Ignore: It clears the page normally!
IF lnKeyCode = 116   
	   loEvent.keyCode = 0
   	   RETURN
ENDIF

...
                        
      *** Ctrl-P - Insert Picture
      CASE lnKeyCode = 80 AND loEvent.CtrlKey
         ToolClick("HTMLEdit","cmdImage")
         loEvent.returnValue = .f.
*** etc.
ENDPROC
There's a bit more to this - specifically I created a base IE event class that has references to the form and the document and a few other things that make it easier to communicate.

I've posted the complete (implementation specific) thing here:

http://codepaste.net/r2ch7k

Ping me if you need more information on how this works. I've done a ton of work with this in a the past...

+++ Rick ---

>Hi,
>
>I have a form that activates a browser in it. It works just fine.
>
>Add Object oleBrowserWin  as oleControl  with Top      =   0                , ;
>                                              Left     =   0                , ;
>                                              Height   = 380                , ;
>                                              Width    = 800                , ;
>                                              Name     = "oleBrowserWin"    , ;
>                                              OLEClass = "Shell.Explorer.2"
>
>
>The question is: I would like to put command buttons in the lower part of the form in order to execute some of the browser's functions, like when I press the right mouse button over the browser area, or ctrl+p to print etc. Think it would make life easier for some users.
>
>How could that be done?
>
>TIA
>
>Fernando
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform