Need sample that display default browser as an icon on butto

Need sample that display default browser as an icon on butto

Postby hua » Tue Jun 06, 2017 4:35 am

Hi guys,

I would like to have a button called "Open..." with an icon of whatever current default web browser is on it too.

Anyone has any code snippet to do this?

TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Need sample that display default browser as an icon on butto

Postby hua » Thu Jun 08, 2017 3:10 am

Instead of reading the web browser's icon from the exe itself I took the approach of preparing in advance the icons of commonly used browser and select which one to use after determining what is current default browser.

Anyone knows what is the tried and tested method to include alpha blended images in an rc compiled with brc? Is changing the resource compiler the only way to go?

Code: Select all  Expand view

function WebBrowserIcon()
  // code based on https://stackoverflow.com/questions/136 ... er-using-c

  local oReg, cProgId, cPath := "", nPos, cBrowser := "Unknown browser", cCom, cIcon := ""
    // determine prog id of default browser
    oReg := TReg32():New(HKEY_CURRENT_USER, "Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice" )
    cProgId := oReg:Get("ProgId")
    oReg:Close()
    do case
       case cProgId == "IE.HTTP"
            cBrowser := "Internet Explorer"
            cIcon := "ie.bmp"
       case cProgId == "FirefoxURL"
            cBrowser := "Firefox"
            cIcon := "firefox.bmp"
       case cProgId == "ChromeHTML"
            cBrowser := "Chrome"
            cIcon := "chrome.bmp"
       case cProgId == "OperaStable"
            cBrowser := "Opera"
            cIcon := "opera.bmp"
       case cProgId == "SafariHTML"
            cBrowser := "Safari"
       case cProgId == "AppXq0fevzme2pys62n3e0fbqa7peapykr8v"
            cBrowser := "Microsoft Edge"
            cIcon := "edge.bmp"
    endcase
    if !empty(cIcon)
       cIcon := ud_bmpDir() + "\" +cIcon
    endif

    // use the progid to determine path to exe
    if !empty(cProgId)
       oReg := TReg32():New(HKEY_CLASSES_ROOT, cProgId + "
\shell\open\command" )
       cPath := oReg:Get()
       oReg:Close()
       if (nPos := at("
.exe", cPath)) > 0
          cPath := left(cPath, nPos+5)
       endif
    endif
    if !empty(cPath)
       *cCom := 'iconsext.exe /save '+cPath+' "
'+ud_bmpDir()+'" -icons'
       *waitrun(cCom, SW_HIDE)
    endif
return cIcon

FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 111 guests