Windows XP or later.
Note: In order for EM_HIDEBALLOONTIP to function correctly users must not
have disabled the "Enable balloon tip" setting on the system. Using
TweakUI for XP, this is located under the Taskbar group of options. It is
also directly accessible as a registry entry under HKEY_CURRENT_USER \
Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced at
the key "EnableBalloonTips"=dword:00000001 (1 to enable, 0 to disable). |
Like
text box balloon tips (SendMessage: Add Balloon Tips to a Text Box),
combo tips for Combo styles 0 or 1 can be displayed by using SendMessage
after obtaining the hwnd to the edit portion of the combo control. And
like the text/rich text version, pretty well the same functionality
applies.
In a combo, the tip always points to start of the combo edit box
regardless of the current cursor position within the control. Like the
text version, it dismissed by either clicking on it, by moving focus to a control
other than the control the tip is assigned to, or by typing into the edit
control. A form can not show more than one tip at a time, and if
the tip is repeatedly shown, the previous tip is destroyed first. Tips
never get focus, and there is no message sent when the tip is dismissed.
If the tip is displayed up to the system timeout value for tool tips, it
automatically disappears leaving focus on the control. In addition, the EM_HIDEBALLOONTIP message (wparam=0, lparam=ByVal 0) can be sent
from a timer to dismiss a tip at any time via code.
Text/Combo balloon tips are only available under Windows XP or later. In order
to develop, see and test the balloon tip for combos, the IDE must also have a manifest as outline at
Manifests: Make the VB IDE use Windows XP Styles .
Furthermore, in order for the tip to appear in a distributed app, the
user must be running XP and
the
application must be distributed with a manifest file to enable the XP
styles in the VB application (also detailed on that page).
|
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Const ECM_FIRST As Long = &H1500
Private Const EM_SHOWBALLOONTIP As Long = (ECM_FIRST + 3)
Private Const EM_HIDEBALLOONTIP As Long = (ECM_FIRST + 4)
Private Type EDITBALLOONTIP
cbStruct As Long
pszTitle As String
pszText As String
ttiIcon As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type COMBOBOXINFO
cbSize As Long
rcItem As RECT
rcButton As RECT
stateButton As Long
hwndCombo As Long
hwndEdit As Long
hwndList As Long
End Type
Private Declare Function GetComboBoxInfo Lib "user32" _
(ByVal hwndCombo As Long, _
CBInfo As COMBOBOXINFO) As Long
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function InitCommonControls Lib "comctl32" () As Long
Private Sub Form_Initialize()
'InitCommonControls must be called
'before the interface is created,
'so calling in the Load event is
'often too late. Placing the call in
'either the application's Sub Main
'entry point, or in the Initialize
'allows the XP styles to be applied.
InitCommonControls
End Sub
Private Sub Form_Load()
Command1.Caption = "Show Tip"
Command1.TabIndex = 0
Combo1.Text = "Florida"
End Sub
Private Sub Command1_Click()
Dim ebt As EDITBALLOONTIP
Dim hEdit As Long
hEdit = GetComboEditHandle(Combo1)
With ebt
.cbStruct = Len(ebt)
.pszTitle = StrConv("US Vacations", vbUnicode)
.pszText = StrConv("Select your holiday destination", vbUnicode)
.ttiIcon = 1
End With
Call SendMessage(hEdit, EM_SHOWBALLOONTIP, 0&, ebt)
End Sub
Private Function GetComboEditHandle(ctl As ComboBox) As Long
Dim CBI As COMBOBOXINFO
CBI.cbSize = Len(CBI)
Call GetComboBoxInfo(ctl.hwnd, CBI)
GetComboEditHandle = CBI.hwndEdit
End Function
|