Hi,
the filter functionality in CommonDialog has not been implemented yet in the current Jabaco framework.
The filter property is CommonDialog ignored for the time being.
See http://code.google.com/p/jabacoframework/source/browse/trunk/Framework/src/VB/CommonDialog.jsrc.
Provided, the filter works, it should be used as follows:
Greetings!
A1880
the filter functionality in CommonDialog has not been implemented yet in the current Jabaco framework.
The filter property is CommonDialog ignored for the time being.
See http://code.google.com/p/jabacoframework/source/browse/trunk/Framework/src/VB/CommonDialog.jsrc.
Provided, the filter works, it should be used as follows:
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
Public Sub Command1_Click() Dim fileName As String With CommonDialog1 .Filter = "" ' Load filters. AddFilter CommonDialog1, "Text Files", "*.txt" AddFilter CommonDialog1, "Graphic Files", _ "*.bmp;*.gif;*.jpg" AddFilter CommonDialog1, "All Files", "*.*" .ShowOpen True fileName = .FileName End With MsgBox fileName End Sub ' Add a filter to the dialog in an easy way. ' from www.vb-helper.com/howto_add_commondialog_filters.html Private Sub AddFilter(ByVal dlg As CommonDialog, _ ByVal filter_title As String, ByVal filter_value As String) Dim txt As String txt = dlg.Filter If Len(txt) > 0 Then txt = txt & "|" txt = txt & filter_title & " (" & filter_value & ")|" & _ filter_value dlg.Filter = txt End Sub |
Greetings!
A1880
Hi,
Yes it's true the Filter-property was not implemented until now.
All Jabaco controls are based on the Swing-framework. The exception proves the rule, the CommonDialog-control is based on java#awt#FileDialog. This is because the security-manager (that plays a role when making an applet) does not like Filedialogs anyway. So Manuel decided to prefer the control that looks more like the original CommonDialog-control because the java#awt#Filedialog is based on the windows-intrinsic comdlg32.dll-control.
The problem behind FileNameFilter more again is platform independency:
in other operating-systems like MAC-OS file-extensions does not play the role like in windows.
in fact files on the Apple have a certain filestamp included that help to identify the type of the file.
More over the problem is also language dependent. In Java you need to implement a class for every type of FilenameFilter but In Java you have innerclasses.
If you like to use the javax#swing#JFileChooser control I have a solution:
Class: CCommonDialog
greetings
OlimilO
Yes it's true the Filter-property was not implemented until now.
All Jabaco controls are based on the Swing-framework. The exception proves the rule, the CommonDialog-control is based on java#awt#FileDialog. This is because the security-manager (that plays a role when making an applet) does not like Filedialogs anyway. So Manuel decided to prefer the control that looks more like the original CommonDialog-control because the java#awt#Filedialog is based on the windows-intrinsic comdlg32.dll-control.
The problem behind FileNameFilter more again is platform independency:
in other operating-systems like MAC-OS file-extensions does not play the role like in windows.
in fact files on the Apple have a certain filestamp included that help to identify the type of the file.
More over the problem is also language dependent. In Java you need to implement a class for every type of FilenameFilter but In Java you have innerclasses.
If you like to use the javax#swing#JFileChooser control I have a solution:
Class: CCommonDialog
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
Private myInitDir As String Private myFilter As String Private myIsCanceled As Boolean Private myFile As File Private myFiles() As File Public Property Get InitDir() As String InitDir = myInitDir End Property Public Property Let InitDir(value As String) myInitDir = value End Property Public Property Get Filter() As String Filter = myFilter End Property Public Property Let Filter(value As String) myFilter = value End Property Public Property Get FileName() As String FileName = myFile.getAbsolutePath End Property Public Property Let FileName(value As String) myFile = New File(value) End Property Public Property Get FileFile() As File FileFile = myFile End Property Public Function getFiles() As File() getFiles = myFiles End Function Public Property Get IsCanceled() As Boolean IsCanceled = myIsCanceled End Property Public Sub ShowOpen() Dim ofd As javax#swing#JFileChooser If Len(myInitDir) > 0 Then ofd = New javax#swing#JFileChooser(myInitDir) Else ofd = New javax#swing#JFileChooser End If If myFile <> Nothing Then ofd.setSelectedFile(myFile) End If If Len(myFilter) > 0 Then Call AddFilters(ofd) End If ofd.showOpenDialog(Nothing) myFile = ofd.getSelectedFile If myFile = Nothing Then myIsCanceled = True Else myFiles = ofd.getSelectedFiles End If End Sub Private Sub AddFilters(fd As javax#swing#JFileChooser) Dim s() As String Dim i As Integer Dim description As String Dim ext As String s() = Split(myFilter, "|") For i = 0 To Ubound(s) Step 2 If (i + 1) <= Ubound(s) Then description = s(i) ext = s(i + 1) If Len(ext) > 0 Then AddFilter(fd, description, ext) End If End If Next End Sub Private Sub AddFilter(fd As javax#swing#JFileChooser, description As String, ext As String) Dim extensions() As String Dim jext As java#lang#String = ext If jext.contains("*.") Then jext = Replace(ext, "*.", "") End If If jext.contains(";") Then extensions = Split(jext, ";") Else ReDim extensions(0) extensions(0) = jext End If fd.addChoosableFileFilter(New javax#swing#filechooser#FileNameExtensionFilter(description, extensions())) End Sub |
greetings
OlimilO
yes, the javax#swing#JFileChooser looks very similar to the original CommonDialog-control
Quoted
The two dialogs look the same
But let's have a second look:
* the swing-dialog has not the same context-menu (right-mouse click) than the awt-dialog has
* the swing-dialog is selfdrawn, this is the reason why it looks the same as the WinXP-control under Win-Vista
in fact true is also, that also the awt-FileDialog does not completely look like the CommonDialog-Control under Win-Vista. But this is true for Open-/SaveFileDialog in every program that comes out of comdlg32.dll and uses a callback-function.
(additional info: a callback-function e.g. must be used to position the dialog in the middle of the screen)
OlimilO
Similar threads
-
Tips, Tricks, Samples & Tutorials »-
db2000 lightchat
(Feb 10th 2009, 5:47pm)
