Webgadget und LINK
Verfasst: 23.05.2016 14:31
Hallo Leute,
wenn ich den Navigations Callback vom Webgadget einsetze, liefert er mir alle mögliche Links ins Stringgadget!
Nun habe ich mit LinkQuittierung = 0 auch nichts erreicht, weil dann die Google Link aus der Google Suche nicht mehr geht!
Help, jemand noch eine Idee?
Gruss ... Velindos
wenn ich den Navigations Callback vom Webgadget einsetze, liefert er mir alle mögliche Links ins Stringgadget!
Nun habe ich mit LinkQuittierung = 0 auch nichts erreicht, weil dann die Google Link aus der Google Suche nicht mehr geht!
Code: Alles auswählen
Procedure SuppressJavaScriptErrorMessages(WebGadget)
Protected MyWebGadget.IWebBrowser2
MyWebGadget = GetWindowLongPtr_(GadgetID(0), #GWL_USERDATA)
MyWebGadget\put_Silent(#True) ; Suppress JavaScript error messages.
EndProcedure
Procedure NavigationCallback(Gadget, Url$)
If Url$= "http://www.purebasic.com/news.php"
MessageRequester("", "No news today!")
ProcedureReturn #False
Else
If LinkQuittierung = 0
SetGadgetText(5,Url$)
LinkQuittierung = 1
EndIf
ProcedureReturn #True
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 600, 320, "WebGadget-Link", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com")
ButtonGadget(1,1,300,60,20,"Google")
ButtonGadget(2,60,300,60,20,"Purebasic")
ButtonGadget(3,120,300,60,20,"Welt")
ButtonGadget(4,180,300,60,20,"Standard")
StringGadget(5,240, 300,300,20,"Link")
ProgressBarGadget(6, 0, 295, WindowWidth(0)-2, 3, 0, 100)
SetGadgetAttribute(0, #PB_Web_NavigationCallback, @NavigationCallback())
; WebObject.IWebBrowser2 = GetWindowLongPtr_(GadgetID(0),#GWLP_USERDATA)
; If WebObject
; WebObject\put_Silent(#True)
; WebObject\put_Left(1)
; EndIf
SuppressJavaScriptErrorMessages(0)
Define Event,EventGadget,EventType
; ------------------
Repeat
Event = WaitWindowEvent()
EventGadget = EventGadget()
EventType = EventType()
Select Event
Case #WM_LBUTTONUP
LinkQuittierung = 0
Case #PB_Event_Gadget
If EventGadget = 0
If EventType = #PB_EventType_DownloadStart
Debug "DownloadStart"
HideGadget(6,0)
EndIf
If EventType = #PB_EventType_DownloadProgress
SetGadgetState(6,GetGadgetAttribute(0,#PB_Web_Progress))
EndIf
If EventType = #PB_EventType_PopupMenu
EndIf
If EventType = #PB_EventType_TitleChange
EndIf
If EventType = #PB_EventType_DownloadEnd
Debug "DownloadEnd"
HideGadget(6,1)
EndIf
EndIf
Select EventGadget
Case 0: SetGadgetText(5,GetGadgetText(0)) ; <============
Case 1 : SetGadgetText(0,"http://www.google.com")
Case 2 : SetGadgetText(0,"http://www.purebasic.com")
Case 3 : SetGadgetText(0,"http://www.welt.de/newsticker/")
Case 4 :SetGadgetText(0,"http://www.standard.at")
EndSelect
Case #WM_KEYFIRST
; Web Navigation über LinkFeld
If EventwParam() = #VK_RETURN
Debug "ENTER gedrückt"
If GetActiveGadget() = 5
Debug "ENTER Taste hat FOCUS"
SetGadgetText(0,GetGadgetText(5))
EndIf
EndIf
EndSelect
; ESC Taste
; If GetAsyncKeyState_(#VK_ESCAPE): End: EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Gruss ... Velindos