Library code snippets
Fit Filenames Into a Specified Width
By Kym Manson, published on 15 Jul 2002
You will need: Command1 and Label1.
' In general declarations
Private Declare Function PathCompactPath Lib "shlwapi" Alias "PathCompactPathA" (ByVal hDC As Long, ByVal lpszPath As String, ByVal dx As Long) As Long
' On a Form
Private Sub Command1_Click()
Dim lhDC As Long, lCtlWidth As Long
Dim FileSpec As String
FileSpec = "C:\MyFolder\VisualBasic\MyReallyWayTooLongFolderName\ButWhoCares\IhaveTheAPI.doc"
Me.ScaleMode = vbPixels
lCtlWidth = Label1.Width - Me.DrawWidth
lhDC = Me.hDC
PathCompactPath lhDC, FileSpec, lCtlWidth
Label1.Caption = FileSpec
End Sub
Click the button and see that the FileSpec variable is shortened to fit inside the label1's width.
Related articles
Related discussion
-
Problem with migration to C# (CoCreateInstanceEx)
by LRollison (1 replies)
-
VB6 Problem Creating Shortcuts
by rb1177 (0 replies)
-
how can i open a file
by kyawswarhtun (0 replies)
-
how to save any one form what i want?
by blackguy (5 replies)
-
Build an MP3 Player
by soybees (4 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
You're too damm clever...............very good
This thread is for discussions of Fit Filenames Into a Specified Width.