Article View: borland.public.cppbuilder.database.ado
Article #3055Re: DBGrid and MouseWheel
From: Mark Guerrieri
Date: Mon, 06 Jan 2003 17:17
Date: Mon, 06 Jan 2003 17:17
106 lines
3971 bytes
3971 bytes
Ok, here you go... this will handle ant TDBGrids in your app and scroll them
correctly... I am using BCB6 sp2...
void __fastcall TForm1::ApplicationEvents1Message(tagMSG &Msg,
bool &Handled)
{
static int deltaUp = 0;
static int deltaDown = 0;
if(Msg.message == WM_MOUSEWHEEL)
{
if(Screen->ActiveForm &&
dynamic_cast<TDBGrid*>(Screen->ActiveForm->ActiveControl))
{
short zDelta = (short) HIWORD(Msg.wParam);
bool bUp = false;
bool bDown = false;
if(zDelta == 0)
return;
if(zDelta > 0)
{
deltaUp+= zDelta;
deltaDown = 0;
bUp = true;
}
else
{
deltaDown+= zDelta;
deltaUp = 0;
bDown = true;
}
if(bUp && deltaUp >= WHEEL_DELTA)
{
deltaUp = 0;
Msg.message = WM_KEYDOWN;
Msg.lParam = 0;
Msg.wParam = VK_UP;
}
else if(bDown && (deltaDown * -1) >= WHEEL_DELTA)
{
deltaDown = 0;
Msg.message = WM_KEYDOWN;
Msg.lParam = 0;
Msg.wParam = VK_DOWN;
}
}
}
}
Mark Guerrieri
mguerrieri@cmsgrp.com
"Ricardo Rodrigues" <madinfo@cadaval.net> wrote in message
news:3e18b751@newsgroups.borland.com...
> I am interested on that code too
> tanks
>
> --Ricardo
>
>
> "Mark Guerrieri" <markg11@comcast.net> wrote in message
> news:3e174252$1@newsgroups.borland.com...
> > This is a known issue with TDBGrid. You need to add a routine to
globally
> > handle mouse wheel messages (write a TApplicationEvents->OnMessage event
> > handler), check to see if the window with input focus is a TDBGrid and
if
> it
> > is, manually scroll the grid. When I get back to the office on Monday,
> I'll
> > post the code I use if someone else hasn't by then.
> >
> > Mark Guerrieri
> > mguerrieri@cmsgrp.com
> >
> > "Alen Markov" <NOSPAM_amarkov@gmx.net> wrote in message
> > news:3e16d6df$1@newsgroups.borland.com...
> > > Just curious:
> > >
> > > Let's say you have a DGGrid with total 1000 rows.
> > > The DBGrid is positioned on the screen in a size
> > > that only the first 15rows are displayed
> > > (Properties - Options are all left on their defaultvalues)
> > >
> > > When you scroll down now with the mousewheel,
> > > it works fine until the "cursor" (the current cell is marked blue)
> > > reaches the row number 15... means you can only scroll
> > > between rows 1 and 15, but not further...
> > >
> > > Is it possible to adjust somehow the behaviour of a DBGrid
> > > so you can scroll through all rows with the mousewheel?
> > >
> > > Alen
> > >
> > >
> > > --
> > > WEB: http://www.come.to/nostromo
> > >
> > >
> >
> >
>
>
Technical Details
Message-ID:
<3e19b869@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!c03.atl99!news.webusenet.com!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3e16d6df$1@newsgroups.borland.com> <3e174252$1@newsgroups.borland.com> <3e18b751@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,cc310fafd9ee71eb X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-01-06 09:40:07 PST Reply-To: "Mark Guerrieri" <mguerrieri@cmsgrp.com> From: "Mark Guerrieri" <mguerrieri@cmsgrp.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3e16d6df$1@newsgroups.borland.com> <3e174252$1@newsgroups.borland.com> <3e18b751@newsgroups.borland.com> Subject: Re: DBGrid and MouseWheel Date: Mon, 6 Jan 2003 12:17:00 -0500 Lines: 108 Organization: Creative Marketing Strategies X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 66.200.143.50 Message-ID: <3e19b869@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1041873001 66.200.143.50 (6 Jan 2003 09:10:01 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!c03.atl99!news.webusenet.com!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail