VB Code:
Option Explicit Private Declare Function ExtractFileIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, _ ByVal lpIconPath As String, _ lpiIcon As Long) _ As Long 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 Sub Toolbar1_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single) Dim p As Long Dim i As Long Dim tb As MSComctlLib.Button If Data.GetFormat(vbCFFiles) Then For p = 1 To Data.Files.Count i = GetILIconIndex(Data.Files(p)) Set tb = Toolbar1.Buttons.Add(, , "", , i) tb.ToolTipText = Data.Files(p) Next End If Set tb = Nothing End Sub Private Function GetILIconIndex(ByVal sFile As String) As Long Dim hIcon As Long Dim li As ListImage Picture1.Picture = LoadPicture hIcon = ExtractFileIcon(App.hInstance, sFile, 0&) If hIcon Then Call DrawIcon(Picture1.hdc, 0, 0, hIcon) End If Picture1.Picture = Picture1.Image Set li = ImageList1.ListImages.Add(, , Picture1.Picture) GetILIconIndex = li.Index Picture1.Picture = LoadPicture Set li = Nothing End Function
I'm basically using this code to allow for file shorcuts on a toolbar. The problem is that the tooltips for the buttons seem to be showing up underneath the toolbar's parent form. Any idea why this would be happening?




Reply With Quote