Page 1 of 1
Problems adding mouse event to Real-Time Marquee Component

Posted:
November 23rd, 2009, 5:11 pm
by AgentX
I'm using the newest Real-Time Marquee Component but I'd like to have a OnMouseEnter and OnMouseLeave event for making active/inactive.
I added my mouse events but could not get a response to the events. The events showed up in the component and I placed code in the events to respond but the event was not live.
Maybe I added in the wrong place, can you help?
best regards
Re: Problems adding mouse event to Real-Time Marquee Component

Posted:
November 24th, 2009, 11:53 am
by Kambiz
What's your version of Delphi?
Re: Problems adding mouse event to Real-Time Marquee Component

Posted:
November 25th, 2009, 3:00 pm
by AgentX
Hi,
Yes, I'm using Delphi 7
Re: Problems adding mouse event to Real-Time Marquee Component

Posted:
November 26th, 2009, 3:59 am
by Kambiz
Here you are:
- Code: Select all
unit RealTimeMarqueeEx;
interface
uses
Windows, Messages, Classes, Controls, RealTimeMarquee;
type
TRealTimeMarqueeEx = class(TRealTimeMarquee)
private
fOnMouseEnter: TNotifyEvent;
fOnMouseLeave: TNotifyEvent;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
published
property OnMouseEnter: TNotifyEvent read fOnMouseEnter write fOnMouseEnter;
property OnMouseLeave: TNotifyEvent read fOnMouseLeave write fOnMouseLeave;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Delphi Area', [TRealTimeMarqueeEx]);
end;
{ TRealTimeMarqueeEx }
procedure TRealTimeMarqueeEx.CMMouseEnter(var Message: TMessage);
begin
inherited;
if Assigned(fOnMouseEnter) then
fOnMouseEnter(Self);
end;
procedure TRealTimeMarqueeEx.CMMouseLeave(var Message: TMessage);
begin
inherited;
if Assigned(fOnMouseLeave) then
fOnMouseLeave(Self);
end;
end.
Re: Problems adding mouse event to Real-Time Marquee Component

Posted:
November 26th, 2009, 5:37 pm
by AgentX
It looks absolutely perfect and I appreciate your help, however this is not working either.
Your component installed correctly and I converted my project to the new component and assigned the events and nothing fires the event, it just won't trigger.
The mousemove and onclick events work fine.
I wonder if it's Windows7 somehow causing this?
I may have to try and do this in the onmousemove event instead.
Thank you..
Re: Problems adding mouse event to Real-Time Marquee Component

Posted:
November 26th, 2009, 7:31 pm
by Kambiz
Sounds strange!
I tested the code on Windows Vista, and it worked.
Re: Problems adding mouse event to Real-Time Marquee Component

Posted:
November 27th, 2009, 9:23 am
by AgentX
I just tried your code on a brand new program and form, it worked perfectly.
Something in my program is taking over the event ..
I'm using this in a DLL and there are other DLL's in this program that capture the mouse events, maybe something else can be stealing the event.
Thank you
Re: Problems adding mouse event to Real-Time Marquee Component

Posted:
November 27th, 2009, 11:56 am
by Kambiz
I suggest to use runtime package instead of DLL, then set main program's Application.Handle to runtime package's Application.Handle.
Re: Problems adding mouse event to Real-Time Marquee Component

Posted:
November 27th, 2009, 4:15 pm
by AgentX
Since this is a plug-in for my main application, I had to make this work within the plug-in code.
I created a solution that works quite well, here is what I had to do for anyone else that may need something like this and not have access to the mouseenter/mouseleave events.
- Code: Select all
procedure TWidgetMainForm.rltmrq1MouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
if GetCapture = 0 then
SetCapture(rltmrq1.Handle);
if PtInRect(Rect(rltmrq1.Left,
rltmrq1.Top,
rltmrq1.Left + rltmrq1.Width,
rltmrq1.Top + rltmrq1.Height),
ClientToScreen(Point(x, y))) then
rltmrq1.Active := False
else
rltmrq1.Active := True;
end;
thanks..
