Page 1 of 1

Sparkies old webgadget interface still works...

Posted: Sat Feb 17, 2007 12:43 am
by utopiomania
Code updated for 5.20+

Sparkies old trick still works with IE7, with and without unicode, if you write the html
to a unicode file (writeString(0, s, #PB_UNICODE) instead of loading it with an "about:.. string.

Just thought I should let you know in case you like to experiment with web-like interfaces like I do..:wink:

Code: Select all

;-initialize
;-
Enumeration
  #WIN1
  #WEB1
EndEnumeration

Global path.s = GetPathPart(ProgramFilename()) + "page.html"
Declare openMainWindow()
Declare.s page1(path.s)

;-program entry
openMainWindow()

;expose the IWebBrowser2 object
webObject.IWebBrowser2 = GetWindowLong_(GadgetID(1),#GWL_USERDATA)

;-program event handler
Repeat
  event = WaitWindowEvent()
  If isBusy ;loading
    webObject\get_ReadyState(@isReady)
    If isReady
      url.s = GetGadgetText(1)
      If FindString(url, "link", 1)
        ;link clicked, cancel navigation
        SetGadgetState(1,#PB_Web_Back)
        ;process the link event
        MessageRequester("Processing", url)
      EndIf
    EndIf
  EndIf
  webObject\get_busy(@isBusy)
Until event = #PB_Event_CloseWindow

;-program exit
;-
DeleteFile(path)
End

Procedure openMainWindow()
  flags = #PB_Window_ScreenCentered | #PB_Window_SystemMenu
  If OpenWindow(0, 0, 0, 600, 400, "", flags)
    WebGadget(1, 0, 0, 600, 400, page1(path))
  EndIf
EndProcedure

Procedure.s page1(path.s) 
  s.s = "<html><body><a href = 'link'>Click this link ÆØÅ</a></body></html>"
  ;write the string to a file
  If FileSize(path) = -1
    ;the file doesn't exist yet, create it
    CreateFile(0, path)
    WriteString(0, s, #PB_Unicode)
    CloseFile(0)
  EndIf
  ProcedureReturn "file://" + path
EndProcedure

Posted: Sat Feb 17, 2007 2:19 am
by Sparkie
You mean I wrote some code and it didn't break :shock: When and where did I do that :?: :? :?: :lol: