Page 1 sur 1

[Résolu]Créer un lien dans un WebGadget en édition

Publié : ven. 23/mai/2008 14:30
par Stefou
Salut à tous

Toujours dans mes web gadget, j'ai besoin de créer un lien dans une page, mais comment faire ?

Si vous savez n'hesitez pas à mettre fin à mes recherches, je galère :cry:


Bonne journée à tous


Voici un code pour insérer le truc qui manque :

Code : Tout sélectionner

Enumeration 1
  #olecmdid_open         
  #olecmdid_new       
  #olecmdid_save         
  #olecmdid_saveas           
  #olecmdid_savecopyas   
  #olecmdid_print       
  #olecmdid_printpreview       
  #olecmdid_pagesetup       
  #olecmdid_spell           
  #olecmdid_properties
  #olecmdid_cut         
  #olecmdid_copy       
  #olecmdid_paste           
  #olecmdid_pastespecial   
  #olecmdid_undo           
  #olecmdid_redo         
  #olecmdid_selectall       
  #olecmdid_clearselection
  #olecmdid_zoom           
  #olecmdid_getzoomrange     
  #olecmdid_updatecommands
  #olecmdid_refresh           
  #olecmdid_stop             
  #olecmdid_hidetoolbars     
  #olecmdid_setprogressmax   
  #olecmdid_setprogresspos
  #olecmdid_setprogresstext   
  #olecmdid_settitle         
  #olecmdid_setdownloadstate
  #olecmdid_stopdownload   
  #olecmdid_ontoolbaractivated
  #olecmdid_find
  #olecmdid_delete
  #olecmdid_httpequiv
  #olecmdid_httpequiv_done
  #olecmdid_enable_interaction
  #olecmdid_onunload
  #olecmdid_propertybag2
  #olecmdid_prerefresh
  #olecmdid_showscripterror
  #olecmdid_showmessage
  #olecmdid_showfind
  #olecmdid_showpagesetup
  #olecmdid_showprint
  #olecmdid_clos
  #olecmdid_allowuilesssaveas
  #olecmdid_dontdownloadcss
  #olecmdid_updatepagestatus
  #olecmdid_print2
  #olecmdid_printpreview2
  #olecmdid_setprinttemplate
  #olecmdid_getprinttemplate
  #olecmdid_pageactionblocked      = 55; no 53 or 54
  #olecmdid_pageactionuiquery     
  #olecmdid_focusviewcontrols     
  #olecmdid_focusviewcontrolsquery
  #olecmdid_showpageactionmenu   
EndEnumeration

Enumeration 0
  #olecmdexecopt_dodefault     
  #olecmdexecopt_promptuser       
  #olecmdexecopt_dontpromptuser   
  #olecmdexecopt_showhelp       
EndEnumeration


Enumeration
  #idm_alignbottom             
  #idm_alignhorizontalcenters
  #idm_alignleft               
  #idm_alignright             
  #idm_aligntogrid             
  #idm_aligntop               
  #idm_alignverticalcenters   
  #idm_arrangebottom           
  #idm_arrangeright           
  #idm_bringforward           
  #idm_bringtofront           
  #idm_centerhorizontally     
  #idm_centervertically       
  #idm_code                   
  #idm_delete     =17             
  #idm_fontname               
  #idm_fontsize               
  #idm_group                   
  #idm_horizspaceconcatenate   
  #idm_horizspacedecrease     
  #idm_horizspaceincrease     
  #idm_horizspacemakeequal     
  #idm_insertobject           
  #idm_multilevelredo     =30     
  #idm_sendbackward        =32     
  #idm_sendtoback             
  #idm_showtable               
  #idm_sizetocontrol           
  #idm_sizetocontrolheight     
  #idm_sizetocontrolwidth     
  #idm_sizetofit               
  #idm_sizetogrid             
  #idm_snaptogrid             
  #idm_taborder               
  #idm_toolbox                 
  #idm_multilevelundo      =44   
  #idm_ungroup               
  #idm_vertspaceconcatenate   
  #idm_vertspacedecrease       
  #idm_vertspaceincrease       
  #idm_vertspacemakeequal     
  #idm_justifyfull             
  #idm_backcolor               
  #idm_bold                   
  #idm_bordercolor             
  #idm_flat                   
  #idm_forecolor               
  #idm_italic                 
  #idm_justifycenter           
  #idm_justifygeneral         
  #idm_justifyleft             
  #idm_justifyright           
  #idm_raised                 
  #idm_sunken                 
  #idm_underline               
  #idm_chiseled               
  #idm_etched                 
  #idm_shadowed               
  #idm_find                   
  #idm_showgrid               = 69
EndEnumeration
#IDM_2D_POSITION = 2394

;#msocmdexecopt_dodefault = 0
Debug "#IDM_BOLD  = "+Str(#idm_bold )

If OpenWindow(0, 0, 0, 640, 480, "WebGadget Edit", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
  If CreateGadgetList(WindowID(0))
    
    WebGadget(0, 5, 5, 630, 340, "www.google.com")
    ButtonGadget(1, 5, 350, 100, 25, "Bold")
    ButtonGadget(2, 110, 350, 100, 25, "Test")
    ButtonGadget(3, 210, 350, 100, 25, "Delete")
    
    ; get webgadgets IWebBrowser2 interface:
    Browser.IWebBrowser2 = GetWindowLong_(GadgetID(0), #GWL_USERDATA)   
    
    ; wait For page To be loaded..
    Repeat
      While WindowEvent(): Wend
      Delay(1)
      Browser\get_Busy(@IsBusy.l)
    Until IsBusy = 0
    
    ; get the document interface
    If Browser\get_Document(@DocumentDispatch.IDispatch) = #S_OK
      
      ; query For IHTMLDocument3:
      If DocumentDispatch\QueryInterface(?IID_IHTMLDocument2, @Document.IHTMLDocument2) = #S_OK
        
        ; here you have a IHTMLDocument2 pointer,  can work with it...
        Document\put_designMode("On") ; Turns on Edit Mode
        ;Document\put_designMode(Ansi2Uni("On")) ; Turns on Edit Mode ;
        CmdTarget.IOleCommandTarget
        If DocumentDispatch\QueryInterface(?IID_IOleCommandTarget, @CmdTarget.IOleCommandTarget) = #S_OK
          
          CmdTarget\Exec(?CGID_MSHTML, #IDM_2D_POSITION, #OLECMDEXECOPT_DONTPROMPTUSER, @var, NULL) ;Lets you drag  drop items
          ; CmdTarget\Release()
        EndIf
        
        Document\Release()
      EndIf
      
      DocumentDispatch\Release()   
    EndIf
    
    vb.l
    
    Repeat
      EventID = WaitWindowEvent()
      
      If EventID = #PB_Event_Gadget ;checks For the events
        Select EventGadget() ;Checks For Gadget Events
          Case 0
            
            Debug "Web Gadget "
            
          Case 1
            Debug "bold button "
            ;Document\execCommand(Ansi2Uni("Delete"), #False, #Null, @vOut)
            CmdTarget\Exec(?CGID_MSHTML, #idm_bold,#olecmdexecopt_dontpromptuser  , 0, 0)
            ; Document\execCommand(Ansi2Uni("Bold"), #False, #Null, @vOut)     
            
          Case 2
            Debug "test button "
            Document\queryCommandState("Bold", @vb)
            ;Document\queryCommandState(Ansi2Uni("Bold"), @vb)
            MessageRequester("Bold State", Str(vb))
            
          Case 3
            Debug "delete button "
            CmdTarget\Exec(?CGID_MSHTML, #idm_delete, #olecmdexecopt_dontpromptuser, 0, 0)
            
        EndSelect
      EndIf
      
      If GetForegroundWindow_() = WindowID(0)
        If GetAsyncKeyState_(#VK_DELETE)
          
          CmdTarget\Exec(?CGID_MSHTML, #idm_delete, #olecmdexecopt_dontpromptuser, 0, 0)
        EndIf
      EndIf
      
    Until EventID = #PB_Event_CloseWindow
    If CmdTarget
      CmdTarget\Release()
    EndIf
  EndIf
EndIf

End


DataSection

IID_IHTMLDocument2:  ; {332c4425-26cb-11d0-b483-00c04fd90119}
Data.l $332C4425
Data.w $26CB, $11D0
Data.b $B4, $83, $00, $C0, $4F, $D9, $01, $19

IID_IOleCommandTarget:  ; {b722bccb-4e68-101b-a2bc-00aa00404770}
Data.l $B722BCCB
Data.w $4E68, $101B
Data.b $A2, $BC, $00, $AA, $00, $40, $47, $70
 
CGID_MSHTML: ; { 0xDE4BA900, 0x59CA, 0x11CF, { 0x95, 0x92, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } }
Data.l $DE4BA900
Data.w $59CA, $11CF
Data.b $95, $92, $44, $45, $53, $54, $00, $00
EndDataSection 

Publié : ven. 23/mai/2008 14:36
par poshu
Hum... Je ne peux pas t'aider (désolé T_T) mais je suis très intéressé par ce code. Je ne pensais pas que c'était possible.

Publié : mar. 27/mai/2008 9:21
par Stefou
Et voilà la réponse :

Code : Tout sélectionner

            Success.VARIANT
            Command.VARIANT
            Command\vt = #VT_BSTR
            Command\bstrVal = Ansi2Uni("http://www.assistance-informatique-77.fr")
            
            Document\execCommand("CreateLink", 0, @Command , @Success)  

Publié : mar. 27/mai/2008 17:07
par nico
Il me semble que les BSTR doivent impérativement être créer avec la commande SysAllocateString_(...)

Publié : mer. 28/mai/2008 6:38
par Stefou
Merci de ton intervention nico ..... :D mais pourrais-tu parler français ? S'il te plaît :roll:

a pluche