Private Declare Function PathCompactPath Lib "shlwapi.dll" Alias "PathCompactPathA" _
(ByVal hdc As Long, ByVal lpszPath As String, ByVal dx As Long) As Long
Private Sub Command1_Click()
Dim temp As String, nWidth As Long
temp = Me.Text1.Text & String(256, Chr(0))
nWidth = Me.Picture1.ScaleWidth - 100
Me.Picture1.Line (0, 0)-(nWidth, Me.Picture1.ScaleHeight), vbBlue, BF
Me.Picture1.CurrentX = 0
Me.Picture1.CurrentY = 0
Me.Picture1.ForeColor = vbWhite
Me.Picture1.Print "指定した長さ:" & nWidth & "px"
Call PathCompactPath(Me.Picture1.hdc, temp, nWidth)
Me.Text2.Text = temp
End Sub
Private Sub Form_Load()
Me.Picture1.ScaleMode = 3
Me.Text1.Text = App.Path
End Sub |