Discussion:
class
(too old to reply)
bar
2007-08-25 17:34:19 UTC
Permalink
Hello all

I have a form
class TfrmMain : public TForm
{
__published: // IDE-managed Components
TPanel *picTickerPanel;
private: // User declarations
public: // User declarations
__fastcall TfrmMain(TComponent* Owner);
};
//-------------------------------------------------
extern PACKAGE TfrmMain *frmMain;


I created a class derived from TShockwaveFlash
//in the header
class TImageFLASH : public TShockwaveFlash
{
private:
String FlashCursor;
public:
__fastcall TImageFLASH(TComponent *Owner);
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
VCL_MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
END_MESSAGE_MAP(TShockwaveFlash)
};

//in the Cpp file
void __fastcall TImageFLASH::CMMouseEnter(TMessage &Message)
{
TShockwaveFlash::Dispatch(&Message)
...........//some thing
}

At runtime i am creating a some flash controls in the "picTickerPanel" panel
of frmMain
for(int FLASHImageNumber=0; FLASHImageNumber<=3; FLASHImageNumber++)
{
TImageFLASH *ImageFLASH = new TImageFLASH(picTickerPanel);
ImageFLASH->Parent = picTickerPanel;
ImageFLASH->Tag = FLASHImageNumber;
}
and placing in the panel.

My Problems
----------
When the mouse is over the flash images i want to know the ImageFLASH Tag
number (Sender) of the event.

Thanks
SA
Damon Chandler (TeamB)
2007-08-25 23:52:53 UTC
Permalink
Hi SA,

I don't know what TShockwaveFlash descends from, but if your TImageFLASH
has a Tag property, you can access that property directly from within
the TImageFLASH::CMMouseEnter (or CMMouseLeave) method(s). When you
receive the CMMouseEnter/Leave messages, just make sure to check that
the Msg.LParam data member is NULL; if it's not, then the message was
intended for a child of the TImageFLASH (not an issue if TImageFLASH
can't contain other child controls).

I would suggest creating OnMouseEnter and OnMouseLeave events for your
TImageFLASH class; this is similar to what's available to TControl
descendants in newer versions of C++Builder; some similar to...

class TImageFLASH : public TShockwaveFlash
{
__published:
__property TNotifyEvent OnMouseEnter =
{read=OnMouseEnter_, write=OnMouseEnter_};
__property TNotifyEvent OnMouseLeave =
{read=OnMouseLeave_, write=OnMouseLeave_};

public:
__fastcall TImageFLASH(TComponent* AOwner) :
TShockwaveFlash(AOwner) {}

private:
void __fastcall CMMouseEnter(TMessage& Msg);
void __fastcall CMMouseLeave(TMessage& Msg);

private:
TNotifyEvent OnMouseEnter_;
TNotifyEvent OnMouseLeave_;

public:
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
VCL_MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
END_MESSAGE_MAP(TCustomControl)
};

void __fastcall TMyControl::
CMMouseEnter(TMessage& Msg)
{
TCustomControl::Dispatch(&Msg);
if (Msg.LParam == NULL && OnMouseEnter_ != NULL)
{
OnMouseEnter_(this);
}
}

void __fastcall TMyControl::
CMMouseLeave(TMessage& Msg)
{
TCustomControl::Dispatch(&Msg);
if (Msg.LParam == NULL && OnMouseLeave_ != NULL)
{
OnMouseLeave_(this);
}
}

Cheers,
--
Damon Chandler (TeamB)
C++Builder Developer's Journal
http://bcbjournal.com
http://bcbjournal.org
Post by bar
At runtime i am creating a some flash controls in the "picTickerPanel" panel
of frmMain
for(int FLASHImageNumber=0; FLASHImageNumber<=3; FLASHImageNumber++)
{
TImageFLASH *ImageFLASH = new TImageFLASH(picTickerPanel);
ImageFLASH->Parent = picTickerPanel;
ImageFLASH->Tag = FLASHImageNumber;
}
and placing in the panel.
My Problems
----------
When the mouse is over the flash images i want to know the ImageFLASH Tag
number (Sender) of the event.
bar
2007-08-26 16:35:11 UTC
Permalink
Post by Damon Chandler (TeamB)
I don't know what TShockwaveFlash descends from, but if your TImageFLASH
has a Tag property, you can access that property directly from within the
TImageFLASH::CMMouseEnter (or CMMouseLeave) method(s).
Hi Damon, thanks for reply
It has the tag property. In the TImageFLASH::CMMouseEnter, i can't able to
find from which flash image the event is occuring.


void __fastcall TImageFLASH::CMMouseEnter(TMessage &Message)
{
//some thing working fine.
.....
Now how to find the Sender of this event.
}
JD
2007-08-27 02:26:14 UTC
Permalink
[...] It has the tag property. In the
TImageFLASH::CMMouseEnter, i can't able to find from which
flash image the event is occuring.
There is no such native event or method. However, one can
subclass the object and add a message handler and in that case
the implicit 'this' pointer would point to the current object.
void __fastcall TImageFLASH::CMMouseEnter(TMessage &Message)
{
//some thing working fine.
.....
Now how to find the Sender of this event.
}
While technically incorrect, that looks like a message handler
and would only be valid if part of a subclassed TImage object
and even then it would most likely be at issue because ...

Prior to BDS (and possibly including BDS), CM_MOUSEENTER and
CM_MOUSELEAVE are unreliable. For more see here:

http://www.stevetrefethen.com/blog/IntroducingOnMouseEnterOnMouseLeaveEventsOnTControlInVCLForDelphi2006.aspx

You need to explain exactly what it is that you want to
accomplish and then explain exactly how the samples fit
into your design.

~ JD
Clayton Arends
2007-08-26 17:31:13 UTC
Permalink
Post by bar
void __fastcall TImageFLASH::CMMouseEnter(TMessage &Message)
...
When the mouse is over the flash images i want to know the ImageFLASH Tag
number (Sender) of the event.
If I correctly understand what you have described then in CMMouseEnter
'this' is the sender. You should just be able to access 'Tag' directly.

void __fastcall TImageFLASH::CMMouseEnter(TMessage &Message)
{
TShockwaveFlash::Dispatch(&Message);

switch (Tag)
{ // blah
}
}

- Clayton
bar
2007-08-27 07:43:48 UTC
Permalink
Hi Clayton.Thanks
this is what i need

Cheers
SA
Remy Lebeau (TeamB)
2007-08-27 17:15:15 UTC
Permalink
Post by bar
When the mouse is over the flash images i want to know
the ImageFLASH Tag number (Sender) of the event.
The sender is the same object that the 'this' pointer of the method is
pointing to, so just use the Tag property directly, ie:

void __fastcall TImageFLASH::CMMouseEnter(TMessage &Message)
{
TShockwaveFlash::Dispatch(&Message)
if( Tag == whatever )
// do something ...
}


Gambit

Loading...