Purebasic : a very small and handy Web Browser + source code

Help other Members. Share your Source Codes
Forum rules
If you share codes or scripts that you haven't developed by yourself,
then you have to mention and give some credits in your post to the original author of the code or script.
inc
Site Admin
Posts: 92
Joined: 18 Apr 2016 19:38
Has thanked: 48 times
Been thanked: 52 times
Status: Offline

Purebasic : a very small and handy Web Browser + source code

Postby inc » 27 May 2016 04:23

Hi,
today i wanna share my own programmed quick Web Browser with you.
The Browser support modern HTML Web Standard.
someone may find it useful. Source is not finished, you can add all your needs and or fix some bugs.

~200kb exe @ 0-2% CPU :icon_eek:

Code: Select all

;
; just a simple purebasic html5 web browser by inc.aka udg
;
; including home button, forward, back, reload/ refresh, close,
; minimize to tray, popup message, delete internet files
; 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
  #Popup_Window
    ;WebGadget
      #WebGadget
      #Btn_CloseWebGadget
      #Btn_min_to_Tray
      #Btn_Reload
      #Btn_Nav_Back
      #Btn_Nav_Frwd
      #Show_Current_Url
      #Show_Current_back
      #Font_Current_Url
      #Btn_Start_Browsing
      #Btn_Home
      #Separater
      #Separater2
      #Separater3
      #Separater4
      #ProgressBar
      #Txt_Browser
      #Btn_Clean_Session
      ; Show Message popup
        #Popup_Window_Line_Top
        #Popup_Window_Line_Left
        #Popup_Window_Line_Right
        #Popup_Window_Line_Bottom
        #Success_Message
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
Global NewUrl.s=Url

; FIND LOCATION OF COOKIES and TEMPORARY INTERNET FILES
#CSIDL_COOKIES = $21
#CSIDL_INTERNET_CACHE = $20
Procedure.s nsFldrFromId(folderId.l)
result.s
pidl.l
result = Space(#MAX_PATH)
SHGetSpecialFolderLocation_(0, folderId, @pidl)
SHGetPathFromIDList_(pidl, @result)
CoTaskMemFree_(pidl)
    ProcedureReturn result
EndProcedure

; Find path to your browser Cookies and Internet Temp Files
  ;Debug nsFldrFromId(#CSIDL_COOKIES)
  ;Debug nsFldrFromId(#CSIDL_INTERNET_CACHE)

; delete browser Cookies and Interent Temp Files on start
  ; inc = my PC Username
  ; change it to yours !
    DeleteDirectory("C:\Users\inc\AppData\Roaming\Microsoft\Windows\Cookies", "*.*" ,#PB_FileSystem_Force)
    DeleteDirectory("C:\Users\inc\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5",Pattern$,#PB_FileSystem_Force|#PB_FileSystem_Recursive)

;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

Procedure RegConvertRegKeyToTopKeyAndKeyName(Key.s)
 
  Shared topKey,KeyName.s
 
  temp.s=StringField(Key,1,"\")
  temp=UCase(temp)
  Select temp
    Case "HKEY_CLASSES_ROOT"
      topKey=#HKEY_CLASSES_ROOT
    Case "HKEY_CURRENT_USER"
      topKey=#HKEY_CURRENT_USER
    Case "HKEY_LOCAL_MACHINE"
      topKey=#HKEY_LOCAL_MACHINE
    Case "HKEY_USERS"
      topKey=#HKEY_USERS
    Case "HKEY_CURRENT_CONFIG"
      topKey=#HKEY_CURRENT_CONFIG
  EndSelect
 
  PositionSlash=FindString(Key,"\",1)
  KeyName.s=Right(Key,(Len(Key)-PositionSlash))
 
EndProcedure

ProcedureDLL RegSetValue(Key.s, ValueName.s, Value.s, Type, ComputerName.s) ; Sets a Value
 
  ;Type can be #REG_SZ / #REG_DWORD / #REG_BINARY / #REG_EXPAND_SZ
  ;For REG_BINARY type use Hexa value as String
  ;Returns 1 if successful or 0 if it fails
 
  Shared RegWow64.l,RegEx,topKey,KeyName.s
  RegConvertRegKeyToTopKeyAndKeyName(Key)
 
  If ComputerName = "."
    If RegEx
      GetHandle = RegOpenKeyEx_(topKey,KeyName,0,#KEY_ALL_ACCESS|RegWow64,@hKey)
    Else
      GetHandle = RegOpenKey_(topKey,KeyName,@hKey)
    EndIf
  Else
    lReturnCode = RegConnectRegistry_(ComputerName,topKey,@lhRemoteRegistry)
    If RegEx
      GetHandle = RegOpenKeyEx_(lhRemoteRegistry,KeyName,0,#KEY_ALL_ACCESS|RegWow64,@hKey)
    Else
      GetHandle = RegOpenKey_(lhRemoteRegistry,KeyName,@hKey)
    EndIf
  EndIf
 
  If GetHandle = #ERROR_SUCCESS
    lpcbData = 255
    lpData.s = Space(255)
   
    Select Type
       
      Case #REG_EXPAND_SZ
        GetHandle = RegSetValueEx_(hKey, ValueName, 0, #REG_EXPAND_SZ, @Value, Len(Value) + 1)
       
      Case #REG_SZ
        GetHandle = RegSetValueEx_(hKey, ValueName, 0, #REG_SZ, @Value, Len(Value) + 1)
       
      Case #REG_DWORD
        lValue = Val(Value)
        GetHandle = RegSetValueEx_(hKey, ValueName, 0, #REG_DWORD, @lValue, 4)
       
      Case #REG_BINARY
        LenBuffer=Len(Value)/2
        *RegBuffer=AllocateMemory(LenBuffer)
        For n=0 To LenBuffer-1
          OctetHexa.s=Mid(Value,(n*2)+1,2)
          Octet=Val("$"+OctetHexa)
          PokeB(*RegBuffer+n,Octet)
        Next
        GetHandle= RegSetValueEx_(hKey,ValueName,0,#REG_BINARY,*RegBuffer,LenBuffer)
        FreeMemory(*RegBuffer)
       
    EndSelect
   
    RegCloseKey_(hKey)
    ergebnis = 1
    ProcedureReturn ergebnis
  Else
    RegCloseKey_(hKey)
    ergebnis = 0
    ProcedureReturn ergebnis
  EndIf
EndProcedure

ProcedureDLL RegCreateKey(Key.s, ComputerName.s)
 
  ;It create subkey if KeyPath don't exist
  ;Returns 1 if successful or 0 if it fails
 
  Shared RegWow64.l,RegEx,topKey,KeyName.s
 
  RegConvertRegKeyToTopKeyAndKeyName(Key)
  lpSecurityAttributes.SECURITY_ATTRIBUTEs
 
  If ComputerName = "."
    If RegEx
      GetHandle = RegCreateKeyEx_(topKey,KeyName,0,0,#REG_OPTION_NON_VOLATILE,#KEY_ALL_ACCESS|RegWow64,@lpSecurityAttributes,@hNewKey,@GetHandle)
    Else
      GetHandle = RegCreateKey_(topKey,KeyName,@hNewKey)
    EndIf
  Else
    lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry)
    If RegEx
      GetHandle = RegCreateKeyEx_(lhRemoteRegistry,KeyName,0,0,#REG_OPTION_NON_VOLATILE,#KEY_ALL_ACCESS|RegWow64,@lpSecurityAttributes,@hNewKey,@GetHandle)
    Else
      GetHandle = RegCreateKey_(lhRemoteRegistry,KeyName,@hNewKey)
    EndIf
  EndIf
 
  If GetHandle = #ERROR_SUCCESS
    GetHandle = RegCloseKey_(hNewKey)
    CreateKey = #True
  Else
    CreateKey = #False
  EndIf
  ProcedureReturn CreateKey
EndProcedure

ProcedureDLL RegCreateKeyValue(Key.s,ValueName.s,Value.s,Type,ComputerName.s) ; Creates a Key and a Value in a Single Command
 
  ;Type can be #REG_SZ or #REG_DWORD
  ;Returns 1 if successful or 0 if it fails
 
  RegCreateKey(Key,ComputerName)
  ProcedureReturn RegSetValue(Key,ValueName,Value,Type,ComputerName)
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, 1200, 800,"WebGadget",#PB_Window_ScreenCentered|#PB_Window_BorderLess)
    SetWindowColor(#MainForm, RGB(15, 124, 15))
   
    Font1 = LoadFont(#PB_Any, "Lucida", 10, #PB_Font_HighQuality)   
   
  ; 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, 496, 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, FontID(Font1))
   
WebGadget(#Webgadget, 1, 37, 1198, 762, URL)
   ProgressBarGadget(#ProgressBar, 1, 32, 1198, 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, FontID(Font1))
     SetGadgetColor(#Btn_Nav_Back, #PB_Gadget_FrontColor, RGB(255, 255, 255));TXT Background Color
     SetGadgetColor(#Btn_Nav_Back, #PB_Gadget_BackColor, RGB(15, 124, 15)) ;TXT Background Color
     
  ;- Separator
     TextGadget(#Separater, 31, 6, 1, 18, "")
     SetGadgetColor(#Separater, #PB_Gadget_BackColor, RGB(11, 96, 13)) ;Hintergrund FARBE
     
  ;- Btn Forward
     TextGadget(#Btn_Nav_Frwd, 33, 0, 30, 31, ">",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
     SetGadgetFont(#Btn_Nav_Frwd, FontID(Font1))
     SetGadgetColor(#Btn_Nav_Frwd, #PB_Gadget_FrontColor, RGB(255, 255, 255));TXT Background Color
     SetGadgetColor(#Btn_Nav_Frwd, #PB_Gadget_BackColor, RGB(15, 124, 15)) ;TXT Background Color
     
  ;- Btn Reload
     TextGadget(#Btn_Reload, 62, 0, 60, 31, "refresh",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
     SetGadgetFont(#Btn_Reload, FontID(Font1))
     SetGadgetColor(#Btn_Reload, #PB_Gadget_FrontColor, RGB(255, 255, 255));TXT Background Color
     SetGadgetColor(#Btn_Reload, #PB_Gadget_BackColor, RGB(15, 124, 15)) ;TXT Background Color
     
  ;- Btn Start Browsing
     TextGadget(#Btn_Start_Browsing, 635, 0, 20, 31, ">>",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
     SetGadgetFont(#Btn_Start_Browsing, FontID(Font1))
     SetGadgetColor(#Btn_Start_Browsing, #PB_Gadget_FrontColor, RGB(255, 255, 255));TXT Background Color
     SetGadgetColor(#Btn_Start_Browsing, #PB_Gadget_BackColor, RGB(15, 124, 15)) ;TXT Background Color
       
  ;- Separator2
     TextGadget(#Separater2, 670, 6, 1, 18, "")
     SetGadgetColor(#Separater2, #PB_Gadget_BackColor, RGB(11, 96, 13)) ;Background Color
     
  ;- Btn Home
     TextGadget(#Btn_Home, 680, 0, 50, 31, "home",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
     SetGadgetFont(#Btn_Home, FontID(Font1))
     SetGadgetColor(#Btn_Home, #PB_Gadget_FrontColor, RGB(255, 255, 255));TXT Background Color
     SetGadgetColor(#Btn_Home, #PB_Gadget_BackColor, RGB(15, 124, 15)) ;TXT Background Color
     
  ;- Separator3
     TextGadget(#Separater3, 738, 6, 1, 18, "")
     SetGadgetColor(#Separater3, #PB_Gadget_BackColor, RGB(11, 96, 13)) ;Background Color
     
  ;- Btn Clean Temp Files and Cookies
     TextGadget(#Btn_Clean_Session, 765, 0, 80, 31, "delete history",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
     SetGadgetFont(#Btn_Clean_Session, FontID(Font1))
     SetGadgetColor(#Btn_Clean_Session, #PB_Gadget_FrontColor, RGB(255, 255, 255));TXT Background Color
     SetGadgetColor(#Btn_Clean_Session, #PB_Gadget_BackColor, RGB(15, 124, 15)) ;TXT Background 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(#Txt_Browser, FontID(Font1))
     SetGadgetColor(#Txt_Browser, #PB_Gadget_FrontColor, RGB(13, 82, 16));TXT Background Color
     SetGadgetColor(#Txt_Browser, #PB_Gadget_BackColor, RGB(15, 124, 15)) ;TXT Background Color
     
  ;- Btn minimize to tray
     TextGadget(#Btn_min_to_Tray, 1555, 0, 20, 31, "__",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
     SetGadgetFont(#Btn_min_to_Tray, FontID(Font1))
     SetGadgetColor(#Btn_min_to_Tray, #PB_Gadget_FrontColor, RGB(255, 255, 255));TXT Background Color
     SetGadgetColor(#Btn_min_to_Tray, #PB_Gadget_BackColor, RGB(15, 124, 15)) ;TXT Background Color
     
  ;- Separator4
     TextGadget(#Separater4, 1592, 6, 1, 18, "")
     SetGadgetColor(#Separater4, #PB_Gadget_BackColor, RGB(11, 96, 13)) ;Background Color
     
  ;- Btn Close WEbGadget Window
     TextGadget(#Btn_CloseWebGadget, 1149, 0, 50, 31, "close",#SS_CENTERIMAGE|#SS_NOTIFY|#SS_CENTER)
     SetGadgetFont(#Btn_CloseWebGadget, FontID(Font1))
     SetGadgetColor(#Btn_CloseWebGadget, #PB_Gadget_FrontColor, RGB(255, 255, 255));TXT Background Color
     SetGadgetColor(#Btn_CloseWebGadget, #PB_Gadget_BackColor, RGB(15, 124, 15)) ;TXT Background Color
     
     myBrowser.IWebBrowser2 = GetWindowLong_(GadgetID(#WebGadget), #GWL_USERDATA) ;callback für Keyboard shortcuts
     SetGadgetAttribute(#WebGadget, #PB_Web_NavigationCallback, @NavigationCallback())
     
EndProcedure

;- Success message
Procedure Success_Dialog()
If OpenWindow(#Popup_Window, 732, 301, 450, 100, "", #PB_Window_WindowCentered | #PB_Window_BorderLess)
  SetWindowColor(#Popup_Window,RGB(68, 70, 71))
  ; SET WINDOW ALWAYS ON TOP
    SetWindowPos_(WindowID(#Popup_Window),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
    Font2 = LoadFont(#PB_Any, "Microsoft Sans Serif", 16, #PB_Font_HighQuality)   
   
    ; 1px window frame
   
    ;1PX Line top
      TextGadget(#Popup_Window_Line_Top, 0, 0, 450, 1, "") ;x;y;lenght;height
      HideGadget(#Popup_Window_Line_Top, 1)
      SetGadgetColor(#Popup_Window_Line_Top, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;Line color
    ;1PX Line 1PX left
      TextGadget(#Popup_Window_Line_Left, 0, 1, 1, 98, "") ;x;y;lenght;height
      HideGadget(#Popup_Window_Line_Left, 1)
      SetGadgetColor(#Popup_Window_Line_Left, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;Line color
    ; 1PX Line 1PX right
      TextGadget(#Popup_Window_Line_Right, 449, 1, 1, 98, "") ;x;y;lenght;height
      HideGadget(#Popup_Window_Line_Right, 1)
      SetGadgetColor(#Popup_Window_Line_Right, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;Line color
    ; 1PX Line 1PX bottom
      TextGadget(#Popup_Window_Line_Bottom, 0, 99, 450, 1, "") ;x;y;lenght;height
      HideGadget(#Popup_Window_Line_Bottom, 1)
      SetGadgetColor(#Popup_Window_Line_Bottom, #PB_Gadget_BackColor, RGB(15, 124, 15))  ;Line color   
    ; INFO FIELD
      TextGadget(#Success_Message, 1, 1, 448, 98,"Cookies and Tempfiles deleted",#SS_CENTERIMAGE|#SS_CENTER) ;x;y;lenght;height
      SetGadgetFont(#Success_Message, FontID(Font2))
      SetGadgetColor(#Success_Message, #PB_Gadget_BackColor, RGB(233, 233, 233)) ;background color
      SetGadgetColor(#Success_Message, #PB_Gadget_FrontColor, RGB(11, 96, 13)) ;txt color

EndIf

      HideGadget(#Popup_Window_Line_Top, 0)
      HideGadget(#Popup_Window_Line_Left, 0)
      HideGadget(#Popup_Window_Line_Right, 0)
      HideGadget(#Popup_Window_Line_Bottom, 0)

; CLOSE POPUP via TIMER
  Endtimer=AddDate(Date(),#PB_Date_Second,1.0)
  Repeat
    EventID=WindowEvent()
      If Date()>Endtimer
        CloseWindow(#Popup_Window)
        UpdateWindow_(WindowID(#MainForm))
        Break
      EndIf
     
    Until Quit
EndProcedure

Procedure Start() ;use IE11 as Webgadget html5
  RegCreateKeyValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", GetFilePart(ProgramFilename()), "11001", #REG_DWORD, ".")
  MainFormShow()
EndProcedure
;}

SetWindowCallback(@WinCallback())
Start()

; 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
         ; delete Internet Cookies and Internet Temp Files on exit
           DeleteDirectory("C:\Users\inc\AppData\Roaming\Microsoft\Windows\Cookies", "*.*" ,#PB_FileSystem_Force)
           DeleteDirectory("C:\Users\inc\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5",Pattern$,#PB_FileSystem_Force|#PB_FileSystem_Recursive)
          ; find and show path to Temp Internet files and Cookies
              ;Debug nsFldrFromId(#CSIDL_COOKIES)
              ;Debug nsFldrFromId(#CSIDL_INTERNET_CACHE)
           End
      ;- Web Navigation - Back - Forward - Reload - Browse - Home - delete history
          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))
           
          ;Auto select/Highlight when focus in address field
          Case #Show_Current_Url 
            If EventType() = #PB_EventType_Focus
               SendMessage_(GadgetID(EventGadget()), #EM_SETSEL, Len(GetGadgetText(EventGadget())), 0)
            EndIf
           
          Case #Btn_Home
            SetGadgetText(#Webgadget, HomeUrl)
          ; privacy Button 
          Case #Btn_Clean_Session 
            ; delete Internet Cookies and IE Temp Files
            ; change your User Name "inc" in the current Path to yours
            Success_Dialog()
            DeleteDirectory("C:\Users\inc\AppData\Roaming\Microsoft\Windows\Cookies", "*.*" ,#PB_FileSystem_Force)
            DeleteDirectory("C:\Users\inc\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5",Pattern$,#PB_FileSystem_Force|#PB_FileSystem_Recursive)
            SetGadgetState(#WebGadget, #PB_Web_Refresh)
            ; find and show path to Temp Internet files and Cookies
                  ;Debug nsFldrFromId(#CSIDL_COOKIES)
                  ;Debug nsFldrFromId(#CSIDL_INTERNET_CACHE)
           
          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 ; RETURN KEY bugged
              SetGadgetText(#Webgadget, GetGadgetText(#Show_Current_Url))
          EndSelect
    EndSelect
             
  Until IsWindow(#MainForm)=0 And IsWindow(Fenster_ID)=0


Image

if you wanna give em a try, don't forget to add the programm icon in the compiler settings.
Only registered members are able to see and download attachments from Aftermath. You must LOGIN or REGISTER to view these files.

User avatar
WhiteWolf
Site Admin
Posts: 300
Joined: 11 Apr 2016 17:49
Has thanked: 74 times
Been thanked: 54 times
Status: Offline

Re: Purebasic: a very small and handy Web Browser + source code

Postby WhiteWolf » 28 May 2016 00:56

Pretty cool one inc gonna try this code thanks for sharing it :icon_lupe:
(¯`·._.·currently working on Windows [AM]WEBDEFF Editor DemoTool Project.·._.·´¯)


alveo

Return to “Purebasic”

Who is online

Users browsing this forum: No registered users and 1 guest

Created by Matti from StylesFactory.pl and Warlords of Draenor


435,659 Page visits

Powered by phpBB® Forum Software © phpBB Limited