Tooltip demo

Alles over het toepassen van API en DLL's in Liberty BASIC

Moderator: anthonio

Tooltip demo

Berichtdoor Gordon » vr feb 05, 2010 11:23 pm

Hier een demo van het maken van een tooltip.
Code: Selecteer alles
'Tooltip demo
WindowWidth = 280
WindowHeight = 185
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)

button #main.button1,"OK",[button1Click], UL, 60, 57, 120, 25

open "untitled" for window as #main
print #main, "font ms_sans_serif 10"
print #main, "trapclose [Quit]"

'----Begin code for tooltips

hTip=CreateTooltip(Hwnd(#main.button1))
Call AddToolTip Hwnd(#main.button1) , hTip , "Tooltip for ok button"

wait

[Quit]
If IsWindow(hTip) Then Notice "The tooltip exists"
close #main
If Not(IsWindow(hTip)) Then Notice "The tooltip has been destroyed."
end

[button1Click]
wait

sub AddToolTip cHndl, hWnd, text$ 'API call for tooltips
TOOLINFO.uId.struct = cHndl
TOOLINFO.lpszText.struct = text$
callDLL #user32, "SendMessageA",_
hWnd As long, _
1028 As long, _
0 As long, _
TOOLINFO as ptr, _
result as long
end sub

FUNCTION CreateTooltip(hMain)
Struct TOOLINFO, _
cbSize As long, _
uFlags As long, _
hwnd As long, _
uId As long, _
rectLeft As long, _
rectTop As long, _
rectRight As long, _
rectBottom As long, _
hinst As long, _
lpszText As ptr
callDLL #comctl32,"InitCommonControlsEx", _
result as void
TOOLINFO.cbSize.struct = Len(TOOLINFO.struct)
TOOLINFO.uFlags.struct = flags Or 17 'TTF_IDISHWND Or TTF_SUBCLASS
TOOLINFO.hwnd.struct = hMain
callDLL #user32,"CreateWindowExA",_
0 As long, _
"tooltips_class32" As ptr, _
0 As long, style As long, _
_CW_USEDEFAULT As long, _
_CW_USEDEFAULT As long, _
_CW_USEDEFAULT As long, _
_CW_USEDEFAULT As long, _
hMain As long, _
0 As long, _
0 as long, _
0 As long, _
CreateTooltip As Long
END FUNCTION


Function IsWindow(hWnd)
callDll #user32, "IsWindow", hWnd As Ulong, IsWindow As Boolean
End Function


Gordon
Avatar gebruiker
Gordon
Site Admin
 
Berichten: 684
Geregistreerd: zo mei 22, 2005 12:50 am

Keer terug naar API/DLL

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron