[DUG] MouseWheel and DBGrid in D6
Rohit Gupta
rohit at cfl.co.nz
Wed May 31 10:54:12 NZST 2006
Wayne,
I was not following the thread so I dont knwo what you were after. However,
I have had mousewheel working in my apps bt overriding the
DoMouseWheel method with the following code in it
if WheelDelta = 0
then { Nothing }
else if WheelDelta < 0
then DoScroll (True,SB_LINEDOWN)
else DoScroll (True,SB_LINEUP);
Result := True;
I do remember that there were some controls that were not calling this
method. For these, I overrode the parents method and called the
childcomponents DoMouseWheel.
Date sent: Wed, 31 May 2006 09:38:57 +1200
Subject: Re: [DUG] MouseWheel and DBGrid in D6
To: "NZ Borland Developers Group - Delphi List" <delphi at ns3.123.co.nz>
From: "Wayne Roser" <rr at kristin.school.nz>
Send reply to: NZ Borland Developers Group - Delphi List <delphi at ns3.123.co.nz>
<mailto:delphi-request at ns3.123.co.nz?subject=unsubscribe>
<mailto:delphi-request at ns3.123.co.nz?subject=subscribe>
[ Double-click this line for list subscription options ]
Hi Stefan
Thanks for your explanation.
I tried:
if (HiWord(Msg.wParam) and $8000)=0
then Msg.wParam := VK_UP else Msg.wParam := VK_DOWN;
but got the same error message as previously.
Also tried Msg.wParamHi instead of HiWord() but that appears to be available for a TMessage and
I've got Msg: tagMSG. Should I be using an event that gives me a TMessage instead of the
TApplicationEvents.OnMessage that I am using?
Wayne
Appendix 1: tagMSG in Windows.pas
{ Message structure }
PMsg = ^TMsg;
tagMSG = packed record
hwnd: HWND;
message: UINT;
wParam: WPARAM;
lParam: LPARAM;
time: DWORD;
pt: TPoint;
end;
Appendix 2: TMessage in Messages.pas
{ Generic window message record }
PMessage = ^TMessage;
TMessage = packed record
Msg: Cardinal;
case Integer of
0: (
WParam: Longint;
LParam: Longint;
Result: Longint);
1: (
WParamLo: Word;
WParamHi: Word;
LParamLo: Word;
LParamHi: Word;
ResultLo: Word;
ResultHi: Word);
end;
NZ Borland Developers Group - Delphi List <delphi at ns3.123.co.nz> writes:
>I would try:
>
>I := smallint(msg.paramhi);
>
>or .. my preferred way:
>
>If (Msg.wParamHi and $8000)=0
> then vk_down
> else vk_up;
>
>the problem is with mixing signed and unsigned datatypes. "Word" datatype is
>unsigned (only has positive range) .. while smallint is "signed" (has +/-
>range).
>
>Range of datatype:
> Word = 0.. 65534;
> smallint = -32768..+32767
>
>a value in a signed datatype is negative if the highest bit is set:
>
> +2 = $0002
> +1 = $0001
> 0 = $0000
> -1 = $ffff
> -2 = $fffe
>
>As you can see ... the value of -1 is stored as $ffff in your wparamhi word.
>Assigning $ffff to a smallint will raise a range error as the compiler
>thinks you try to assign $ffff=65535 to it.
>
>Kind Regards,
>Stefan Mueller
>
>
>
>-----Original Message-----
>From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
>Behalf Of Wayne Roser
>Sent: Tuesday, 30 May 2006 2:47 p.m.
>To: NZ Borland Developers Group - Delphi List
>Subject: [DUG] MouseWheel and DBGrid in D6
>
>I found an article in Delphi.about.com and got this code to fix MouseWheel
>behaviour in a DBGrid:
>
>procedure TForm1.ApplicationEvents1Message (var Msg: TMsg; var Handled:
>Boolean) ;
>var
> i: SmallInt;
>begin
> if Msg.message = WM_MOUSEWHEEL then begin
> Msg.message := WM_KEYDOWN;
> Msg.lParam := 0;
> i := HiWord(Msg.wParam) ; // this line gives me a problem
> if i > 0 then
> Msg.wParam := VK_UP
> else
> Msg.wParam := VK_DOWN;
> Handled := False;
> end;
>end;
>
>So I dropped a TApplicationEvents component on my form and used the code.
>
>I get a problem at the line
> i := HiWord(Msg.wParam) ;
>Msg.wParam is -7864320 and an ERangeError pops up with message 'Range check
>error'
>
>My working version has
> i := Msg.wParam div abs(Msg.wParam);
>in place of the offending line but I'd like to know wassup with the original
>code.
>
>Wayne Roser
>
>_______________________________________________
>Delphi mailing list
>Delphi at ns3.123.co.nz
>http://ns3.123.co.nz/mailman/listinfo/delphi
>
>_______________________________________________
>Delphi mailing list
>Delphi at ns3.123.co.nz
>http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi
Regards
Rohit
======================================================================
CFL - Computer Fanatics Ltd. 21 Barry's Point Road, AKL, New Zealand
PH (649) 489-2280
FX (649) 489-2290
email rohit at cfl.co.nz or r.gupta at xtra.co.nz
======================================================================
More information about the Delphi
mailing list