home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CommonDial18020462001.psc / Form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-04-07  |  7.7 KB  |  238 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Example"
  5.    ClientHeight    =   5400
  6.    ClientLeft      =   45
  7.    ClientTop       =   390
  8.    ClientWidth     =   5175
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   5400
  13.    ScaleWidth      =   5175
  14.    StartUpPosition =   3  'Windows Default
  15.    Begin VB.Frame Frame2 
  16.       Caption         =   "Common Dialog"
  17.       Height          =   2535
  18.       Left            =   120
  19.       TabIndex        =   8
  20.       Top             =   2760
  21.       Width           =   4935
  22.       Begin PrjExample.OpenImage OpenImage1 
  23.          Left            =   4320
  24.          Top             =   1200
  25.          _extentx        =   847
  26.          _extenty        =   847
  27.       End
  28.       Begin VB.CommandButton Command1 
  29.          Caption         =   "Open Images"
  30.          Height          =   375
  31.          Left            =   240
  32.          TabIndex        =   12
  33.          Top             =   480
  34.          Width           =   2175
  35.       End
  36.       Begin VB.TextBox Text1 
  37.          Height          =   285
  38.          Left            =   240
  39.          TabIndex        =   11
  40.          Top             =   1920
  41.          Width           =   4215
  42.       End
  43.       Begin VB.CommandButton Command2 
  44.          Caption         =   "Open Files"
  45.          Height          =   375
  46.          Left            =   2520
  47.          TabIndex        =   10
  48.          Top             =   480
  49.          Width           =   1935
  50.       End
  51.       Begin VB.CommandButton Command3 
  52.          Caption         =   "Save File"
  53.          Height          =   375
  54.          Left            =   240
  55.          TabIndex        =   9
  56.          Top             =   960
  57.          Width           =   2175
  58.       End
  59.       Begin VB.Label Label3 
  60.          Caption         =   "Returned path :"
  61.          Height          =   255
  62.          Left            =   240
  63.          TabIndex        =   13
  64.          Top             =   1560
  65.          Width           =   2055
  66.       End
  67.    End
  68.    Begin VB.Frame Frame1 
  69.       Caption         =   "Browse for Folders"
  70.       Height          =   2655
  71.       Left            =   120
  72.       TabIndex        =   0
  73.       Top             =   0
  74.       Width           =   4935
  75.       Begin VB.CommandButton cmdBrowse 
  76.          Caption         =   "Show Browse for Folder dialog"
  77.          Height          =   375
  78.          Left            =   720
  79.          TabIndex        =   5
  80.          Top             =   1200
  81.          Width           =   3255
  82.       End
  83.       Begin VB.CheckBox Check1 
  84.          Caption         =   "Show Recurse Checkbox"
  85.          Height          =   255
  86.          Left            =   2280
  87.          TabIndex        =   4
  88.          Top             =   360
  89.          Value           =   1  'Checked
  90.          Width           =   2295
  91.       End
  92.       Begin VB.CheckBox Check2 
  93.          Caption         =   "Show Create Folder button"
  94.          Enabled         =   0   'False
  95.          Height          =   255
  96.          Left            =   2280
  97.          TabIndex        =   3
  98.          Top             =   720
  99.          Value           =   1  'Checked
  100.          Width           =   2415
  101.       End
  102.       Begin VB.OptionButton Option1 
  103.          Caption         =   "Open  Mode"
  104.          Height          =   255
  105.          Left            =   480
  106.          TabIndex        =   2
  107.          Top             =   360
  108.          Value           =   -1  'True
  109.          Width           =   1575
  110.       End
  111.       Begin VB.OptionButton Option2 
  112.          Caption         =   "Save Mode"
  113.          Height          =   255
  114.          Left            =   480
  115.          TabIndex        =   1
  116.          Top             =   720
  117.          Width           =   1695
  118.       End
  119.       Begin PrjExample.BFFC BFFC1 
  120.          Left            =   4440
  121.          Top             =   2160
  122.          _extentx        =   556
  123.          _extenty        =   503
  124.       End
  125.       Begin VB.Label Label1 
  126.          Height          =   255
  127.          Left            =   120
  128.          TabIndex        =   7
  129.          Top             =   1680
  130.          Width           =   4335
  131.       End
  132.       Begin VB.Label Label2 
  133.          Height          =   255
  134.          Left            =   120
  135.          TabIndex        =   6
  136.          Top             =   2040
  137.          Width           =   4215
  138.       End
  139.    End
  140. Attribute VB_Name = "Form1"
  141. Attribute VB_GlobalNameSpace = False
  142. Attribute VB_Creatable = False
  143. Attribute VB_PredeclaredId = True
  144. Attribute VB_Exposed = False
  145. 'Even though it meant duplicating some declares/subs
  146. 'I have kept code separate so you should be able to
  147. 'compile 2 controls
  148. '1.OpenImage.ocx (OpenImage.ctl + CmnDialog.bas)
  149. '2.BBFC.ocx (BBFC.ctl + frmButton + ModBrowse.bas)
  150. 'Both these controls could be improved and have more
  151. 'functions added to them, but work quite well
  152. 'in their current state.
  153. 'For those interested in modifying MS controls there
  154. 'are a couple of sites that provide freeware DLLs or
  155. 'controls that achieve similar functionality.
  156. '(I'm stubborn enough to insist on writing my own)
  157. 'http://vbaccelerator.com/
  158. 'http://www.mvps.org/ccrp/
  159. '***************************************************
  160. '***********Browse for Folder Example***************
  161. '***************************************************
  162. Private Sub cmdBrowse_Click()
  163. Dim temp As String
  164. With BFFC1
  165.     .ParentForm = Me.hwnd 'Browse for folder needs the calling forms handle
  166.     .InitDir = "C:\windows\desktop"
  167.     .ShowCreate = Check2.Value
  168.     .ShowRecurse = Check1.Value
  169.     .Title = "Test"
  170.     'If you are allowing the user to select a path
  171.     'to open files, you dont need a 'Create new folder' option
  172.     'Similarly, if you are allowing the user to select a path
  173.     'to save files to, you dont need a 'Recurse' checkbox.
  174.     If Option1.Value = True Then
  175.         temp = .OpenBrowse
  176.     Else
  177.         temp = .SaveBrowse
  178.     End If
  179. End With
  180. If temp = "" Then
  181.     Label1 = "User Cancelled"
  182.     Label2 = ""
  183.     Label1 = temp
  184.     'The DoRecurse property returns the users desire to
  185.     'recurse folders for the .OpenBrowse method - it's
  186.     'up to you to provide code for recursion from the
  187.     'returned path
  188.     If BFFC1.DoRecurse Then
  189.         Label2 = "User requests recursion"
  190.     Else
  191.         Label2 = ""
  192.     End If
  193. End If
  194. End Sub
  195. Private Sub Option1_Click()
  196. Check1.Enabled = Option1.Value
  197. Check2.Enabled = Not Check1.Enabled
  198. End Sub
  199. Private Sub Option2_Click()
  200. Check2.Enabled = Option2.Value
  201. Check1.Enabled = Not Check2.Enabled
  202. End Sub
  203. '***************************************************
  204. '***************Common Dialog Example***************
  205. '***************************************************
  206. Private Sub Command1_Click()
  207. 'Calls the standard Commondialog for open files
  208. 'with selected pictures shown in a panel below
  209. 'the main dialog
  210. '.ParentForm is optional - causes the dialog to be modal-usually desirable
  211. 'Other properties, with the exception of .Filter and .Flags, are also valid
  212. 'for the .OpenImage function
  213. OpenImage1.ParentForm = Me.hwnd
  214. Text1.Text = OpenImage1.OpenImage
  215. End Sub
  216. Private Sub Command2_Click()
  217. 'Calls the standard Commondialog for open files
  218. With OpenImage1
  219.     .ParentForm = Me.hwnd
  220.     .Filter = "All Files " + Chr(0) + "*.*"
  221.     .Flags = 5
  222.     .InitDir = "C:\windows\desktop"
  223.     .Title = "Fred all files"
  224.     Text1.Text = .OpenFile
  225. End With
  226. End Sub
  227. Private Sub Command3_Click()
  228. 'Calls the standard Commondialog for save files
  229. With OpenImage1
  230.     .ParentForm = Me.hwnd
  231.     .Filter = "All Files " + Chr(0) + "*.*"
  232.     .Flags = 5
  233.     .InitDir = "C:\windows\desktop"
  234.     .Title = "Fred save files"
  235.     Text1.Text = .SaveFile
  236. End With
  237. End Sub
  238.