Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Purebasic Webbrowser html5 compatible

Featured Replies

Posted

Hi at all.

i wanna share my quick Purebasic webbrowser code. someone may find it useful. Source is not finished, you can add all your needs and or fix some bugs.

 

179kb exe :D 0-2% CPU :D

;
; just a simple purebasic html5 web browser by inc.aka udg
; 
; including home button, forward, back, reload/ refresh, close
; address url field, page load progress bar
;
; PB 5.30 Windows 7
;
;{ Keyboard Shortcut Enumerations
Enumeration 1
  #OLECMDID_OPEN
  #OLECMDID_NEW
  #OLECMDID_SAVE
  #OLECMDID_SAVEAS
  #OLECMDID_SAVECOPYAS
  #OLECMDID_PRINT
  #OLECMDID_PRINTPREVIEW
  #OLECMDID_PAGESETUP
  #OLECMDID_SPELL
  #OLECMDID_PROPERTIES
  #OLECMDID_CUT
  #OLECMDID_COPY
  #OLECMDID_PASTE
  #OLECMDID_PASTESPECIAL
  #OLECMDID_UNDO
  #OLECMDID_REDO
  #OLECMDID_SELECTALL
  #OLECMDID_CLEARSELECTION
  #OLECMDID_ZOOM
  #OLECMDID_GETZOOMRANGE
  #OLECMDID_UPDATECOMMANDS
  #OLECMDID_REFRESH
  #OLECMDID_STOP
  #OLECMDID_HIDETOOLBARS
  #OLECMDID_SETPROGRESSMAX
  #OLECMDID_SETPROGRESSPOS
  #OLECMDID_SETPROGRESSTXT
  #OLECMDID_SETTITLE
  #OLECMDID_SETDOWNLOADSTATE
  #OLECMDID_STOPDOWNLOAD
  
EndEnumeration

Enumeration 0
  #OLECMDEXECOPT_DODEFAULT
  #OLECMDEXECOPT_PROMPTUSER
  #OLECMDEXECOPT_DONTPROMPTUSER
  #OLECMDEXECOPT_SHOWHELP
  EndEnumeration
;}
Enumeration
    #MainForm
    ;WebGadget
      #WebGadget
      #Btn_CloseWebGadget
      #Btn_min_to_Tray
      #Btn_Fnt_min_to_Tray
      #Font_Btn_CloseWebGadget
      #Btn_Reload
      #Font_Btn_Reload
      #Btn_Nav_Back
      #Font_Btn_Nav_Back
      #Btn_Nav_Frwd
      #Font_Btn_Nav_Frwd
      #Show_Current_Url
      #Show_Current_back
      #Font_Current_Url
      #Btn_Start_Browsing
      #Btn_Home
      #Font_Start_Browsing
      #Separater
      #Separater2
      #Separater3
      #ProgressBar
      #Txt_Browser
EndEnumeration

;Image Plugins
  UsePNGImageDecoder()

Define Event

Global WebObject.IWebBrowser2
; load a URL on start and set it as default
Global Url.s="http://www.google.com"
; define home button URL
Global HomeUrl.s=Url

;move window- hold left mouse trigger down
Procedure WinCallback(hWnd, uMsg, wParam, lParam)
  Protected result = #PB_ProcessPureBasicEvents
  Select uMsg
        
    Case #WM_LBUTTONDOWN
      SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)

  EndSelect
  ProcedureReturn result
EndProcedure

;- Read current URL
Procedure NavigationCallback(Gadget, NewUrl.s)
  
  If NewUrl <> Url
    ;SetGadgetText(#Show_Current_Url, GetGadgetText(#Webgadget))
         SetGadgetText(#Show_Current_Url, NewUrl)
     
    Url = NewUrl
  EndIf
  ProcedureReturn #PB_ProcessPureBasicEvents
  
EndProcedure

Procedure SuppressJavaScriptErrorMessages(WebGadget)
 
  Protected MyWebGadget.IWebBrowser2
 
  MyWebGadget = GetWindowLongPtr_(GadgetID(#Webgadget), #GWL_USERDATA)
  MyWebGadget\put_Silent(#True) ; Suppress JavaScript error messages.
 
EndProcedure

Procedure MainFormShow()
 hwnd=OpenWindow(#MainForm, 0, 0, 1280, 770,"WebGadget",#PB_Window_ScreenCentered|#PB_Window_BorderLess)
    SetWindowColor(#MainForm, RGB(15, 124, 15))
    
  ; show current URL in Address - Input-Field
    TextGadget(#Show_Current_back, 127, 0, 503, 31," ")
    SetGadgetColor(#Show_Current_back, #PB_Gadget_BackColor, RGB(11, 96, 13)) ;TXT Background Color
    StringGadget(#Show_Current_Url, 130, 7, 500, 20, Url, #PB_String_BorderLess)
    SetGadgetColor(#Show_Current_Url, #PB_Gadget_FrontColor, RGB(255, 255, 255));TXT Color
    SetGadgetColor(#Show_Current_Url, #PB_Gadget_BackColor, RGB(11, 96, 13)) ;TXT Background Color
    SetGadgetFont(#Show_Current_Url, LoadFont(#Font_Current_Url, "Lucida", 10, #PB_Font_HighQuality)) ; Button Font
    
WebGadget(#Webgadget, 1, 37, 1278, 732, "http://www.google.com")
   ProgressBarGadget(#ProgressBar, 1, 32, 1278, 5, 0, 0)
    SuppressJavaScriptErrorMessages(#Webgadget)
  
    ;- Add Keyboard Shortcuts
     WebObject.IWebBrowser2 = GetWindowLongPtr_(GadgetID(#WebGadget),#GWLP_USERDATA)
     AddKeyboardShortcut(#MainForm,#PB_Shortcut_Control|#PB_Shortcut_X,Asc("x"))
     AddKeyboardShortcut(#MainForm,#PB_Shortcut_Control|#PB_Shortcut_C,Asc("c"))
     AddKeyboardShortcut(#MainForm,#PB_Shortcut_Control|#PB_Shortcut_V,Asc("v"))
     AddKeyboardShortcut(#MainForm,#PB_Shortcut_Control|#PB_Shortcut_A,Asc("a"))
     AddKeyboardShortcut(#MainForm,#PB_Shortcut_Control|#PB_Shortcut_Z,Asc("z"))
     AddKeyboardShortcut(#MainForm,#PB_Shortcut_Control|#PB_Shortcut_Y,Asc("y"))
     AddKeyboardShortcut(#MainForm,#PB_Shortcut_Control|#PB_Shortcut_Shift|#PB_Shortcut_Z,Asc("y"))
     AddKeyboardShortcut(#MainForm, #PB_Shortcut_Return,1)
     
 ;- Btn Back
     TextGadget(#Btn_Nav_Back, 0, 0, 30, 31, "<",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
      SetGadgetFont(#Btn_Nav_Back, LoadFont(#Font_Btn_Nav_Back, "Lucida", 10, #PB_Font_HighQuality))  ; Button Font
      SetGadgetColor(#Btn_Nav_Back, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;TXT Background Color
      SetGadgetColor(#Btn_Nav_Back, #PB_Gadget_FrontColor, RGB(255, 255, 255))  ;TXT Color
      
  ;- Separator
     TextGadget(#Separater, 31, 6, 1, 18, "")
      SetGadgetColor(#Separater, #PB_Gadget_BackColor, RGB(31, 77, 106)) ;TXT Background Color  
      
  ;- Btn Forward
     TextGadget(#Btn_Nav_Frwd, 32, 0, 30, 31, ">",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
      SetGadgetFont(#Btn_Nav_Frwd, LoadFont(#Font_Btn_Nav_Frwd, "Lucida", 10, #PB_Font_HighQuality))  ; Button Font
      SetGadgetColor(#Btn_Nav_Frwd, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;TXT Background Color
      SetGadgetColor(#Btn_Nav_Frwd, #PB_Gadget_FrontColor, RGB(255, 255, 255))  ;TXT Color
     
  ;- Btn Reload
     TextGadget(#Btn_Reload, 60, 0, 60, 31, "refresh",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
      SetGadgetFont(#Btn_Reload, LoadFont(#Font_Btn_Reload, "Lucida", 10, #PB_Font_HighQuality))  ; Button Font
      SetGadgetColor(#Btn_Reload, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;TXT Background Color
      SetGadgetColor(#Btn_Reload, #PB_Gadget_FrontColor, RGB(255, 255, 255))  ;TXT Color
      
  ;- Btn Start Browsing 
     TextGadget(#Btn_Start_Browsing, 635, 0, 20, 31, ">>",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
      SetGadgetFont(#Btn_Start_Browsing, LoadFont(#Font_Start_Browsing, "Lucida", 10, #PB_Font_HighQuality))  ; Button Font
      SetGadgetColor(#Btn_Start_Browsing, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;TXT Background Color
      SetGadgetColor(#Btn_Start_Browsing, #PB_Gadget_FrontColor, RGB(255, 255, 255))  ;TXT Color
      
  ;- Separator2
     TextGadget(#Separater2, 670, 6, 1, 18, "")
      SetGadgetColor(#Separater2, #PB_Gadget_BackColor, RGB(31, 77, 106)) ;TXT Background Color      
      
  ;- Btn Home
     TextGadget(#Btn_Home, 680, 0, 50, 31, "home",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
      SetGadgetFont(#Btn_Home, LoadFont(#Font_Start_Browsing, "Lucida", 10, #PB_Font_HighQuality))  ; Button Font
      SetGadgetColor(#Btn_Home, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;TXT Background Color
      SetGadgetColor(#Btn_Home, #PB_Gadget_FrontColor, RGB(255, 255, 255))      ;TXT Color
      
  ;- TxT: Browser by inc in 2k16
      TextGadget(#Txt_Browser, 1000, 0, 250, 31, "Browser by inc in 2k16",#SS_CENTERIMAGE)     ;x;y;lenght;height
      SetGadgetFont(#Btn_Nav_Frwd, LoadFont(#Font_Btn_Nav_Frwd, "Lucida", 10, #PB_Font_HighQuality))  ; Button Font
      SetGadgetColor(#Txt_Browser, #PB_Gadget_FrontColor, RGB(13, 82, 16));Txt Color
      SetGadgetColor(#Txt_Browser, #PB_Gadget_BackColor, RGB(15, 124, 15)) ;Background Color 
      
  ;- Btn Close WEbGadget Window
     TextGadget(#Btn_CloseWebGadget, 1220, 0, 60, 31, "close",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
      SetGadgetFont(#Btn_CloseWebGadget, LoadFont(#Btn_CloseWebGadget, "Lucida", 10, #PB_Font_HighQuality))  ; Button Font
      SetGadgetColor(#Btn_CloseWebGadget, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;TXT Background Color
      SetGadgetColor(#Btn_CloseWebGadget, #PB_Gadget_FrontColor, RGB(255, 255, 255))  ;TXT Color
      
  ;- Separator3
     TextGadget(#Separater3, 1217, 6, 1, 18, "")
     SetGadgetColor(#Separater3, #PB_Gadget_BackColor, RGB(31, 77, 106)) ;TXT Background Color      
      
  ;- Btn minimize to tray
     TextGadget(#Btn_min_to_Tray, 1186, 0, 20, 31, "__",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
      SetGadgetFont(#Btn_min_to_Tray, LoadFont(#Btn_Fnt_min_to_Tray, "Lucida", 10, #PB_Font_HighQuality))  ; Button Font
      SetGadgetColor(#Btn_min_to_Tray, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;TXT Background Color
      SetGadgetColor(#Btn_min_to_Tray, #PB_Gadget_FrontColor, RGB(255, 255, 255))  ;TXT Color    
          
      myBrowser.IWebBrowser2 = GetWindowLong_(GadgetID(#WebGadget), #GWL_USERDATA) ;callback for Keyboard shortcuts
SetGadgetAttribute(#WebGadget, #PB_Web_NavigationCallback, @NavigationCallback())
EndProcedure

SetWindowCallback(@WinCallback())
MainFormShow()

; MAIN
Repeat
  Event = WaitWindowEvent()
  EventGadget = EventGadget()
  EventType = EventType()
  
;display progressbar load status
Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #WebGadget
          Select EventType()
            Case #PB_EventType_DownloadStart
            Case #PB_EventType_DownloadProgress
              SetGadgetAttribute(#ProgressBar, #PB_ProgressBar_Maximum, GetGadgetAttribute(#WebGadget, #PB_Web_ProgressMax))
              SetGadgetState(#ProgressBar, GetGadgetAttribute(#WebGadget, #PB_Web_Progress))
            Case #PB_EventType_DownloadEnd
          EndSelect
      EndSelect
  EndSelect 
  
;- Button Functions  
  If Event = #PB_Event_Gadget
    Select EventGadget()

      ;- BTN CloseWebGadget     
          Case #Btn_CloseWebGadget
            CloseWindow(#MainForm)
            End 
      ;- Web Navigation - Back - Forward - Reload - Browse - Home
          Case #Btn_Nav_Back
            SetGadgetState(#WebGadget, #PB_Web_Back)
          Case #Btn_Nav_Frwd
            SetGadgetState(#WebGadget, #PB_Web_Forward)
          Case #Btn_Reload
            SetGadgetState(#WebGadget, #PB_Web_Refresh)
          Case #Btn_Start_Browsing
            SetGadgetText(#Webgadget, GetGadgetText(#Show_Current_Url))
          Case #Btn_Home
            SetGadgetText(#Webgadget, HomeUrl)
          Case #Btn_min_to_Tray
            SetWindowState(#MainForm, #PB_Window_Minimize)
           
    EndSelect
  EndIf

 ; KeyboardShortcuts
    Select Event
      Case #PB_Event_Menu
          Select EventMenu()
            Case 'c'
              WebObject\ExecWB(#OLECMDID_COPY,#OLECMDEXECOPT_DONTPROMPTUSER,0,0)
            Case 'v'
              WebObject\ExecWB(#OLECMDID_PASTE,#OLECMDEXECOPT_DONTPROMPTUSER,0,0)  
            Case 1
              SetGadgetText(#Webgadget, GetGadgetText(#Show_Current_Url))
          EndSelect
    EndSelect  
             
  Until IsWindow(#MainForm)=0 And IsWindow(Fenster_ID)=0

 

pb_browser.rar

inc_browser.rar

Edited by udg

:rolleyes:

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.