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

Discussion in 'C++' started by Kyzer, May 6, 2005.

  1. Kyzer

    Kyzer Guest

    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
     
    Kyzer, May 6, 2005
    #1
    1. Advertising

  2. > 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
     
    Jonathan Mcdougall, May 6, 2005
    #2
    1. Advertising

  3. Kyzer

    Duane Hebert Guest

    "Kyzer" <> wrote in message news:...
    > 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.
     
    Duane Hebert, May 6, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JerryG
    Replies:
    0
    Views:
    427
    JerryG
    Dec 20, 2005
  2. Bender
    Replies:
    2
    Views:
    264
    Thomas 'PointedEars' Lahn
    Oct 22, 2003
  3. coolsti
    Replies:
    1
    Views:
    108
    coolsti
    May 15, 2005
  4. jon
    Replies:
    9
    Views:
    140
    pcx99
    Dec 3, 2006
  5. NeilCarmichael

    onmousedown onmouseup

    NeilCarmichael, Oct 8, 2007, in forum: Javascript
    Replies:
    3
    Views:
    166
    Thomas 'PointedEars' Lahn
    Oct 9, 2007
Loading...

Share This Page