home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Microsoft Plateform / Visual Basic 5.0 / Msvb50.ace / msvb50 / MSVB50 / VB / SETUPKIT / SETUP1 / GROUP.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-12-01  |  10.4 KB  |  331 lines

  1. VERSION 5.00
  2. Begin VB.Form frmGroup 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "* #"
  5.    ClientHeight    =   5250
  6.    ClientLeft      =   1095
  7.    ClientTop       =   1515
  8.    ClientWidth     =   5460
  9.    Icon            =   "group.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    LockControls    =   -1  'True
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   350
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   364
  17.    Begin VB.DirListBox dir95Groups 
  18.       Height          =   930
  19.       Left            =   765
  20.       TabIndex        =   8
  21.       Top             =   60
  22.       Visible         =   0   'False
  23.       Width           =   3810
  24.    End
  25.    Begin VB.Frame Frame1 
  26.       Height          =   30
  27.       Left            =   105
  28.       TabIndex        =   7
  29.       Top             =   4650
  30.       Width           =   5220
  31.    End
  32.    Begin VB.CommandButton cmdCancel 
  33.       Cancel          =   -1  'True
  34.       Caption         =   "#"
  35.       Height          =   345
  36.       Left            =   2880
  37.       MaskColor       =   &H00000000&
  38.       TabIndex        =   3
  39.       Top             =   4800
  40.       Width           =   1140
  41.    End
  42.    Begin VB.CommandButton cmdContinue 
  43.       Caption         =   "#"
  44.       Default         =   -1  'True
  45.       Height          =   345
  46.       Left            =   1395
  47.       MaskColor       =   &H00000000&
  48.       TabIndex        =   2
  49.       Top             =   4800
  50.       Width           =   1140
  51.    End
  52.    Begin VB.ListBox lstGroups 
  53.       Height          =   2040
  54.       ItemData        =   "group.frx":0442
  55.       Left            =   1080
  56.       List            =   "group.frx":0449
  57.       Sorted          =   -1  'True
  58.       TabIndex        =   1
  59.       Top             =   2220
  60.       Width           =   3240
  61.    End
  62.    Begin VB.TextBox txtGroup 
  63.       Height          =   300
  64.       Left            =   1080
  65.       TabIndex        =   0
  66.       Text            =   "*"
  67.       Top             =   1410
  68.       Width           =   3270
  69.    End
  70.    Begin VB.Label lblDDE 
  71.       Height          =   225
  72.       Left            =   225
  73.       TabIndex        =   9
  74.       Top             =   1350
  75.       Visible         =   0   'False
  76.       Width           =   705
  77.    End
  78.    Begin VB.Label lblGroups 
  79.       AutoSize        =   -1  'True
  80.       Caption         =   "#"
  81.       Height          =   195
  82.       Left            =   1080
  83.       TabIndex        =   6
  84.       Top             =   1950
  85.       Width           =   105
  86.    End
  87.    Begin VB.Label lblGroup 
  88.       AutoSize        =   -1  'True
  89.       Caption         =   "#"
  90.       Height          =   195
  91.       Left            =   1080
  92.       TabIndex        =   5
  93.       Top             =   1170
  94.       Width           =   105
  95.    End
  96.    Begin VB.Label lblMain 
  97.       AutoSize        =   -1  'True
  98.       Caption         =   "#"
  99.       Height          =   195
  100.       Left            =   180
  101.       TabIndex        =   4
  102.       Top             =   165
  103.       Width           =   5100
  104.       WordWrap        =   -1  'True
  105.    End
  106. Attribute VB_Name = "frmGroup"
  107. Attribute VB_GlobalNameSpace = False
  108. Attribute VB_Creatable = False
  109. Attribute VB_PredeclaredId = True
  110. Attribute VB_Exposed = False
  111. Option Explicit
  112. Dim mstrGroup As String
  113. Dim mstrDefGroup As String
  114. Dim mstrProgramsPath As String
  115. Dim mfrm As Form
  116. Private Sub cmdCancel_Click()
  117.     ExitSetup frmGroup, gintRET_EXIT
  118. End Sub
  119. Private Sub cmdContinue_Click()
  120.     mstrGroup = txtGroup.Text
  121.     If Not fCreateProgGroup() Then
  122.         '
  123.         ' Couldn't create the group. Let
  124.         ' the user try again.
  125.         '
  126.         txtGroup.SetFocus
  127.     Else
  128.         '
  129.         ' The group got created ok, so unload Choose Program Group dialog
  130.         ' and continue on with setup.
  131.         '
  132.         Unload Me
  133.     End If
  134. End Sub
  135. Private Function fCreateProgGroup() As Boolean
  136. ' Create a program group for either NT or Win95.
  137.     Dim strMsg As String
  138.     If TreatAsWin95() Then
  139.         If Not fValidFilename(mstrGroup) Then
  140.             strMsg = ResolveResString(resGROUPINVALIDGROUPNAME, "|1", CStr(gintMAX_PATH_LEN), "|2", ResolveResString(resCOMMON_INVALIDFILECHARS))
  141.             MsgFunc strMsg, vbOKOnly Or vbQuestion, gstrTitle
  142.             GoTo CGError
  143.         End If
  144.     Else
  145.         If Not fValidNTGroupName(mstrGroup) Then
  146.             strMsg = ResolveResString(resGROUPINVALIDGROUPNAME, "|1", CStr(gintMAX_GROUPNAME_LEN%), "|2", ResolveResString(resGROUPINVALIDCHARS))
  147.             MsgFunc strMsg, vbOKOnly Or vbQuestion, gstrTitle
  148.             GoTo CGError
  149.         End If
  150.             
  151.     End If
  152.     '
  153.     'Go ahead and create the main program group
  154.     '
  155.     If Not fCreateOSProgramGroup(mfrm, mstrGroup, True) Then
  156.         GoTo CGError
  157.     End If
  158.     fCreateProgGroup = True
  159.     Exit Function
  160. CGError:
  161.     fCreateProgGroup = False
  162. End Function
  163. Private Sub Form_Load()
  164.     '
  165.     ' Initialize localized control properties.
  166.     '
  167.     SetFormFont Me
  168.     Me.Caption = ResolveResString(resGROUPFRM, "|1", gstrAppName)
  169.     lblMain.Caption = ResolveResString(resGROUPLBLMAIN)
  170.     lblGroup.Caption = ResolveResString(resGROUPLBLGROUP)
  171.     lblGroups.Caption = ResolveResString(resGROUPLBLGROUPS)
  172.     cmdContinue.Caption = ResolveResString(resGROUPBTNCONTINUE)
  173.     cmdCancel.Caption = ResolveResString(resLOG_IDCANCEL)
  174.     '
  175.     ' Initialize the Program Group text box with the
  176.     ' title of the application.
  177.     '
  178.     txtGroup.Text = gstrTitle
  179.     '
  180.     ' Load the ListBox with the program manager groups.
  181.     '
  182.     If TreatAsWin95() Then
  183.         LoadW95Groups
  184.     Else
  185.         LoadProgManGroups
  186.     End If
  187.     '
  188.     ' Initialize the Program Group textbox with the
  189.     ' default group selected in the list box.
  190.     '
  191.     txtGroup.Text = lstGroups.List(lstGroups.ListIndex)
  192. End Sub
  193. Private Sub lstGroups_Click()
  194.     txtGroup.Text = lstGroups.List(lstGroups.ListIndex)
  195. End Sub
  196. Private Sub txtGroup_Change()
  197.     cmdContinue.Enabled = Len(Trim(txtGroup.Text)) > 0
  198. End Sub
  199. Sub LoadProgManGroups()
  200. ' This routine uses DDE to talk to Program Manager
  201. ' to retrieve a list of all the groups it manages.
  202. ' It should only be called if the shell is NT 3.51.
  203. ' If it is Win95 or NT4, call LoadW95Groups()
  204. ' instead.
  205. ' Special strings used in this routine.  Do not
  206. ' localize these strings.
  207.     Const strPROGMANLINKTOPIC = "ProgMan|Progman"
  208.     Const strPROGMANLINKITEM = "Progman"
  209.     Const strNDWGROUP = "Quick Access"
  210.     Dim strGroups As String
  211.     Dim strGroup As String
  212.     Dim intOffset As Integer
  213.     Dim intAnchor As Integer
  214.     Dim iGroup As Long
  215.     lblDDE.LinkTopic = strPROGMANLINKTOPIC
  216.     lblDDE.LinkItem = strPROGMANLINKITEM
  217.     lblDDE.LinkMode = 2
  218.     lblDDE.LinkRequest
  219.     On Error Resume Next
  220.     lblDDE.LinkMode = 0
  221.     '
  222.     ' The DDE call just made put the names of all the groups
  223.     ' into the caption property of the lblDDE control.
  224.     ' We want to transfer them to the list box.  They are
  225.     ' separated by CRLF's.
  226.     '
  227.     strGroups = lblDDE.Caption
  228.     intAnchor = 1
  229.     intOffset = InStr(intAnchor, strGroups, CRLF)
  230.     lstGroups.Clear
  231.     Do While intOffset > 0
  232.         strGroup = Mid(strGroups, intAnchor, intOffset - intAnchor)
  233.         '
  234.         ' Norton Desktop for Windows uses the "Quick Access" group
  235.         ' to replace program manager.  Trying to add icons to this
  236.         ' group will fail later when we perform our DDE.linkrequest.
  237.         ' Therefore, skip this group.
  238.         '
  239.         If strGroup <> strNDWGROUP Then
  240.             lstGroups.AddItem strGroup
  241.         End If
  242.         
  243.         intAnchor = intOffset + 2
  244.         intOffset = InStr(intAnchor, strGroups, CRLF)
  245.     Loop
  246.     '
  247.     ' The lstGroups listbox now contains a listing of all the program
  248.     ' manager groups.
  249.     '
  250.     ' Look for the default group in the list and select it.  If it's
  251.     ' not there, add it.
  252.     '
  253.     iGroup = SendMessageString(lstGroups.hwnd, LB_FINDSTRINGEXACT, -1, mstrDefGroup)
  254.     If iGroup = LB_ERR Then
  255.         '
  256.         ' The group doesn't yet exist, add it to the list.
  257.         '
  258.         lstGroups.AddItem mstrDefGroup
  259.         lstGroups.ListIndex = lstGroups.NewIndex
  260.     Else
  261.         lstGroups.ListIndex = iGroup
  262.     End If
  263. End Sub
  264. Sub LoadW95Groups()
  265. ' This routine uses the system registry to
  266. ' retrieve a list of all the subfolders in the
  267. ' \windows\start menu\programs folder.
  268. ' It should only be called if the shell is Win95
  269. ' NT4.  If it is NT 3.51, call LoadProgManGroups()
  270. ' instead.
  271.     Dim strFolder As String
  272.     Dim iFolder As Integer
  273.     mstrProgramsPath = strGetProgramsFilesPath()
  274.     strFolder = Dir(mstrProgramsPath, vbDirectory)   ' Retrieve the first entry.
  275.     lstGroups.Clear
  276.     Do While strFolder <> ""
  277.         '
  278.         ' Ignore the current directory and the encompassing directory.
  279.         '
  280.         If strFolder <> "." And strFolder <> ".." Then
  281.             '
  282.             ' Verify that we actually got a directory and not a file.
  283.             '
  284.             If (GetAttr(mstrProgramsPath & strFolder) And vbDirectory) = vbDirectory Then
  285.                 '
  286.                 ' We got a directory, add it to the list.
  287.                 '
  288.                 lstGroups.AddItem strFolder
  289.             End If
  290.         End If
  291.         '
  292.         ' Get the next subfolder in the Programs folder
  293.         '
  294.         strFolder = Dir
  295.     Loop
  296.     '
  297.     ' The lstGroups listbox now contains a listing of all the Programs
  298.     ' subfolders (the groups).
  299.     '
  300.     ' Look for the default folder in the list and select it.  If it's
  301.     ' not there, add it.
  302.     '
  303.     iFolder = SendMessageString(lstGroups.hwnd, LB_FINDSTRINGEXACT, -1, mstrDefGroup)
  304.     If iFolder = LB_ERR Then
  305.         '
  306.         ' The group doesn't yet exist, add it to the list.
  307.         '
  308.         lstGroups.AddItem mstrDefGroup
  309.         lstGroups.ListIndex = lstGroups.NewIndex
  310.     Else
  311.         lstGroups.ListIndex = iFolder
  312.     End If
  313. End Sub
  314. Public Property Get GroupName(frm As Form, strDefGroup As String) As String
  315.     mstrDefGroup = strDefGroup
  316.     Set mfrm = frm
  317.     If gfNoUserInput = True Then
  318.         mstrGroup = mstrDefGroup
  319.         If Not fCreateProgGroup() Then
  320.             ExitSetup frmSetup1, gintRET_FATAL
  321.         End If
  322.     Else
  323.         Me.Show vbModal
  324.     End If
  325.     GroupName = mstrGroup
  326. End Property
  327. Private Sub txtGroup_GotFocus()
  328.     txtGroup.SelStart = 0
  329.     txtGroup.SelLength = 32767
  330. End Sub
  331.