BCB6 DBGrid VScroll - How to make it to scroll without changing selected row

Hi, I'm looking for solution to make functionality of BCB6 DGBGrid Vscroll like in NET DataGridView ( scrolling rows without changing a selected record ).

Regards
Leo01010101Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sinisa VukSoftware architectCommented:
You close your old question before....
There you are not follow my directions. I suggest to create new dbgrid component inherited from original. Or use solution to override grids WindowProc.
So, this time with code:

1. add this to global variables:
TWndMethod FOrgGridWndProc;

Open in new window


2. add new method to form class to replace original:
...
void __fastcall NewGridWndProc(tagMSG &Msg);
...

Open in new window


3. add code for it and replace original window proc of dbgrid
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  FOrgGridWndProc = DBGrid1->WindowProc;
  DBGrid1->WindowProc = NewGridWndProc;  
}

void __fastcall TForm1::NewGridWndProc(tagMSG &Msg)
{
  if( Msg.message == WM_VSCROLL )
  {
     Msg.Result = 1; //handled
  }else
  {
    //call original one
    FOrgGridWndProc(Msg);
  }
}

Open in new window


(this is translatio from Delphi ...but  with some changes can work)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leo01010101Author Commented:
Thank you very much, I didn't follow you direction before because I was not sure how to use your Delphi sample code.  Now I had to made a cosmetic change (code below) and now it is working perfectly.  

void __fastcall TForm1::NewGridWndProc(TMessage &Message)    
{
  if( Message.Msg == WM_VSCROLL )
  {
     Message.Result = 1; //handled
  }else
    //call original one
    FOrgGridWndProc(Message);
  }
}

Open in new window

0
Leo01010101Author Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for Leo01010101's comment #a39542682

for the following reason:

Perfect solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.