Code: Select all
;
; by Pille, 14.07.2003
; Adapted from Jost Schwider's VB OpenUrl
;
Enumeration
#Window
#Editor
#Url
#cmdOpenUrl
EndEnumeration
defaultUrl.s="http://www.google.com/index.html"
Procedure.s OpenURL(URL.s, OpenType.b)
;?OpenType [1 = IOTPreconfig | 2 = IOTDirect | 3 = IOTProxy]
;content.s = OpenURL("http://www.google.de/index.html", 1)
isLoop.b=1
INET_RELOAD.l=$80000000
hInet.l=0: hURL.l=0: Bytes.l=0
Buffer.s=Space(2048)
res.s=""
hInet = InternetOpen_("PB@INET", OpenType, #Null, #Null, 0)
hURL = InternetOpenUrl_(hInet, URL, #Null, 0, INET_RELOAD, 0)
Repeat
InternetReadFile_(hURL, @Buffer, Len(Buffer), @Bytes)
If Bytes = 0
isLoop=0
Else
res = res + Left(Buffer, Bytes)
EndIf
Until isLoop=0
InternetCloseHandle_(hURL)
InternetCloseHandle_(hInet)
ProcedureReturn res
EndProcedure
If OpenWindow(#Window, 0, 0, 500, 500, "OpenUrl", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
EditorGadget(#Url, 5, 5, 410, 20)
EditorGadget(#Editor, 5, 30, 490, 465)
ButtonGadget(#cmdOpenUrl, 420, 5, 75, 20, "Get Source!")
SetGadgetText(#Url, defaultUrl)
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_Gadget
Select EventGadget()
Case #cmdOpenUrl
SetGadgetText(#Editor, OpenUrl(GetGadgetText(#Url),1))
EndSelect
EndIf
Until EventID = #PB_Event_CloseWindow
EndIf