Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Command buttons in a form with a browser in it
Message
De
20/10/2012 17:17:28
 
 
À
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:
01555400
Vues:
57
Update

So far got some of what I'm looking for.

To print just added this line to a command button:
ThisForm.oleBrowserWin.ExecWB(6, 1)
The other case (the right mouse button click), still pending, but found the code below written by
Craig Boyd (http://www.levelextreme.com/SupportArea.aspx?Process=17&ID=66598) at http://www.tek-tips.com/viewthread.cfm?qid=1207892, but still couldn't find the right way to call the mouse_event in Win32API.

It is explained here http://msdn.microsoft.com/en-us/library/windows/desktop/ms646260%28v=vs.85%29.aspx, but it goes beyond my knowledge to correctly interpret it.

Any tips?

My last try was this code:
#DEFINE MOUSEEVENTF_RIGHTDOWN 0x0008 
        
DECLARE INTEGER mouse_event IN Win32API ;
INTEGER, INTEGER, INTEGER, INTEGER, INTEGER

DOEVENTS && make sure everything else is done 
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
DOEVENTS 
        
CLEAR DLLS "mouse_event"
Inserted the above code in place of the keybd_event sequence (commented below), but all I got was VFP freezing (below is the Craig Boyd's code).
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form

    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"
    WindowState = 2

    ADD OBJECT olecontrol1 AS olecontrol WITH ;
        Top = 0, ;
        Left = 0, ;
        Height = 204, ;
        Width = 375, ;
        Anchor = 15, ;
        Name = "Olecontrol1", ;
        OleClass = "Shell.Explorer.2"

    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 215, ;
        Left = 276, ;
        Height = 27, ;
        Width = 84, ;
        Anchor = 12, ;
        Caption = "Find", ;
        Name = "Command1"

    PROCEDURE olecontrol1.Init
        this.navigate("http://www.sweetpotatosoftware.com/spsblog")
    ENDPROC

    PROCEDURE command1.Click
        LOCAL loDoc
        loDoc = THISFORM.Olecontrol1.object.Document
        loDoc.focus() && document must have focus

        *!* Use API calls to simulate CTRL + F

* ===== This starts where I replaced the code ===========================

*       #DEFINE KEYEVENTF_KEYUP 0x02
*       #DEFINE VK_CONTROL 0x11
*       
*       DECLARE INTEGER keybd_event IN Win32API ;
*             INTEGER, INTEGER, INTEGER, INTEGER
*
*       DOEVENTS && make sure everything else is done 
*       keybd_event(VK_CONTROL, 0, 0, 0)
*       keybd_event(0x46, 0, 0, 0) && 0x46 is 'f'
*       keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
*       DOEVENTS && make sure it sends the keys right now 
*       
*       CLEAR DLLS "keybd_event"
 
* ===== This ends where I replaced the code =============================

        *!* Keyboard doesn't work here
        *!*    KEYBOARD '{CTRL+F}'

        *!* We could have used Windows Script instead though
        *!*    WshShell = CreateObject("WScript.Shell")
        *!*    WshShell.SendKeys("^f")

        *!* OTHER DEV NOTES OF INTEREST *!*

        *!* ExecWB throws the following exception:
        *!*    'OLE Error code Trying to revoke a drop target that has not been registered'
        *!*    THISFORM.Olecontrol1.ExecWB(42,0)

        *!* For some reason Microsoft didn't implement
        *!* the find dialog for execCommand
        *!* List of supported command identifiers can be found at:
        *!*    http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/commandids.asp
        *!*    loDoc.execCommand("Find") && this doesn't work, but others will
    ENDPROC
    
ENDDEFINE
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform