home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / shbrowse / form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-07-06  |  3.6 KB  |  105 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Example of how to use SHBrowse.dll"
  7.    ClientHeight    =   876
  8.    ClientLeft      =   1080
  9.    ClientTop       =   1476
  10.    ClientWidth     =   5664
  11.    BeginProperty Font 
  12.       Name            =   "MS Sans Serif"
  13.       Size            =   7.8
  14.       Charset         =   0
  15.       Weight          =   700
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    ForeColor       =   &H80000008&
  21.    LinkTopic       =   "Form1"
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    PaletteMode     =   1  'UseZOrder
  25.    ScaleHeight     =   876
  26.    ScaleWidth      =   5664
  27.    StartUpPosition =   2  'CenterScreen
  28.    Begin VB.CommandButton Command3 
  29.       Appearance      =   0  'Flat
  30.       BackColor       =   &H80000005&
  31.       Caption         =   "Browse"
  32.       Default         =   -1  'True
  33.       BeginProperty Font 
  34.          Name            =   "MS Sans Serif"
  35.          Size            =   7.8
  36.          Charset         =   0
  37.          Weight          =   400
  38.          Underline       =   0   'False
  39.          Italic          =   0   'False
  40.          Strikethrough   =   0   'False
  41.       EndProperty
  42.       Height          =   360
  43.       Left            =   4284
  44.       TabIndex        =   0
  45.       Top             =   252
  46.       Width           =   1215
  47.    End
  48.    Begin VB.Label Label1 
  49.       BeginProperty Font 
  50.          Name            =   "MS Sans Serif"
  51.          Size            =   7.8
  52.          Charset         =   0
  53.          Weight          =   400
  54.          Underline       =   0   'False
  55.          Italic          =   0   'False
  56.          Strikethrough   =   0   'False
  57.       EndProperty
  58.       Height          =   336
  59.       Left            =   168
  60.       TabIndex        =   1
  61.       Top             =   264
  62.       Width           =   3996
  63.    End
  64. Attribute VB_Name = "Form1"
  65. Attribute VB_GlobalNameSpace = False
  66. Attribute VB_Creatable = False
  67. Attribute VB_PredeclaredId = True
  68. Attribute VB_Exposed = False
  69. Option Explicit
  70. '----------------------------------------------------------
  71. ' GetFolder
  72. '-----------
  73. '   hWnd            The window handle of the calling window
  74. '   DlgCaption      The caption of the label that appears just above the Tree control
  75. '   SelectedPath    The String variable that will return the selected path - if any.
  76. '                   (The string space must be allocated by the calling program)
  77. Private Declare Function GetFolder Lib "SHBrowse.dll" (ByVal hwnd As Long, ByVal DlgCaption As String, ByVal SelectedPath As String) As Long
  78. Private Sub Command2_Click()
  79.     End
  80. End Sub
  81. Private Sub Command3_Click()
  82.     Dim lRet As Long
  83.     Dim DlgCaption As String
  84.     Dim S2 As String
  85.     Dim iPos As Integer
  86. '   Use a fixed length string
  87.     Dim S As String * 256
  88. '   Allocate space for the string now. The DLL expects the
  89. '   memory to have already been allocated for the string
  90. '   that will return the path selected on the Browse Dlg.
  91.     S = String(256, 0)
  92. '   Set the caption that will appear just above the Tree.
  93.     DlgCaption = "Select New Folder"
  94. '   Get the new folder
  95.     lRet = GetFolder(Me.hwnd, DlgCaption, S)
  96.     iPos = InStr(1, S, Chr(0))
  97.     S2 = Left$(S, iPos - 1)
  98.     'MsgBox "Return path is " & S2
  99.     Label1.Caption = S2
  100. End Sub
  101. Private Sub Form_Load()
  102.     ChDrive App.Path
  103.     ChDir App.Path
  104. End Sub
  105.