Print Page | Close Window

howto handle browse folder,open,save dialog

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Suite Pro
Forum Description: Topics Related to Codejock Suite Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=19857
Printed Date: 27 September 2024 at 11:15pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: howto handle browse folder,open,save dialog
Posted By: Developerx
Subject: howto handle browse folder,open,save dialog
Date Posted: 13 June 2012 at 7:05pm

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




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net