Date: 02-16-2022
Return to Index
created by gbSnippets
'%TBSTYLE_TOOLTIPS style when creating the toolbar
'%WM_NOTIFY message - test for %TTN_NEEDTEXT
'Nmhdr AND TOOLTIPTEXT structures passed in WM_NOTIFY to determine
'which Toolbar Button needs the tooltip Text.
'.hwndFrom member of the Nmhdr structure will contain the handle for
'the tooltip control created by the toolbar.
'You can test its Class Name to see if it is a tooltip control or get the handle
'from the Toolbar and compare it, to determine ff the message is from your
'toolbars tooltip and notanother.
'the .idfrom member of Nmhdr should contain the Id number
'for the Toolbar Button which requires the tooltip Text.
'Primary Code:
'Credit: Kev Peel
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "win32api.inc"
#Include "commctrl.inc"
%ID_TOOLBAR = 100
%IDC_NEW = 1000
%IDC_OPEN = 2000
%IDC_SAVE = 3000
CallBack Function dlgProc
Select Case Cbmsg
Case %WM_NOTIFY
Local pNMHDR As Nmhdr Ptr
pNMHDR = Cblparam
Select Case @pNMHDR.Code
Case %TTN_GETDISPINFO
Local pTTT As TOOLTIPTEXT Ptr
pTTT = Cblparam
Select Case @pTTT.hdr.idFrom
Case %IDC_NEW
@pTTT.@lpszText = "File new..." + $Cr + "Even two lines possible!"
Case %IDC_OPEN
@pTTT.@lpszText = "Open a File"
Case %IDC_SAVE
@pTTT.@lpszText = "Saves a File"
End Select
End Select
Case %WM_SIZE
Control Send Cbhndl, %ID_TOOLBAR, Cbmsg, Cbwparam, Cblparam
End Select
End Function
Function PBMain
Dim hDlg As Dword, tbb(0 To 2) As TBBUTTON, hToolBar As Dword
Dialog New 0, "Drake Software Client Write-Up", 0, 0, 85 , 100 , %WS_POPUP Or _
%WS_BORDER Or %WS_DLGFRAME Or %WS_THICKFRAME Or %WS_SYSMENU Or %WS_CAPTION Or %WS_MINIMIZEBOX Or _
%WS_MAXIMIZEBOX Or %WS_CLIPSIBLINGS Or %WS_CLIPCHILDREN Or %WS_VISIBLE _
Or %DS_CENTER Or %DS_3DLOOK Or %DS_NOFAILCREATE Or _
%DS_SETFONT, %WS_EX_WINDOWEDGE Or %WS_EX_CONTROLPARENT Or %WS_EX_LEFT _
Or %WS_EX_LTRREADING Or %WS_EX_RIGHTSCROLLBAR, To hDlg
tbb(0).idCommand = %IDC_NEW
tbb(0).fsState = %TBSTATE_ENABLED
tbb(0).fsStyle = %TBSTYLE_BUTTON
tbb(0).iBitmap = 6
tbb(1).idCommand = %IDC_OPEN
tbb(1).fsState = %TBSTATE_ENABLED
tbb(1).fsStyle = %TBSTYLE_BUTTON
tbb(1).iBitmap = 7
tbb(2).idCommand = %IDC_SAVE
tbb(2).fsState = %TBSTATE_ENABLED
tbb(2).fsStyle = %TBSTYLE_BUTTON
tbb(2).iBitmap = 8
hToolbar = CreateToolbarEx(hDlg, %WS_CHILD Or %TBSTYLE_TOOLTIPS Or %TBSTYLE_FLAT Or %TBSTYLE_TRANSPARENT, _
%ID_TOOLBAR, 0, %NULL, 0, tbb(0), UBound(tbb)+1, 16, 16, 0, 0, Len(TBBUTTON))
Dim tbab As TBADDBITMAP
tbab.hInst = %HINST_COMMCTRL
tbab.nID = %IDB_STD_SMALL_COLOR
SendMessage hToolbar, %TB_ADDBITMAP, 0, VarPTR(tbab)
ShowWindow hToolBar, %SW_SHOW
Dialog Show Modal hDlg Call dlgProc
End Function
'gbs_00290
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm