Page 2 of 2

Posted: Tue May 04, 2004 7:37 pm
by Sparkie
Gald to help Aeroschmelz :)

Code: Select all

SetGadgetText(0,"javascript:void(window.scrollTo(50, 150), document.body.style.zoom='2.0')")
If the code above appears with a line break, just paste it as one continuous line of code in PB.

Posted: Wed May 05, 2004 4:22 am
by fweil
...,

Not really a valuable trick'n tips post, so I prefer to put it there for further comments !

Code: Select all

#Window_Main = 0
#Gadget_Web = 0

Dim URL.s(10)
QC.s = Chr(34)

  URL(1) = "http://www.purebasic.com"
  URL(2) = "javascript:void(document.body.style.zoom='3.0')"
  URL(3) = "javascript:window.scrollTo(50, 150)"
  URL(4) = "javascript:document.write('<BODY BGCOLOR=" + QC + "#000000" + QC + " TEXT=" + QC + "#FFFF00" + QC + "><H1><U>Hello World<BR>Width is <SCRIPT language=" + QC + "javascript" + QC + ">document.write(screen.availWidth)</SCRIPT><BR>Height is <SCRIPT language=" + QC + "javascript" + QC + ">document.write(screen.availheight)</SCRIPT></U></H1></BODY>')"
  URL(5) = "about:blank"
  URL(6) = "javascript:document.write('<BODY>Up to you to play more with this ...</BODY>')"

  URLIndex = 0
  URLMax = 6
  Quit = #FALSE
  WindowXSize = 640
  WindowYSize = 480
  If OpenWindow(#Window_Main, 0, 0, WindowXSize, WindowYSize, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "WebGadget")
      AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Escape, #PB_Shortcut_Escape)
      AddKeyboardShortcut(#Window_Main, #PB_Shortcut_F2, #PB_Shortcut_F2)
      AddKeyboardShortcut(#Window_Main, #PB_Shortcut_F5, #PB_Shortcut_F5)
      AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Back, #PB_Shortcut_Back)
      AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Left, #PB_Shortcut_Left)
      AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Right, #PB_Shortcut_Right)
      If CreateGadgetList(WindowID(0))
          WebGadget(#Gadget_Web, 10, 10, WindowXSize - 20, WindowYSize - 20, "about:blank")
      EndIf
      Repeat
        Select WaitWindowEvent()
          Case #PB_Event_CloseWindow
            Quit = #TRUE
          Case #PB_Event_Menu
            Select EventMenuID()
              Case #PB_Shortcut_F2
                URLIndex + 1
                If URLIndex > URLMax
                    URLIndex = 1
                EndIf
                SetGadgetText(#Gadget_Web, URL(URLIndex))
                SetWindowText_(WindowID(), URL(URLIndex))
              Case #PB_Shortcut_F5
                SetGadgetState(#Gadget_Web, #PB_Web_Refresh)
              Case #PB_Shortcut_Back
                SetGadgetState(#Gadget_Web, #PB_Web_Back)
              Case #PB_Shortcut_Left
                SetGadgetState(#Gadget_Web, #PB_Web_Back)
              Case #PB_Shortcut_Right
                SetGadgetState(#Gadget_Web, #PB_Web_Forward)
              Case #PB_Shortcut_Escape
                Quit = #TRUE
            EndSelect
          Case #PB_Event_Gadget
        EndSelect
      Until Quit
  EndIf
End
Play with F2 on the keyboard and you will have some interestng effects using the WebGadget tool ... but ... it crashes sometimes and if you add more links in the list, it also may render bad results.

It seems, but I am not sure of the reason why, that the IWebBrowser2 stuff is unstable from Purebasic, or maybe my computer has some lacks.

Up to readers to answer / comment this before an eventual bug report or just any better commented information.

Rgrds

Posted: Fri May 07, 2004 10:48 pm
by Aeroschmelz
If i want to change the loaded page and reset the javascript settings like zoom i get an error ? Must i wait until the page is loaded ?

I use this in case of a key command or button event:

Code: Select all

Procedure NextPage()
;Nächste Seite Laden
          Eintrag.l=NextElement(URL())
          If Eintrag.l<>0
               SetGadgetText(1,URL())
          Else
               FirstElement(URL())
               SetGadgetText(1,URL())
          EndIf
          Delay(500)
        
EndProcedure
in case of key or button call procedure

Code: Select all

nextPage()
SetGadgetText(1,"javascript:void(document.body.style.zoom='3.0')")
It just zooms, but does not change the page....

Posted: Fri May 14, 2004 5:29 pm
by fweil
...,

Here I try to give you a working result, but I am not sure it is necessary to take that way because it seems redundant to copy first parameters in a string a catch then these in another.

Anyway, the following sample code works whatever you give a string argument when running the program, and identifies each /ini= field taking the name after = as an ini file field to add to ini.s string.

Code: Select all

  ;- Parameter auslesen und in String übergeben
  Parameter.s
  schritt.s
  
  Repeat
    schritt = ProgramParameter()
    Parameter = Parameter + " " + schritt
  Until schritt = ""

  Parameter = Trim(Parameter)

  ;Überprüfen ob ein ini File als Parameter angegeben worden ist

  ini.s = ""
  ParameterName.s
  
  If Parameter <> ""
      FieldNumber = 1
      While StringField(Parameter, FieldNumber, " ")
        FieldNumber + 1
      Wend
      FieldNumber - 1
      For i = 1 To FieldNumber
        ParameterName.s = StringField(Parameter, i, " ")
        If Left(ParameterName, 5) = "/ini="
            ini = ini + " " + Mid(ParameterName, 6, Len(ParameterName) - 6 + 1)
        EndIf
      Next
      ini = Trim(ini)
    Else
      ini = "default.ini"
  EndIf
  
  CallDebugger
End

Posted: Sat May 15, 2004 8:09 am
by Aeroschmelz
Really thanks for your help, it works now ! I just dare to ask, but i have another problem ;-) Sorry.... If i have a procedure which is loading a new page when you press the key i would like to change the zoom to the defined setting. The procedure works only if i load a html page, if it is a flash file it fails and will never change the page for executions :

Code: Select all

Procedure NextPage()
;Nächste Seite Laden
          Eintrag.l=NextElement(URL())
          If Eintrag.l<>0
               SetGadgetText(1,URL())
          Else
               FirstElement(URL())
               SetGadgetText(1,URL())
          EndIf
          WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(1), #GWL_USERDATA)
          Repeat
              WindowEvent() 
              WebObject\get_ReadyState(@webState)
          Until webState = 4
          SetGadgetText(1,"javascript:void(document.body.style.zoom='"+Str(ZoomLevel)+"')")
 
 EndProcedure
Must i reset some variable or what ?

Posted: Sat May 15, 2004 8:25 am
by Aeroschmelz
Oh, i think i solved this:

Code: Select all

Procedure NextPage()
;Nächste Seite Laden
          Eintrag.l=NextElement(URL())
          If Eintrag.l<>0
               SetGadgetText(1,URL())
          Else
               FirstElement(URL())
               SetGadgetText(1,URL())
          EndIf
          webState=0
          WebObject.IWebBrowser2=0
          WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(1), #GWL_USERDATA)
          Repeat
              WindowEvent() 
              WebObject\get_ReadyState(@webState)
          Until webState = 4
          SetGadgetText(1,"javascript:void(document.body.style.zoom='"+Str(ZoomLevel)+"')")