Dim IconPos(40) As POINTAPI
Dim lpInitCtrls As tagINITCOMMONCONTROLSEX, hImgList As Long
Dim BeforeIconIndex As Long
Private Sub Command1_Click()
Dim FileName As String, cnt As Long
Dim rc As Long, psfi As SHFILEINFO
Dim x As Long, y As Long
Call InitCommonControlsEx(lpInitCtrls)
DirName = Me.Text1.Text
FileName = "(init)"
cnt = 0
x = -60
y = 80
Do While FileName <> "" And cnt < 40
If FileName = "(init)" Then FileName = Dir(DirName & "\*.exe") Else FileName = Dir
If FileName <> "" Then
Call SHGetFileInfo(DirName & "\" & FileName, FILE_ATTRIBUTES_NORMAL, psfi, Len(psfi), SHGFI_ICON)
rc = ImageList_ReplaceIcon(hImgList, -1, psfi.hIcon)
x = x + 100
If x > Me.ScaleWidth Then x = 40: y = y + 80
IconPos(cnt).x = x
IconPos(cnt).y = y
Call ImageList_Draw(hImgList, rc, Me.hDC, x, y, ILD_NORMAL)
Me.CurrentX = x - 15
Me.CurrentY = y + 35
Me.Print FileName
cnt = cnt + 1
End If
Loop
End Sub
Private Sub Form_Load()
hImgList = ImageList_Create(32, 32, ILC_COLOR32 Or ILC_MASK, 30, 10)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim pos_x As Long, pos_y As Long, lpPoint As POINTAPI
Call GetCursorPos(lpPoint)
Call ScreenToClient(Me.hWnd, lpPoint)
For i = 0 To 40
pos_x = IconPos(i).x
pos_y = IconPos(i).y
If lpPoint.x >= pos_x And lpPoint.x <= pos_x + 32 And _
lpPoint.y >= pos_y And lpPoint.y <= pos_y + 32 Then
Call ImageList_Draw(hImgList, i, Me.hDC, pos_x, pos_y, ILD_BLEND25)
If BeforeIconIndex <> i Then
pos_x = IconPos(BeforeIconIndex).x
pos_y = IconPos(BeforeIconIndex).y
Call ImageList_Draw(hImgList, BeforeIconIndex, Me.hDC, pos_x, pos_y, ILD_NORMAL)
BeforeIconIndex = i
End If
Exit For
End If
Next
End Sub
Private Sub Form_Resize()
Me.Line1(0).X2 = Me.ScaleWidth
Me.Line1(1).X2 = Me.ScaleWidth
Me.Cls
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call ImageList_Destroy(hImgList)
End Sub |