Страница: 1 |
|
Вопрос: иконки на рабочий стол
|
Добавлено: 03.09.10 21:40
|
|
Автор вопроса: kvskvs
|
Всем привет
Помогите примерчиком на VB6 !!!
1. Нужно перетаскивать иконки с рабочего стола на форму, с последующим запуском с формы.
2. Желательно перетаскивать на форму названия файлов (например с Total Commander) , с последующим запуском с формы.
Заранее благодарю
Ответить
|
Номер ответа: 1 Автор ответа: Just
Вопросов: 4 Ответов: 330
|
Профиль | | #1
|
Добавлено: 03.09.10 22:46
|
создай пару листбоксов и кинь код в форму
-
- Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
- Dim lCount As Long, sArr() As String, sPath As String, sExt As String
- Dim objShell As Object, objShortcut As Object
- Set objShell = CreateObject("WScript.Shell")
-
- For lCount = 1 To Data.Files.Count
- sPath = Data.Files(lCount)
- sExt = LCase(Right$(sPath, 4))
- If sExt = ".lnk" Then
- Set objShortcut = objShell.CreateShortcut(sPath)
- sPath = objShortcut.TargetPath
- End If
-
- List1.AddItem sPath
- sArr = Split(sPath, "\")
- List2.AddItem sArr(UBound(sArr))
- Next lCount
-
- Set objShortcut = Nothing
- Set objShell = Nothing
- End Sub
Ответить
|
Номер ответа: 6 Автор ответа: Just
Вопросов: 4 Ответов: 330
|
Профиль | | #6
|
Добавлено: 04.09.10 10:56
|
может так?
-
- Option Explicit
-
- Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
- Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
- Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
-
- Dim sPathEXE As String
-
-
- Private Sub Form_Load()
- OLEDropMode = 1
- Picture1.AutoRedraw = True
- End Sub
-
-
- Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
- Dim lCount As Long, sArr() As String, sPath As String, sExt As String
- Dim objShell As Object, objShortcut As Object
- Set objShell = CreateObject("WScript.Shell")
-
- For lCount = 1 To Data.Files.Count
- sPath = Data.Files(lCount)
- sExt = LCase(Right$(sPath, 4))
- If sExt = ".lnk" Then
- Set objShortcut = objShell.CreateShortcut(sPath)
- sPath = objShortcut.TargetPath
- End If
-
- List1.AddItem sPath
- IconToPicture sPath, Picture1
- sPathEXE = sPath
- sArr = Split(sPath, "\")
- List2.AddItem sArr(UBound(sArr))
- Next lCount
-
- Set objShortcut = Nothing
- Set objShell = Nothing
- End Sub
-
-
- Private Sub Picture1_Click()
- Shell sPathEXE, vbNormalFocus
- End Sub
-
-
- Function IconToPicture(sPath As String, xPicture As PictureBox) As Long
- Dim lRet As Long
- xPicture.Picture = LoadPicture()
- xPicture.AutoRedraw = True
- lRet = ExtractIcon(0, sPath, 0)
- IconToPicture = DrawIcon(xPicture.hdc, 0, 0, lRet)
- DestroyIcon lRet
- End Function
Ответить
|
Страница: 1 |
Поиск по форуму