WebGadget: Directly insert code and catch link clicks.

Share your advanced PureBasic knowledge/code with the community.
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post by Nik »

Does anyone in this thread know an answer for viewtopic.php?t=17700

Sorry for double posting but I thnik it is important enough for this :oops:
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

Post by garretthylltun »

I'm going to assume that this is MS Windows only since it's using DCOM,
right?

-Garrett
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
· Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
· http://www.freewarehome.com/ <-- Freeware listings since 1996
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

yes.
quidquid Latine dictum sit altum videtur
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

is there a way to make the webgadget scroll?
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

quidquid Latine dictum sit altum videtur
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

yeah, but i dont understand german... can u translate it into english?
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

Can these interfaces (IHTML_xxxx) be updated natively in PB4.0 ?
As we can see in the WebGadgetExtras.pb there's a lot of thing to update...
Not urgent but i would be nice. :wink:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
real
User
User
Posts: 49
Joined: Fri Oct 08, 2004 5:17 am

Post by real »

Is there anybody out there who converted the WebGadgetExtras.pb to PB 4???

I used it under v3.94 and wanted to take advantage of strings longer than 64KB in v4.0, but I can't compile the WebGadgetExtras.pb anymore. :cry:
User avatar
oryaaaaa
Addict
Addict
Posts: 825
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Post by oryaaaaa »

How can get all source code (include HEAD)

Code: Select all

 IHTMLDocument2 *HTMLDocument = NULL;
  WCHAR           wszShortcutFile[512];
  LPDISPATCH lpdisp;

  lpdisp = m_web0.GetDocument();
  HTMLDocument = (IHTMLDocument2 *)lpdisp;
  HRESULT hr4 = HTMLDocument->QueryInterface(IID_IPersistFile,(void **)&PersistFile);
  MultiByteToWideChar(CP_ACP, 0, "C:\\test.html", -1,
                       wszShortcutFile, 512);
  PersistFile->Save(wszShortcutFile,TRUE);
All Soucecode to File save with C
How do it become it if it translates into PureBasic?
User avatar
oryaaaaa
Addict
Addict
Posts: 825
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Post by oryaaaaa »

Code: Select all

DataSection
IID_IPersistFile:
  ; 0000010b-0000-0000-C000-000000000046
Data.l $0000010B
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection
  
Procedure WebGadget_Read(Gadget, tempfile.s)
    Shared WebGadget_Document.IHTMLDocument2_FIXED
    result = 0
    
    If GetGadgetText(Gadget) = ""
      SetGadgetText(Gadget, "about:blank")
    EndIf
    memoryurl.s=GetGadgetText(Gadget)
    
    WebGadget_Document = 0
    Browser.IWebBrowser2 = GetWindowLong_(GadgetID(Gadget), #GWL_USERDATA)
    If Browser
      If Browser\get_document(@DocumentDispatch.IDispatch) = #S_OK
        If DocumentDispatch\QueryInterface(?IID_IPersistFile, @PersistFile.IPersistFile) = #S_OK      
          mem.s = Space(1000)
          MultiByteToWideChar_(#CP_ACP, 0, tempfile, -1, mem, 1000)
          hres = PersistFile\SAVE(@mem,#True)
          result = 1
        EndIf
        DocumentDispatch\Release()
      EndIf  
      Browser\Release()
    EndIf
    SetGadgetText(Gadget, memoryurl)
    
  ProcedureReturn result
EndProcedure  
Dummy
Enthusiast
Enthusiast
Posts: 162
Joined: Wed Jun 09, 2004 11:10 am
Location: Germany
Contact:

Post by Dummy »

In PB 4 Beta 9 the parameter Link$ of the callbackfunction is always empty. Pls fix.
uweb
User
User
Posts: 98
Joined: Wed Mar 15, 2006 9:40 am
Location: Germany

Post by uweb »

Does anybody know how to handel JavaScript-Links ?

This is my try :

Code: Select all

XIncludeFile "WebGadgetExtras.pb"

#WebGadget = 0

Procedure LinkCallback(Gadget, Link$, Text$, ID$, Class$)

  Debug "Gadget: "+Str(Gadget)

  Debug "Link: "+Link$
  Debug "Text: "+Text$

  Debug ""

  ProcedureReturn 0 ; prevent link from executing
EndProcedure

If OpenWindow(0, 0, 0, 800, 600, #PB_Window_SystemMenu|#PB_Window_ScreenCentered, "WebGadget example")
  If CreateGadgetList(WindowID())
   
    WebGadget(#WebGadget, 0, 0, 800, 600, "")   
           
    If WebGadget_Open(#WebGadget, 0)
   
      WebGadget_Write("<html>")
      WebGadget_Write("<head>")
      WebGadget_Write("<title>Text des Titels</title>")
      WebGadget_Write("<script type='text/javascript'>")
      WebGadget_Write("function Go() {")
      WebGadget_Write("  var Vorname = document.Formular.Vorname.value;")

      WebGadget_Write("  var test1 = '<a href=execute&nbsp;'+Vorname+' id=a123>x123</a>';")
      WebGadget_Write("  var test2 = 'execute '+Vorname;")

      WebGadget_Write("  this.a123.outerHTML = test1;")
      WebGadget_Write("  alert(this.a123.outerHTML);")

;      WebGadget_Write("  this.a123.click();")
;      WebGadget_Write("  window.location.href = test2;")

      WebGadget_Write("}")
      WebGadget_Write("</script>")
      WebGadget_Write("</head>")
      WebGadget_Write("<body>")
      WebGadget_Write("<a href='12' id='a123'>123</a><br>")
      WebGadget_Write("<a href='456'>456</a><br><br>")
      WebGadget_Write("<h1>Das hier k&ouml;nnen Sie absenden!</h1>")
      WebGadget_Write("<form name='Formular' action='javascript:Go()'>")
      WebGadget_Write("<table border='0' cellpadding='5' cellspacing='0' bgcolor='#E0E0E0'>")
      WebGadget_Write(" <tr>")
      WebGadget_Write("  <td align='right'>Vorname:</td>")
      WebGadget_Write("  <td><input name='Vorname' type='text' size='30' maxlength='30'></td>")
      WebGadget_Write(" </tr><tr>")
      WebGadget_Write("  <td align='right'>Zuname:</td>")
      WebGadget_Write("  <td><input name='Zuname' type='text' size='30' maxlength='40'></td>")
      WebGadget_Write(" </tr><tr>")
      WebGadget_Write("  <td align='right' valign='top'>Kommentar:</td>")
      WebGadget_Write("  <td><textarea name='Text' rows='10' cols='50'></textarea></td>")
      WebGadget_Write(" </tr><tr>")
      WebGadget_Write("  <td align='right'>Formular:</td>")
      WebGadget_Write("  <td>")
      WebGadget_Write("   <input type='submit' value=' Absenden '>")
      WebGadget_Write("   <input type='reset' value=' Abbrechen'>")
      WebGadget_Write("  </td>")
      WebGadget_Write(" </tr>")
      WebGadget_Write("</table>")
      WebGadget_Write("</form>")
      WebGadget_Write("</body>")
      WebGadget_Write("</html>")
   
      WebGadget_Close()
    EndIf
   
    WebGadget_CatchLinks(#WebGadget, @LinkCallback())           
   
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow   
   
  EndIf
EndIf
edit :

The 4. way

Code: Select all

WebGadget_Write("  this.a123.innerHTML = test2;")
do not work also.

What i wont is to interact whith Javascript. A Form is only one Case for this.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

See my post on interacting with JavaScript here:
http://www.purebasic.fr/english/viewtop ... 68&start=0

I plan to put all this code together into a library but right now i just do not have the time.
quidquid Latine dictum sit altum videtur
uweb
User
User
Posts: 98
Joined: Wed Mar 15, 2006 9:40 am
Location: Germany

Post by uweb »

Great !

My english is not the best, so i am not so often here.
But now i see : I have to change.

I dont know why but many german send there perls only (instead of also) in english.
Well, its there decision.

I am thankful even so !
zikitrake
Addict
Addict
Posts: 868
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Post by zikitrake »

real wrote:Is there anybody out there who converted the WebGadgetExtras.pb to PB 4???

I used it under v3.94 and wanted to take advantage of strings longer than 64KB in v4.0, but I can't compile the WebGadgetExtras.pb anymore. :cry:
+1 :D
PB 6.21 beta, PureVision User
Post Reply