WebGadget()
Syntax
Result = WebGadget(#Gadget, x, y, Width, Height, URL$ [, Flags])Description
Creates a Web gadget in the current GadgetList. If #PB_Any is used as '#Gadget' parameter, the new gadget number will be returned as 'Result'. #Gadget will be the number returned by EventGadget() function.
'Flags' is an optional parameter and can be composed of one of the following constants:#PB_Web_Mozilla : Uses the Mozilla ActiveX instead of the IE one (Windows only).The following functions can be used to act on a WebGadget:
- SetGadgetText(): Change the current URL.
- GetGadgetText(): Get the current URL.
- SetGadgetState(): Perform an action on the gadget. The following constants are valid:#PB_Web_Back : One step back in the navigation history. #PB_Web_Forward: One step forward in the navigation history. #PB_Web_Stop : Stop loading the current page. #PB_Web_Refresh: Refresh the current page.Note: The following features do not work with the Mozilla ActiveX on windows (#PB_Web_Mozilla flag)
- SetGadgetItemText(): With #PB_Web_HtmlCode as 'Item' html code can be streamed into the Gadget.
- GetGadgetItemText(): The following constants can be used to get information:#PB_Web_HtmlCode : Get the html code from the gadget. #PB_Web_PageTitle : Get the current title for the displayed page. #PB_Web_StatusMessage: Get the current statusbar message. #PB_Web_SelectedText : Get the currently selected text inside the gadget.- SetGadgetAttribute(): Set the following attributes:#PB_Web_ScrollX : Set the horizontal scrolling position. #PB_Web_ScrollY´ : Set the vertical scrolling position. #PB_Web_BlockPopups : Block popup windows. #PB_EventType_PopupWindow is fired if this setting is enabled. #PB_Web_BlockPopupMenu: Block standard the popup menu. #PB_EventType_PopupMenu is fired if this setting is enabled. #PB_Web_NavigationCallback: Set a callback for monitoring (and disabling) navigation.The Navigation callback must have the following format:Procedure NavigationCallback(Gadget, Url$) ; ; Return #True to allow this navigation or #False to deny it. ; ProcedureReturn #True EndProcedure- GetGadgetAttribute(): Get the following attributes:#PB_Web_ScrollX : Get the horizontal scrolling position. #PB_Web_ScrollY´ : Get the vertical scrolling position. #PB_Web_Busy : Returns nonzero if the gadget is busy loading a page. #PB_Web_Progress : Returns the current (sometimes estimated) progress after a #PB_EventType_DownloadProgress event. #PB_Web_ProgressMax : Returns the current (sometimes estimated) maximum progress after a #PB_EventType_DownloadProgress event. #PB_Web_BlockPopups : Get the current popupwindow blocking setting. #PB_Web_BlockPopupMenu: Get the current popupmenu blocking setting. #PB_Web_NavigationCallback: Get the current navigation callback (if any).Notes: Popup windows and popup menues are not supported on the WebGadget on Linux. However, the #PB_Web_BlockPopups can still be set to enable the #PB_EventType_PopupWindow event. The same also applies for #PB_Web_BlockPopupMenu.
The following types of events can happen for this gadget:#PB_EventType_TitleChange : The page title changed. #PB_EventType_StatusChange : The status message changed. #PB_EventType_DownloadStart : A page download started. #PB_EventType_DownloadProgress: Progress info is available with GetGadgetAttribute(). #PB_EventType_DownloadEnd : A page download ended (finished or aborted). #PB_EventType_PopupWindow : A popup window was blocked. #PB_EventType_PopupMenu : The popup menu was blocked (display a custom menu here).Note: on Microsoft Windows the WebGadget uses the Internet Explorer 4.0+ ActiveX object. This means that IE has to be installed (already present on Win98/Me and Win2000/XP). The ATL.dll, present in the PureBasic\Compilers\ directory is also needed, and must be in the same directory as the executable. As an alternative, the Mozilla ActiveX can be used instead (http://www.iol.ie/~locka/mozilla/mozilla.htm) if the #PB_Web_Mozilla flag is specified (the Mozilla ActiveX needs to be installed separately, it isn't bundled with FireFox or Mozilla).Example:
If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com") ; Note: if you want to use a local file, change last parameter to "file://" + path + filename Repeat Until WaitWindowEvent() = #PB_Event_CloseWindow EndIf
Example 2: (with navigation callback); This example does display the PureBasic.com website. Inside the callback procedure ; the navigation to the 'News' site will be avoided (#False returned), but allowed ; for all other sites (#True returned). Procedure NavigationCallback(Gadget, Url$) If Url$= "http://www.purebasic.com/news.php" MessageRequester("", "No news today!") ProcedureReturn #False Else ProcedureReturn #True EndIf EndProcedure If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com") SetGadgetAttribute(0, #PB_Web_NavigationCallback, @NavigationCallback()) Repeat Until WaitWindowEvent() = #PB_Event_CloseWindow EndIf
Supported OS
All