 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ben (nl) Guest
|
Posted: Wed Dec 03, 2003 12:55 am Post subject: OnMouseEnter/Leave Image - Component... |
|
|
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 . 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
|
Posted: Wed Dec 03, 2003 1:07 am Post subject: Re: OnMouseEnter/Leave Image - Component... |
|
|
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 . 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
|
Posted: Wed Dec 03, 2003 1:12 am Post subject: Re: OnMouseEnter/Leave Image - Component... |
|
|
"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
|
Posted: Wed Dec 03, 2003 1:16 am Post subject: Re: OnMouseEnter/Leave Image - Component... |
|
|
| 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 .
|
|
| Back to top |
|
 |
Ben (nl) Guest
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Dec 03, 2003 1:38 am Post subject: Re: OnMouseEnter/Leave Image - Component... |
|
|
"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
|
Posted: Wed Dec 03, 2003 1:45 am Post subject: Re: OnMouseEnter/Leave Image - Component... |
|
|
| 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 .
And I think I just found out how... Yes!!
Ben.
|
|
| Back to top |
|
 |
Cactus Guest
|
Posted: Wed Dec 03, 2003 4:05 am Post subject: Re: OnMouseEnter/Leave Image - Component... |
|
|
| 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
|
Posted: Wed Dec 03, 2003 5:09 am Post subject: Re: OnMouseEnter/Leave Image - Component... |
|
|
"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
|
Posted: Wed Dec 03, 2003 1:41 pm Post subject: Re: OnMouseEnter/Leave Image - Component... |
|
|
| 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
|
Posted: Wed Dec 03, 2003 6:38 pm Post subject: Re: OnMouseEnter/Leave Image - Component... |
|
|
"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 |
|
 |
|
|
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
|
|