Passing in a OnMouseDown/OnMouseUp event handler as a parameter of a function

K

Kyzer

Hi all,

I have created a class which contains many TShapes, TLabels and
TPanels. What I want to be able to do is when creating this class, is
passing in a pointer to OnMouseDown and OnMouseUp events. Thereby, the
user of the class can create their own event handlers for those events.
The idea is that by passing in the event handlers, these event
handlers are assigned to the appropriate events for each of the objects
in the class. However, I am having trouble declaring the constructor:

eg.
class SpecialButton : public TObject {
__published:
TShape *TLCorner;
TShape *TRCorner; // ...etc....

__public:
__fastcall SpecialButton(TMouseEvent mouseDown, TMouseEvent
mouseUp); // ??????
};

Your suggestions on this would be greatly appreciated.

Thanks,
Kyzer
 
J

Jonathan Mcdougall

Hi all,
I have created a class which contains many TShapes, TLabels and
TPanels. What I want to be able to do is when creating this class, is
passing in a pointer to OnMouseDown and OnMouseUp events. Thereby, the
user of the class can create their own event handlers for those events.
The idea is that by passing in the event handlers, these event
handlers are assigned to the appropriate events for each of the objects
in the class. However, I am having trouble declaring the constructor:

eg.
class SpecialButton : public TObject {
__published:

What's __published?
TShape *TLCorner;
TShape *TRCorner; // ...etc....

__public:

What's __public?
__fastcall SpecialButton(TMouseEvent mouseDown, TMouseEvent
mouseUp); // ??????

What's __fastcall?
};

Your suggestions on this would be greatly appreciated.

What's the problem?


Jonathan
 
D

Duane Hebert

Kyzer said:
Hi all,

I have created a class which contains many TShapes, TLabels and
TPanels. What I want to be able to do is when creating this class, is
passing in a pointer to OnMouseDown and OnMouseUp events. Thereby, the
user of the class can create their own event handlers for those events.
The idea is that by passing in the event handlers, these event
handlers are assigned to the appropriate events for each of the objects
in the class. However, I am having trouble declaring the constructor:

eg.
class SpecialButton : public TObject {
__published:
TShape *TLCorner;
TShape *TRCorner; // ...etc....

__public:
__fastcall SpecialButton(TMouseEvent mouseDown, TMouseEvent
mouseUp); // ??????
};

Your suggestions on this would be greatly appreciated.
Try newsgroups.borland.com and look for a discussion with
VCL in the title. You'll get better help there. What you probably
want to do is to define a virtual function called by the event and allow
a derived class to override it.

BTW, even Borland doesn't support __public: AFAIK.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top