Board index » cppbuilder » How to derive a new component?

How to derive a new component?

I got the advice to derive a new component from TDBGrid to be able to expose
it's OnMouse...events. I have never derived new components, could somebody
point me in the right direction or suggest any reading on the subject?

Peter

 

Re:How to derive a new component?


Well, I think I was able to derive a TMyDBGrid that has an OnMouseDown and
OnMouseUp event handler. My problem now is that OnMouseDown seems to occur
only when I click down on the first row (column headings) of  MyDBGrid. The
OnMouseUp event occurs in any cell of the grid, and it also knows in which
cell the mousepointer is. I would like the OnMouseDown to function the same
way, is that possible ?

Peter

Re:How to derive a new component?


You may have forgotten to call the existing handler of your class' ancestor.
Its processing must still be done. Something like this:

void __fastcall TMyDBGrid::OnMouseDown(TObject *Sender, TMouseButton Button,
Classes::TShiftState Shift,
int X, int Y)
{
  //  your code ...

  TControl::OnMouseDown(Sender, Button, Shift, X, Y);

Quote
}

Mike

Quote
"Peter Valkama" <peter:valk...@yle.fi> wrote in message

news:3bfbb336_2@dnews...
Quote

> Well, I think I was able to derive a TMyDBGrid that has an OnMouseDown and
> OnMouseUp event handler. My problem now is that OnMouseDown seems to occur
> only when I click down on the first row (column headings) of  MyDBGrid.
The
> OnMouseUp event occurs in any cell of the grid, and it also knows in which
> cell the mousepointer is. I would like the OnMouseDown to function the
same
> way, is that possible ?

> Peter

Re:How to derive a new component?


Mike,
is the line
   TControl::OnMouseDown(Sender, Button, Shift, X, Y);
supposed to go in right there? It gives me an Access Violation message.

Peter

Quote
"Mike Noll" <mike.n...@jhuapl.edu> wrote in message news:3bfbcdca_2@dnews...
> You may have forgotten to call the existing handler of your class'
ancestor.
> Its processing must still be done. Something like this:

> void __fastcall TMyDBGrid::OnMouseDown(TObject *Sender, TMouseButton
Button,
> Classes::TShiftState Shift,
> int X, int Y)
> {
>   //  your code ...

>   TControl::OnMouseDown(Sender, Button, Shift, X, Y);
> }

> Mike

Other Threads