<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-7">
<META content="MSHTML 6.00.6000.16643" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>
<DIV><FONT face=Arial size=2>Ok, i did the tests and it came up that i was just
misusing ClientToScreen and ScreenToClient in TForm in my test (i expected it to
modify the point i was passing instead of returning a new point), so that wasn't
the reason the message isn't sent to the correct control.</FONT></DIV></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=badsector@slashstone.com
href="mailto:badsector@slashstone.com">Kostas Michalopoulos</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=lazarus@lazarus.freepascal.org
href="mailto:lazarus@lazarus.freepascal.org">General mailing list</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, June 05, 2008 3:00
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Lazarus] OnMouseWheel[Down/Up]
support in TControl (patch included)</DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>I'm making a 3D design program and i use
TPaintBox to draw the 2D viewports. I want to make the program zoom in/out
using the wheel, however although all other mouse events are supported
OnMouseWheelUp/Down are not. I noticed that the TPaintBox is a descendant of
TGraphicControl, which doesn't provide these events and TWinControl is where
the code for these is written. So i tried to move the code from TWinControl up
to TControl so all controls can receive them, much like they receive
OnMouseDown/Up etc. But it didn't worked, because after some checks i figured
out that the message wasn't sent to the correct control (there wasn't done
proper translation of the mouse coordinates from screen to client space). So i
added a couple of lines in WMMouseWheel function in TControl (moved from
TWinControl) that re-checks for the proper control under mouse using
FindLCLControl and calls the DoMouseWheel function of that control (or the
Self control if FindLCLControl returns nil).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This solved the problem and now all TControls can
use OnMouseWheel* events. However while doing my tests i saw that calling
ScreenToClient in a TForm the coordinates remain intact. I am not sure if this
is the original issue of improper translations, since right now i'm way too
tired (spent around four hours trying to fix this) to check, but i might check
it tomorrow (well, also i don't know if this is a bug or a design
decision).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>In any case since i have a properly working
(although a little hacky) patch for making wheel events usable for
non-TWinControls, i'm attaching it. The patch is against SVN revision
</FONT><FONT face=Arial><FONT size=2><FONT
size=2>15308.</FONT></DIV></FONT></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Kostas</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<P>
<HR>
<P></P>
<DIV>_______________________________________________<BR>Lazarus mailing
list<BR>Lazarus@lazarus.freepascal.org<BR><A
href="http://www.lazarus.freepascal.org/mailman/listinfo/lazarus">http://www.lazarus.freepascal.org/mailman/listinfo/lazarus</A></DIV></BLOCKQUOTE></BODY></HTML>