home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / regicon / reginf4.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-12-11  |  8.3 KB  |  241 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Regicon Browser Settings"
  5.    ClientHeight    =   1935
  6.    ClientLeft      =   1500
  7.    ClientTop       =   3585
  8.    ClientWidth     =   8895
  9.    Height          =   2340
  10.    Icon            =   "reginf4.frx":0000
  11.    Left            =   1440
  12.    LinkTopic       =   "Form1"
  13.    LockControls    =   -1  'True
  14.    ScaleHeight     =   1935
  15.    ScaleWidth      =   8895
  16.    Top             =   3240
  17.    Width           =   9015
  18.    Begin VB.CommandButton cmdSteps 
  19.       Caption         =   "&See the Code"
  20.       Height          =   375
  21.       Left            =   7320
  22.       TabIndex        =   2
  23.       Top             =   600
  24.       Width           =   1455
  25.    End
  26.    Begin VB.CommandButton cmdClose 
  27.       Caption         =   "&Close"
  28.       Height          =   375
  29.       Left            =   7320
  30.       TabIndex        =   1
  31.       Top             =   240
  32.       Width           =   1455
  33.    End
  34.    Begin VB.Frame Frame1 
  35.       Height          =   1695
  36.       Left            =   120
  37.       TabIndex        =   0
  38.       Top             =   120
  39.       Width           =   6975
  40.       Begin VB.CommandButton cmdReset 
  41.          Caption         =   "&Reset Start Page"
  42.          Height          =   375
  43.          Left            =   5160
  44.          TabIndex        =   10
  45.          Top             =   1200
  46.          Width           =   1695
  47.       End
  48.       Begin VB.CommandButton cmdApply 
  49.          Caption         =   "&Change Start Page"
  50.          Height          =   375
  51.          Left            =   5160
  52.          TabIndex        =   9
  53.          Top             =   840
  54.          Width           =   1695
  55.       End
  56.       Begin VB.ComboBox cboStartPages 
  57.          Height          =   315
  58.          Left            =   1680
  59.          TabIndex        =   3
  60.          Top             =   840
  61.          Width           =   3375
  62.       End
  63.       Begin VB.Label lblDefaultBrowser 
  64.          Height          =   255
  65.          Left            =   1680
  66.          TabIndex        =   8
  67.          Top             =   240
  68.          Width           =   3375
  69.       End
  70.       Begin VB.Label Label2 
  71.          Alignment       =   1  'Right Justify
  72.          Caption         =   "Deafult Browser:"
  73.          Height          =   255
  74.          Left            =   120
  75.          TabIndex        =   7
  76.          Top             =   240
  77.          Width           =   1455
  78.       End
  79.       Begin VB.Label Label3 
  80.          Alignment       =   1  'Right Justify
  81.          Caption         =   "Current Start Page:"
  82.          Height          =   255
  83.          Left            =   120
  84.          TabIndex        =   6
  85.          Top             =   480
  86.          Width           =   1455
  87.       End
  88.       Begin VB.Label lblStartPage 
  89.          Height          =   255
  90.          Left            =   1680
  91.          TabIndex        =   5
  92.          Top             =   480
  93.          Width           =   3375
  94.       End
  95.       Begin VB.Label Label1 
  96.          Alignment       =   1  'Right Justify
  97.          Caption         =   "Start Pages:"
  98.          Height          =   255
  99.          Left            =   600
  100.          TabIndex        =   4
  101.          Top             =   840
  102.          Width           =   975
  103.       End
  104.       Begin RegistryControl.RegiCon RegiCon1 
  105.          Left            =   120
  106.          Top             =   840
  107.          _ExtentX        =   847
  108.          _ExtentY        =   847
  109.       End
  110.    End
  111. Attribute VB_Name = "Form1"
  112. Attribute VB_Creatable = False
  113. Attribute VB_Exposed = False
  114. Private DefaultBrowser As String
  115. Private DefaultStartPage As String
  116. Private NewStartPage As String
  117. Private fDirty As Boolean
  118. Private Sub cmdApply_Click()
  119.     Dim i As Integer
  120.     Dim fMatch As Boolean
  121.     If MsgBox("Change start page from " & vbCrLf & NewStartPage & vbCrLf & "to" & vbCrLf & cboStartPages.Text & "?", vbQuestion + vbYesNo, "Confirm Change?") = vbNo Then
  122.         Exit Sub
  123.     End If
  124.     NewStartPage = cboStartPages.Text
  125.     fDirty = True
  126.     If InStr(1, lblDefaultBrowser.Caption, "IExplore", 1) > 0 Then
  127.         'IE
  128.         RegiCon1.RootKey = rkHKEY_CURRENT_USER
  129.         RegiCon1.Key = "Software\Microsoft\Internet Explorer\Main"
  130.         RegiCon1.KeyItemName = "Start Page"
  131.         RegiCon1.KeyItemType = dtREG_SZ
  132.         RegiCon1.KeyItemValue = NewStartPage
  133.         RegiCon1.SetEntry
  134.     ElseIf InStr(1, lblDefaultBrowser.Caption, "Netscape", 1) > 0 Then
  135.         'Netscape
  136.         RegiCon1.RootKey = rkHKEY_CURRENT_USER
  137.         RegiCon1.Key = "Software\Netscape\Netscape Navigator\Main"
  138.         RegiCon1.KeyItemName = "Home Page"
  139.         RegiCon1.KeyItemType = dtREG_SZ
  140.         RegiCon1.KeyItemValue = NewStartPage
  141.         RegiCon1.SetEntry
  142.     End If
  143.     lblStartPage.Caption = NewStartPage
  144.     For i = 0 To cboStartPages.ListCount - 1
  145.         If StrComp(NewStartPage, cboStartPages.List(i), 1) = 0 Then
  146.             fMatch = True
  147.             Exit For
  148.         End If
  149.     Next i
  150.     If fMatch = False Then
  151.         cboStartPages.AddItem NewStartPage, 0
  152.     End If
  153. End Sub
  154. Private Sub cmdClose_Click()
  155.     Unload Me
  156. End Sub
  157. Private Sub cmdReset_Click()
  158.     If InStr(1, lblDefaultBrowser.Caption, "IExplore", 1) > 0 Then
  159.         'IE
  160.         RegiCon1.RootKey = rkHKEY_CURRENT_USER
  161.         RegiCon1.Key = "Software\Microsoft\Internet Explorer\Main"
  162.         RegiCon1.KeyItemName = "Start Page"
  163.         RegiCon1.KeyItemType = dtREG_SZ
  164.         RegiCon1.KeyItemValue = DefaultStartPage
  165.         RegiCon1.SetEntry
  166.     ElseIf InStr(1, lblDefaultBrowser.Caption, "Netscape", 1) > 0 Then
  167.         'Netscape
  168.         RegiCon1.RootKey = rkHKEY_CURRENT_USER
  169.         RegiCon1.Key = "Software\Netscape\Netscape Navigator\Main"
  170.         RegiCon1.KeyItemName = "Home Page"
  171.         RegiCon1.KeyItemType = dtREG_SZ
  172.         RegiCon1.KeyItemValue = DefaultStartPage
  173.         RegiCon1.SetEntry
  174.     End If
  175.     lblStartPage.Caption = DefaultStartPage
  176.     cboStartPages.ListIndex = 0
  177.     NewStartPage = DefaultStartPage
  178.     fDirty = False
  179. End Sub
  180. Private Sub cmdSteps_Click()
  181.     frmCode.Show 1
  182. End Sub
  183. Private Sub Form_Load()
  184.     'verify there is a default browser entry
  185.     RegiCon1.RootKey = rkHKEY_LOCAL_MACHINE
  186.     RegiCon1.Key = "SOFTWARE\Classes\http\shell\open\ddeexec\Application"
  187.     RegiCon1.KeyItemName = ""
  188.     If RegiCon1.IsEntry = False Then
  189.         '
  190.         'no default browser installed
  191.         MsgBox "No Browser Detected. Quitting."
  192.         Unload Me
  193.     End If
  194.     'get the default browser
  195.     RegiCon1.GetEntry
  196.     '
  197.     'Display the entry
  198.     lblDefaultBrowser.Caption = RegiCon1.KeyItemValue
  199.     If InStr(1, lblDefaultBrowser.Caption, "IExplore", 1) > 0 Then
  200.         'Default is Internet Explorer
  201.         RegiCon1.RootKey = rkHKEY_CURRENT_USER
  202.         RegiCon1.Key = "Software\Microsoft\Internet Explorer\Main"
  203.         RegiCon1.KeyItemName = "Start Page"
  204.         RegiCon1.GetEntry
  205.         DefaultStartPage = RegiCon1.KeyItemValue
  206.     ElseIf InStr(1, lblDefaultBrowser.Caption, "Netscape", 1) > 0 Then
  207.         'Default is Netscape
  208.         RegiCon1.RootKey = rkHKEY_CURRENT_USER
  209.         RegiCon1.Key = "Software\Netscape\Netscape Navigator\Main"
  210.         RegiCon1.KeyItemName = "Home Page"
  211.         RegiCon1.GetEntry
  212.         DefaultStartPage = RegiCon1.KeyItemValue
  213.     Else
  214.         'unknown location of
  215.         cboStartPages.Enabled = False
  216.         cmdApply.Enabled = False
  217.         cmdReset.Enabled = False
  218.         Exit Sub
  219.     End If
  220.     '
  221.     'load the StartPage box with a list of URLs
  222.     NewStartPage = DefaultStartPage
  223.     lblStartPage.Caption = NewStartPage
  224.     cboStartPages.AddItem NewStartPage
  225.     cboStartPages.AddItem "http://www.mabry.com/index.htm"
  226.     cboStartPages.AddItem "http://www.microsoft.com/index.htm"
  227.     cboStartPages.AddItem "http://www.netscape.com/index.html"
  228.     cboStartPages.ListIndex = 0
  229. End Sub
  230. Private Sub Form_Unload(Cancel As Integer)
  231.     '
  232.     'if we've ended up with something different than
  233.     'we started with, see if the user wants to keep
  234.     'the new setting
  235.     If StrComp(NewStartPage, DefaultStartPage, 1) <> 0 Then
  236.         If MsgBox("The start page has changed from " & vbCrLf & DefaultStartPage & vbCrLf & "to" & vbCrLf & NewStartPage & vbCr & vbCrLf & "Keep this new start page?", vbQuestion + vbYesNo, "Confirm Change?") = vbNo Then
  237.             cmdReset_Click
  238.         End If
  239.     End If
  240. End Sub
  241.