You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Thanks, you're right in that point, but something else was wrong; I even didn't get
a WM_NOTIFY message. In the enumeration function, the line
If lZStr = "STATIC" should be If lZStr <> "STATIC"
(No need to add tips to static controls...)
The TYPE defined in the common control inc file is :
Code:
TYPE TOOLTIPTEXT
hdr AS NMHDR
lpszText AS ASCIIZ PTR
szText AS ASCIIZ * 80
hInst AS LONG
uFlags AS DWORD
END TYPE
Your have defined the sztext member as lpszText (a pointer) and
you are trying to change the pointer to a pointer towards your
asciiz string in your function. When the message returns control
to windows (function ends), your asciiz string which is local will
disappear before Windows can process the string.
The tooltip control is passing a valid ascii string buffer in the
type described above, so you don't need to define your own asciiz
string. You must put data into the asciiz buffer passed to your
dialog procedure, not change it to another buffer.
What's wrong (or missing here)? I don't get tooptips on the buttons
The enumeration function seems to work OK. (Adds all controls to the tooptip)
Code:
#Compile Exe
#Include "win32api.inc"
#Include "commctrl.inc
Global hDlg As Long
Global hTTip As Long
Global hInstance As Long
'=====================/ Enumeration callback /=================================
Function EnumChildProc(ByVal CtrlDlg As Long, param As Long) As Long
Local lTI As TOOLINFO, lZStr As Asciiz * 128
GetClassName CtrlDlg, lzStr, SizeOf(lzStr)
If lzStr = "STATIC" Then
lTI.cbSize = SizeOf(lTI)
lTI.uFlags = %TTF_IDISHWND Or %TTF_SUBCLASS
lTI.hwnd = hDlg
lTI.uID = CtrlDlg
lTI.hInst = hInstance
lTI.lpszText= %LPSTR_TEXTCALLBACK
SendMessage hTTip, %TTM_ADDTOOL, 0, VarPtr(lTI)
End If
Function = 1
End Function
'==============================================================================
Function AddToolTips (ByVal hDlg As Long) As Long
hTTip = CreateWindowEx (0, _
"tooltips_class32", _
ByVal %NULL, _
%WS_POPUP Or %TTS_ALWAYSTIP, _
%CW_USEDEFAULT, _
%CW_USEDEFAULT, _
%CW_USEDEFAULT, _
%CW_USEDEFAULT, _
ByVal hDlg, _
ByVal %NULL, _
GetWindowLong (hDlg, %GWL_HINSTANCE), _
ByVal %NULL)
If hTTip = %FALSE Then Function = 0 : Exit Function
If (EnumChildWindows (hDlg, CodePtr(EnumChildProc), 0)) = 0 Then
Function = %FALSE
Else
Function = %TRUE
End If
End Function
'==============================================================================
CallBack Function MainCb() As Long
Local lTTptr As TOOLTIPTEXT Ptr, lZStr As Asciiz * 64
Select Case CbMsg
Case %WM_NOTIFY
lTTPtr = CbLparam
If @lTTPtr.Hdr.Code = %TTN_NEEDTEXT Then
lZStr = Time$
@lTTPtr.lpszText = VarPtr(lZStr)
End If
End Select
End Function
'==============================================================================
Function WinMain (ByVal CurInst&, ByVal PrvInst&, CmdLine As Asciiz Ptr, _
ByVal CmdShow&) Export As Long
Local lRet As Long
hInstance = CurInst&
InitCommonControls
Dialog New 0, "ToolTip",,,100,100,%WS_OVERLAPPED Or %WS_SYSMENU To hDlg
Control Add Button, hDlg,101,"Button #1",30,10,40,14,%WS_TABSTOP
Control Add Button, hDlg,102,"Button #2",30,30,40,14,%WS_TABSTOP
Control Add Button, hDlg,103,"Button #3",30,50,40,14,%WS_TABSTOP
Control Handle hDlg,101 To lRet
AddToolTips hDlg
Dialog Show Modal hDlg Call MainCb
End Function
Has anybody used 'Control Add ""tooltips_class32".....' instead of
CreateWindowEx to produce tooltips? I've not seen any examples and cannot
get it to work.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: