|
-
Nov 14th, 2000, 11:44 PM
#1
Thread Starter
New Member
I am trying to get DOS 8.3 filenames with
a Common Dialog Control.
I have entered the following statements:
CommonDialog1.Flags = cdlOFNNoLongNames
CommonDialog1.ShowOpen
When I get the CommonDialog.Filename
I get long filenames. Do I have to do
something else to make this work?
-
Nov 14th, 2000, 11:53 PM
#2
Why don't you just convert it to ShortFileName?
Code:
Public Declare Function GetShortPathName _
Lib "kernel32" Alias "GetShortPathNameA" (ByVal _
lpszLongPath As String, ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
Public Function GetShortFilename(ByVal sLongFilename As String) As String
'Returns the Short Filename associated w
' ith sLongFilename
Dim lRet As Long
Dim sShortFilename As String
'First attempt using 1024 character buff
' er.
sShortFilename = String$(1024, " ")
lRet = GetShortPathName(sLongFilename, sShortFilename, Len(sShortFilename))
'If buffer is too small lRet contains bu
' ffer size needed.
If lRet > Len(sShortFilename) Then
'Increase buffer size...
sShortFilename = String$(lRet + 1, " ")
'and try again.
lRet = GetShortPathName(sLongFilename, sShortFilename, Len(sShortFilename))
End If
'lRet contains the number of characters
' returned.
If lRet > 0 Then
GetShortFilename = Left$(sShortFilename, lRet)
End If
-
Nov 15th, 2000, 01:11 AM
#3
Fanatic Member
The following code will achieve the effect you are looking for:
Code:
Private Sub Form_Load()
cdl.Filter = "All Files (*.*)|*.*|"
cdl.Flags = cdlOFNNoLongNames Or cdlOFNAllowMultiselect
cdl.ShowOpen
End Sub
This is the quote from the windows help file (for VB5) that provided the answer
Under both Windows NT 4.0 and Windows 95 if you do not choose the cdlOFNAllowMultiselect flag, then both the cdlOFNExplorer and cdlOFNLongNames flags have no effect and are essentially the default.
They don't mention the cdlOFNNoLongNames flag but I tried it and it works, also you have to set a filter or no file names at all will show up.
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Nov 15th, 2000, 04:47 PM
#4
Thread Starter
New Member
Matthew,
I tried your routine, and it worked fine.
Many thanks,
Don
-
Nov 15th, 2000, 05:03 PM
#5
_______
<?>
YoungBuck's code is fine as well. Only drawback I see
is that it list all the files in shortname only and that
might be a bit of a setback if you are looking for a file
called adirtbagdogwebsite and you get it listed as adirtb~1.
(could confuse the user)
Code:
Private Sub Form_Load()
CommonDialog1.Filter = "All Files (*.*)|*.*|"
CommonDialog1.Flags = cdlOFNNoLongNames Or cdlOFNAllowMultiselect
CommonDialog1.ShowOpen
MsgBox CommonDialog1.FileName
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 16th, 2000, 05:38 PM
#6
Thread Starter
New Member
YoungBuck, and HeSaidJoe,
I tried your solution, and they worked well, too.
However, in this case, I don't want the user to
have the option of multiple choice.
I'm certain I can use your solution in future,
so thanks for the help,
Don
-
Nov 16th, 2000, 05:41 PM
#7
_______
<?>
Actually, mine was just an observation.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|