- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
I want to get a ToolTip to work when the mouse is over a button in a modeless dialog.
I searched the forum before and I got an old example byJugoslav Dujic, but it doesnt work in my program. First, the code that I use:
!=======================================
...
hInst=GetModuleHandle(NULL)
write(tempstring,'(A)') 'Startet die Berechnung'C
Rect=T_RECT(0,0,0,0)
hTooltip=CreateWindowEx(WS_EX_TOPMOST, "TOOLTIPS_CLASS32"C, ""C, TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, dlgMain%hwnd, NULL, hInst, NULL)
hHook=SetWindowsHookEx(WH_GETMESSAGE, LOC(HookProc), NULL, GetCurrentThreadId())
TI=T_TTTOOLINFO(32, TTF_IDISHWND, dlgMain%hWnd,GetDlgItem(dlgMain%hWnd, IDC_BUTTON_Start), Rect, 0,LOC(tempstring), 0)
l=SendMessage(hTooltip,TTM_ADDTOOL,0,LOC(TI))
...
Rect=T_RECT(0,0,0,0)
hTooltip=CreateWindowEx(WS_EX_TOPMOST, "TOOLTIPS_CLASS32"C, ""C, TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, dlgMain%hwnd, NULL, hInst, NULL)
hHook=SetWindowsHookEx(WH_GETMESSAGE, LOC(HookProc), NULL, GetCurrentThreadId())
TI=T_TTTOOLINFO(32, TTF_IDISHWND, dlgMain%hWnd,GetDlgItem(dlgMain%hWnd, IDC_BUTTON_Start), Rect, 0,LOC(tempstring), 0)
l=SendMessage(hTooltip,TTM_ADDTOOL,0,LOC(TI))
...
!===========================================================
INTEGER(4) FUNCTION HookProc(hTooltip,hHook,nCode,wParam,lParam)
!DEC$ATTRIBUTES STDCALL:: HookProc
USE DFWIN
IMPLICIT NONE
INTEGER,INTENT(IN):: hTooltip,hHook,nCode,wParam,lParam
INTEGER:: iSt
TYPE(T_MSG):: Msg,MsgOut
POINTER(pMsg,Msg)
INCLUDE "Resource.fd"
pMsg=lParam
SELECT CASE (Msg%Message)
CASE (WM_MOUSEMOVE,WM_LBUTTONDOWN,WM_LBUTTONUP,WM_RBUTTONDOWN,
$WM_RBUTTONUP)
MsgOut%lParam = Msg%lParam
MsgOut%wParam = Msg%wParam
MsgOut%Message = Msg%Message
MsgOut%hwnd = Msg%Hwnd
iSt=SendMessage(hTooltip,TTM_RELAYEVENT,0,LOC(MsgOut))
END SELECT
HookProc=CallNextHookEx(hHook,nCode,wParam,lParam)
END FUNCTION HookProc
!DEC$ATTRIBUTES STDCALL:: HookProc
USE DFWIN
IMPLICIT NONE
INTEGER,INTENT(IN):: hTooltip,hHook,nCode,wParam,lParam
INTEGER:: iSt
TYPE(T_MSG):: Msg,MsgOut
POINTER(pMsg,Msg)
INCLUDE "Resource.fd"
pMsg=lParam
SELECT CASE (Msg%Message)
CASE (WM_MOUSEMOVE,WM_LBUTTONDOWN,WM_LBUTTONUP,WM_RBUTTONDOWN,
$WM_RBUTTONUP)
MsgOut%lParam = Msg%lParam
MsgOut%wParam = Msg%wParam
MsgOut%Message = Msg%Message
MsgOut%hwnd = Msg%Hwnd
iSt=SendMessage(hTooltip,TTM_RELAYEVENT,0,LOC(MsgOut))
END SELECT
HookProc=CallNextHookEx(hHook,nCode,wParam,lParam)
END FUNCTION HookProc
!===========================================================
I tried it in two different ways: First I inserted the CreateWindowEx part directly after call dlgmodeless(dlg), but then nothing happens. Then I inserted it in the dlg_init part of the dialog, but then the program crashes (but later on, not when these functions are being called).
When I debug the lines, the programs never gets to the HookProc function.
Does anyone has in idea or a better solution?
Thanks in advance,
Markus
@jugaslav: When you fixed it or programmed it in your XFT library; Im not allowed to use 3rd party code in my program. You know, company standards ;-)
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh my. Ages have passed since I posted that, and there's a missing part where something is actually written into the tooltip text (not that I remember :-) ). About the most I remember about that code is my remark that tooltip handling in Win32 is so bloated that I hadn't been sure what the code actually did, only that it worked :-).
Before I even start to tackle this, I'll suggest few alternative methods:
1) If it's supposed to be a help feature, the MS-recommended way is to use "context help" feature, with help button [?] on the dialog. DialogTest sample and cleaner XContextHelp demonstrate that. Although they use XFLOGM/Xeffort, they can easily be adapted to Win32 or DFLOGM-based ones.
2) It's far easier to implement tooltips on the toolbars than on regular buttons (but far more difficult to handle toolbars than buttons in DFLOGM environment). Many people used 1-button toolbars to emulate "cool-looking" buttons and/or implement tooltips
3) If 1) and 2) are out, I'll start digging.
Before I even start to tackle this, I'll suggest few alternative methods:
1) If it's supposed to be a help feature, the MS-recommended way is to use "context help" feature, with help button [?] on the dialog. DialogTest sample and cleaner XContextHelp demonstrate that. Although they use XFLOGM/Xeffort, they can easily be adapted to Win32 or DFLOGM-based ones.
2) It's far easier to implement tooltips on the toolbars than on regular buttons (but far more difficult to handle toolbars than buttons in DFLOGM environment). Many people used 1-button toolbars to emulate "cool-looking" buttons and/or implement tooltips
3) If 1) and 2) are out, I'll start digging.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The attached code shows a complete example of how to implement a dynamic tooltip, where the message is (re)formed prior to display each time the tooltip is invoked by a mouseover; static (unvarying) tooltip messages are much easier. The example uses a child window, but you can easily change that for your button's handle.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page