View previous topic :: View next topic |
Author |
Message |
rhosking
Joined: 21 Aug 2006 Posts: 14 Location: UK
|
Posted: Fri Oct 06, 2006 9:13 am Post subject: Tooltips |
|
|
Me again
I have a application message filter (Application.addMessageFilter) listening to wm_mousemove and wm_mousewheel messages.
When I add a tooltip to the application I no longer get these messages.
I think this is down to another message filter registered (before mine) by the form class which returns true and thus blocks any other message filters from running.
Could the gotMessage method in Application be modified so it always processes all message filters regardless of their return value then process the 'true' part if any of the message filters returned true. ie....
Code: |
IMessageFilter[] local = filters;
bool filterstop = false;
foreach(IMessageFilter mf; local)
{
// Returning true prevents dispatching.
if(mf.preFilterMessage(msg)) {
filterstop = true;
}
}
if (filterstop) {
Control ctrl;
ctrl = lookupHwnd(msg.hWnd);
if(ctrl)
ctrl.mustWndProc(msg);
return;
}
|
|
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Fri Oct 06, 2006 11:54 am Post subject: Re: Tooltips |
|
|
The Windows tooltips must be blocking those messages at some other level because DFL doesn't add one of those filters for tooltips. |
|
Back to top |
|
|
rhosking
Joined: 21 Aug 2006 Posts: 14 Location: UK
|
Posted: Fri Oct 06, 2006 3:21 pm Post subject: |
|
|
The Form class which does have a message filter tests isDialogMessage (line 2216 in form.d) which when a tooltip is used in the application the filter returns true. If no tooltip is present it returns false.
Since the form's message filter just happens to be the first in the applications filter list it prevents other filters running if it returns true. |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Sun Oct 08, 2006 6:43 am Post subject: |
|
|
I'm not sure I want to do what you're proposing, but here is a way to achieve what you want:
Code: | bool delegate(inout Message)[] msgHandlers;
private class MsgFilterer: IMessageFilter
{
bool preFilterMessage(inout Message m)
{
bool result = false;
foreach(handler; msgHandlers)
{
if(handler(m))
result = true;
}
return result;
}
}
static this()
{
Application.addMessageFilter(new MsgFilterer);
} |
Now handlers should always be called first, even if a message is filtered out. |
|
Back to top |
|
|
rhosking
Joined: 21 Aug 2006 Posts: 14 Location: UK
|
Posted: Sun Oct 08, 2006 6:53 am Post subject: |
|
|
Ah yes that workaround should do the trick. Many thanks! |
|
Back to top |
|
|
|