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 

OnMouseEnter/Leave Image - Component...

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





PostPosted: Wed Dec 03, 2003 12:55 am    Post subject: OnMouseEnter/Leave Image - Component... Reply with quote



Okay, I want to change the cursor when over multiple images (resize
form with images) and someone suggested to make my own component.

Then (this) is the group to be...
(Funny that TLabel HAS got these Events and they didn't implement it in
TImage...)

I think I've found some useful code... only now to figure out how to make a
component out of this for my bcb 6 Neutral. Never done that before.

I read a few tutorials, but not a lot of progress yet, still searching at
the moment, but maybe someone can help me out.


Gr, Ben.
(ps. sorry that this post surfed over 2 other groups, but I didn't knew at
the
time of the post that I would be doing something with component-writing ;-)


class PACKAGE THotImage : public TImage
{
private:
TNotifyEvent fOnMouseEnter;
TNotifyEvent fOnMouseLeave;

protected:
void __fastcall CMMouseEnter(TMessage& Message);
void __fastcall CMMouseLeave(TMessage& Message);

BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
END_MESSAGE_MAP(TImage)

__published:
__property TNotifyEvent OnMouseEnter = {
read = fOnMouseEnter, write = fOnMouseEnter };
__property TNotifyEvent OnMouseLeave = {
read = fOnMouseLeave, write = fOnMouseLeave };
};

void __fastcall THotImage::CMMouseEnter(TMessage& Message)
{
inherited::Dispatch(&Message);
if (fOnMouseEnter)
fOnMouseEnter(this);
}

void __fastcall THotImage::CMMouseLeave(TMessage& Message)
{
inherited::Dispatch(&Message);
if (fOnMouseLeave)
fOnMouseLeave(this);
}




Back to top
Rodolfo Frino
Guest





PostPosted: Wed Dec 03, 2003 1:07 am    Post subject: Re: OnMouseEnter/Leave Image - Component... Reply with quote



If what you want is to change the mouse cursor when the mouse enters or
leaves a control (including a TImage)
then you could use this method:

http://www.geocities.com/rodolfofrino/WndProcMouseEntersLeaves.html

"Programming is the art of picking a needle out of a hayheap." Rodolfo, 2003


"Ben (nl)" <Just (AT) Ask (DOT) com> wrote

Quote:
Okay, I want to change the cursor when over multiple images (resize
form with images) and someone suggested to make my own component.

Then (this) is the group to be...
(Funny that TLabel HAS got these Events and they didn't implement it in
TImage...)

I think I've found some useful code... only now to figure out how to make
a
component out of this for my bcb 6 Neutral. Never done that before.

I read a few tutorials, but not a lot of progress yet, still searching at
the moment, but maybe someone can help me out.


Gr, Ben.
(ps. sorry that this post surfed over 2 other groups, but I didn't knew at
the
time of the post that I would be doing something with component-writing
;-)


class PACKAGE THotImage : public TImage
{
private:
TNotifyEvent fOnMouseEnter;
TNotifyEvent fOnMouseLeave;

protected:
void __fastcall CMMouseEnter(TMessage& Message);
void __fastcall CMMouseLeave(TMessage& Message);

BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
END_MESSAGE_MAP(TImage)

__published:
__property TNotifyEvent OnMouseEnter = {
read = fOnMouseEnter, write = fOnMouseEnter };
__property TNotifyEvent OnMouseLeave = {
read = fOnMouseLeave, write = fOnMouseLeave };
};

void __fastcall THotImage::CMMouseEnter(TMessage& Message)
{
inherited::Dispatch(&Message);
if (fOnMouseEnter)
fOnMouseEnter(this);
}

void __fastcall THotImage::CMMouseLeave(TMessage& Message)
{
inherited::Dispatch(&Message);
if (fOnMouseLeave)
fOnMouseLeave(this);
}







Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Dec 03, 2003 1:12 am    Post subject: Re: OnMouseEnter/Leave Image - Component... Reply with quote




"Ben (nl)" <Just (AT) Ask (DOT) com> wrote


Quote:
Then (this) is the group to be...
(Funny that TLabel HAS got these Events and they
didn't implement it in TImage...)

The underlying messages that are sent when the mouse moves over or out of a
particular control have always been implemented ever since BCB3. It is just
that none of the native component actually exposed events for them until
BCB6. Why they chose just TLabel and not TControl instead, I do not know.
But the messages themselves are still available, though.


Gambit



Back to top
Ben (nl)
Guest





PostPosted: Wed Dec 03, 2003 1:16 am    Post subject: Re: OnMouseEnter/Leave Image - Component... Reply with quote

Quote:
(Funny that TLabel HAS got these Events and they
didn't implement it in TImage...)

The underlying messages that are sent when the mouse moves over or out of
a
particular control have always been implemented ever since BCB3. It is
just
that none of the native component actually exposed events for them until
BCB6. Why they chose just TLabel and not TControl instead, I do not know.
But the messages themselves are still available, though.

I understand, but still Wink.



Back to top
Ben (nl)
Guest





PostPosted: Wed Dec 03, 2003 1:17 am    Post subject: Re: OnMouseEnter/Leave Image - Component... Reply with quote

Quote:
If what you want is to change the mouse cursor when the mouse enters or
leaves a control (including a TImage)
then you could use this method:

http://www.geocities.com/rodolfofrino/WndProcMouseEntersLeaves.html

"Programming is the art of picking a needle out of a hayheap." Rodolfo,
2003


Thx Smile I could make it work with that.

I also just found
http://groups.google.com/groups?hl=nl&lr=&ie=UTF-8&selm=3b5f3331.113244416%4
0newsgroups.borland.com

Ben.




Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Dec 03, 2003 1:38 am    Post subject: Re: OnMouseEnter/Leave Image - Component... Reply with quote


"Rodolfo Frino" <MenInBlack (AT) nowhere (DOT) com> wrote

Quote:
If what you want is to change the mouse cursor when
the mouse enters or leaves a control (including a TImage)
then you could use this method:
You could just set the component's Cursor property instead. That is what it

is for - changing the cursor when the mouse enters a specific component and
then changes the cursor back to something else when the mouse leaves the
component.


Gambit



Back to top
Ben (nl)
Guest





PostPosted: Wed Dec 03, 2003 1:45 am    Post subject: Re: OnMouseEnter/Leave Image - Component... Reply with quote

Quote:
You could just set the component's Cursor property instead. That is what
it
is for - changing the cursor when the mouse enters a specific component
and
then changes the cursor back to something else when the mouse leaves the
component.

I could...

But that's not what I want.

I want to write the d#mn component Wink.

And I think I just found out how... Yes!!

Ben.



Back to top
Cactus
Guest





PostPosted: Wed Dec 03, 2003 4:05 am    Post subject: Re: OnMouseEnter/Leave Image - Component... Reply with quote

Quote:
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
END_MESSAGE_MAP(TImage)

That is Dispatch method macro.
it already have a TImage::Dispatch() call.
so you don't need call again.


Quote:
void __fastcall THotImage::CMMouseEnter(TMessage& Message)
{
inherited::Dispatch(&Message); <------ .......
if (fOnMouseEnter)
fOnMouseEnter(this);
}



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Dec 03, 2003 5:09 am    Post subject: Re: OnMouseEnter/Leave Image - Component... Reply with quote


"Cactus" <a@b.com> wrote


Quote:
That is Dispatch method macro.
it already have a TImage::Dispatch() call.
so you don't need call again.

Yes, actually you do, otherwise any handled messages won't be seen by the
base class appropriately. The MESSAGE_MAP overrides Dispatch() and then
automatically calls the base class Dispatch() *only* for unhandled messages.
If there is a message handler, it is the responsibility of that handler to
call the base class Dispatch() manually, the MESSAGE_MAP won't be able to do
so. The MESSAGE_MAP macros expand to a switch() statement with the base
class Dispatch() in the 'default' section only, ie:

void __fastcall Dispatch(TMessage &Message)
{
switch( Message.Msg )
{
case CM_MOUSEENTER:
CMMouseEnter(*((TMessage*)&Message));
break;
case CM_MOUSELEAVE:
CMMouseLeave(*((TMessage*)&Message));
break;
default:
TImage::Dispatch(&Message);
break;
}
}


Gambit



Back to top
Cactus
Guest





PostPosted: Wed Dec 03, 2003 1:41 pm    Post subject: Re: OnMouseEnter/Leave Image - Component... Reply with quote

Quote:
void __fastcall Dispatch(TMessage &Message)
{
switch( Message.Msg )
{
case CM_MOUSEENTER:
CMMouseEnter(*((TMessage*)&Message));
break;
case CM_MOUSELEAVE:
CMMouseLeave(*((TMessage*)&Message));
break;
default:
TImage::Dispatch(&Message);
break;
}
}


I no find any about CM_MOUSELEAVE & CM_MOUSEENTER define in my help
documents.
in win32 help, it is

WM_CAPTURECHANGED
WM_LBUTTONDBLCLK
WM_LBUTTONDOWN
WM_LBUTTONUP
WM_MBUTTONDBLCLK
WM_MBUTTONDOWN
WM_MBUTTONUP
WM_MOUSEMOVE
WM_MOUSEWHEEL
WM_NCHITTEST
WM_NCLBUTTONDBLCLK
WM_NCLBUTTONDOWN
WM_NCLBUTTONUP
WM_NCMBUTTONDBLCLK
WM_NCMBUTTONDOWN
WM_NCMBUTTONUP
WM_NCMOUSEMOVE
WM_NCRBUTTONDBLCLK
WM_NCRBUTTONDOWN
WM_NCRBUTTONUP
WM_RBUTTONDBLCLK
WM_RBUTTONDOWN
WM_RBUTTONUP


And, they may have a few changed, this event no occur in my test.
WM_MOUSEACTIVATE

regards.



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Dec 03, 2003 6:38 pm    Post subject: Re: OnMouseEnter/Leave Image - Component... Reply with quote


"Cactus" <a@b.com> wrote


Quote:
I no find any about CM_MOUSELEAVE & CM_MOUSEENTER
define in my help documents.

They are used internally by the VCL. The help files don't document the
VCL's internal features. There is a lot going on inside the VCL that is not
documented, probably because they weren't meant to be used directly in the
first place. Experience teaches poeple how to access and use the private
stuff, though :-)

Quote:
in win32 help, it is

Those are Win32 API messages. All of the CM_ messages are private to the
VCL's internal use only.


Gambit



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) 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.