Hello all, I was just in a mode to share some tips howto use CJ commondialog
3 important things i found after testing open with cj commondialog filters, parenthwnd, and capture if user click cancel instead of OK. 1. important use the parentHWND, look in code ; ) 2. Capture if user press cancel , look in code 3. FILTERS , oh those filter often messed up but look in code for using many of them ---------------------------------------------------------------------------------- ' EXAMPLE 'Create 2 buttons, with .caption ... 'name them cmdbrowseinput and cmdbrowseouputdir 'add flatedit1 and flatedit2 ' EXAMPLE how to choose a file Private Sub cmdbrowseinput_Click() Dim whataction As Long Dim filex As String
'important else function correct CommonDialog1.ParentHwnd = Me.hWnd 'set filters CommonDialog1.Filter = "html (.html)|.html|" & "htm (*.htm)|*.htm|" _ & "text (*.txt)|*.txt|" & "JPEG (*.jpg)|*.jpg|" & "ALL (*.*)|*.*|" whataction = CommonDialog1.ShowOpen filex = CommonDialog1.FileName 'this must come after showsave If whataction = 2 Then Me.Caption = "Cancel..." Else Me.Caption = "Ready" 'send result to flatedit1 FlatEdit1.Text = filex End If End Sub
'Example howto browsefolder correct Private Sub cmdbrowseouputdir_Click() Dim whataction As Long Dim filex As String
CommonDialog1.ParentHwnd = Me.hWnd whataction = CommonDialog1.ShowBrowseFolder filex = CommonDialog1.FileName 'this must come after showsave ' Me.Caption = CommonDialog1.FileName If whataction = 2 Then Me.Caption = "Cancel..." Else Me.Caption = "Ready" FlatEdit2.Text = filex End If
End Sub
Example in use
|