BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help with new Class Events...

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Ramy
Guest





PostPosted: Tue Jun 22, 2004 9:06 am    Post subject: Need help with new Class Events... Reply with quote




I have Class Based on TPanel -

class TBaseButton : public TPanel
{
protected:
virtual void __fastcall WndProc( TMessage &Message );
DYNAMIC void __fastcall MouseDown( TMouseButton Button, TShiftState Shift, int X, int Y );
DYNAMIC void __fastcall MouseMove( TShiftState Shift, int X, int Y );

private:
void __fastcall OnMouseEnter( void );
void __fastcall OnMouseLeave( void );
TImage *Image;

public:
__fastcall TBaseButton( TComponent* Owner );
};

-- -- -- -- -- -- -- -- -- -- -- -- --

I want that the TImage which i have on this Pannel (the Image is
part of the Class as you can see) will act just as the Panel
itself, meaning that when i click it, it will go to the same
MouseDown function of the Panel, and then i move mouse cursor
over it will call the 'MouseMove' event of the Panel, and that
when i Enter or Leave it's borders it will call the 'WndProc'
event ( which is where i call the functions 'OnMouseEnter' and
'OnMouseLeave'.

How do i do that?

I tried in the TBaseButton Constructor things like -

Image->OnMouseDown = MouseDown;

and

Image->MouseDown = MouseDown;

and

Image->OnMouseDown = &MouseDown;

but i'm keep getting errors for all this lines...

Thanks very much.

Ramy

Back to top
Ramy
Guest





PostPosted: Tue Jun 22, 2004 11:06 am    Post subject: Re: Need help with new Class Events... Reply with quote




Also, what do i have do write in the Class and in the CPP file
if i want to create an event for the Image, for example
'OnMouseUp' event?

Thanks,
Ramy


"Ramy" <Ramy (AT) NoMail (DOT) com> wrote:
Quote:

I have Class Based on TPanel -

class TBaseButton : public TPanel
{
protected:
virtual void __fastcall WndProc( TMessage &Message );
DYNAMIC void __fastcall MouseDown( TMouseButton Button, TShiftState Shift, int X, int Y );
DYNAMIC void __fastcall MouseMove( TShiftState Shift, int X, int Y );

private:
void __fastcall OnMouseEnter( void );
void __fastcall OnMouseLeave( void );
TImage *Image;

public:
__fastcall TBaseButton( TComponent* Owner );
};

-- -- -- -- -- -- -- -- -- -- -- -- --



Back to top
Ramy
Guest





PostPosted: Tue Jun 22, 2004 12:37 pm    Post subject: Re: Need help with new Class Events... Reply with quote




OK OK.... i know how to do that, i think that i have found the
solution for this 2 questions, ignore it.

Ramy


"Ramy" <Ramy (AT) NoMail (DOT) com> wrote:
Quote:

Also, what do i have do write in the Class and in the CPP file
if i want to create an event for the Image, for example
'OnMouseUp' event?

Thanks,
Ramy



Back to top
Jeff Kish
Guest





PostPosted: Wed Jun 23, 2004 11:56 am    Post subject: Re: Need help with new Class Events... Reply with quote

On 22 Jun 2004 05:37:11 -0700, "Ramy" <Ramy (AT) NoMail (DOT) com> wrote:

Quote:

OK OK.... i know how to do that, i think that i have found the
solution for this 2 questions, ignore it.

Ramy


"Ramy" <Ramy (AT) NoMail (DOT) com> wrote:

Also, what do i have do write in the Class and in the CPP file
if i want to create an event for the Image, for example
'OnMouseUp' event?

Thanks,
Ramy

Well, share your solution with us Ramy!

Jeff Kish

Back to top
Ramy
Guest





PostPosted: Wed Jun 23, 2004 1:06 pm    Post subject: Re: Need help with new Class Events... Reply with quote


Quote:
Well, share your solution with us Ramy!
Jeff Kish

OK

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TBaseButton Class
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

class TBaseButton : public TPanel
{
protected:
virtual void __fastcall WndProc( TMessage &Message );
DYNAMIC void __fastcall MouseDown( TMouseButton Button, TShiftState Shift, int X, int Y );
DYNAMIC void __fastcall MouseMove( TShiftState Shift, int X, int Y );

private:
void __fastcall OnMouseEnter( void );
void __fastcall OnMouseLeave( void );
void __fastcall ImageClick( TObject *Sender );
typedef TPanel inherited;
bool MouseInImage;
TPoint ClickPoint;
TImage *Image;
TLabel *Label;
TBevel *Bevel;

public:
__fastcall TBaseButton( TComponent* Owner );
virtual void __fastcall SetBounds( int ALeft, int ATop, int AWidth, int AHeight );
};

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TBaseButton Constructor
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// Create one BaseButton ( Panel with Bevel, Image
// and Label on it )

__fastcall TBaseButton::TBaseButton( TComponent* Owner ) :
TPanel( Owner )
{
ClickPoint = Point( -1, -1 );
MouseInImage = false;
ParentColor = true;
BevelOuter = bvNone;
BevelInner = bvNone;

Bevel = new TBevel( this );
Bevel->Parent = this;
Bevel->Style = bsRaised;
Bevel->Visible = false;
OnClick = ImageClick;

Image = new TImage( this );
Image->Parent = this;
Image->AutoSize = false;
Image->Stretch = true;
Image->OnClick = ImageClick;
Image->Picture->LoadFromFile( "TempImage.bmp" );
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Image Click
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// Image Click

void __fastcall TBaseButton::ImageClick( TObject *Sender )
{
// Bla Bla Bla... My Code for Image Click
}

[... Bla bla.... more functions...]

Ramy


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.