BCB6 DBGrid Vertical ScrollBar shouldn't change selected record

Hi, I want to set DBGrid to not allow a vertical ScrollBar to change selected record. Is it possible?
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:
I suggest to hide vertical scroll-bar. This is how it is possible in Delphi, but should be similar in bcb too...
http://www.techques.com/question/1-7529524/Keep-the-scrollbars-hidden-in-a-Delphi-dbgrid-%28even-on-resize%29
http://delphi.xcjc.net/viewthread.php?tid=49141
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:
Yes, I did it and it was working. But I'm looking now for solution where scroll-bar will work and change position of first displayed record but without changing selection.
0
Sinisa VukSoftware architectCommented:
Then you can make inherited dbgrid with WMVScroll message method overrided:
type
  TMyDBGrid = class(TDBGrid)
  private
    procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
  end;

...

implementation

procedure TMyDBGrid.WMVScroll(var Message: TWMVScroll);
begin
  // inherited; //keep commented
end;

Open in new window


... or you can replace WindowProc method where you must ignore TWMVScroll message.
Here is example of how to replace this method...
http://stackoverflow.com/questions/5397158/delphi-drag-drop-with-listview/5397705#5397705
0
Leo01010101Author Commented:
I'm not sure how to implement your code in C++,

I tried to catch WM_SCROLL in this way:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   Application->OnMessage = AppMessage;
}

void __fastcall TForm1::AppMessage(tagMSG &Msg, bool &Handled)
{
  if( Msg.message == WM_VSCROLL )
  {
   Handled = true;
  }
}

Open in new window



but it didn't catch this event when I move a vertical scroll bar ( mouse wheel message is catched etc.. ). What could be a reason?
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.