Problems adding mouse event to Real-Time Marquee Component

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

Problems adding mouse event to Real-Time Marquee Component

Postby AgentX » November 23rd, 2009, 5:11 pm

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
AgentX
Active Member
Active Member
 
Posts: 5
Joined: November 23rd, 2009, 4:47 pm

Re: Problems adding mouse event to Real-Time Marquee Component

Postby Kambiz » November 24th, 2009, 11:53 am

What's your version of Delphi?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: Problems adding mouse event to Real-Time Marquee Component

Postby AgentX » November 25th, 2009, 3:00 pm

Hi,

Yes, I'm using Delphi 7
AgentX
Active Member
Active Member
 
Posts: 5
Joined: November 23rd, 2009, 4:47 pm

Re: Problems adding mouse event to Real-Time Marquee Component

Postby Kambiz » November 26th, 2009, 3:59 am

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.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: Problems adding mouse event to Real-Time Marquee Component

Postby AgentX » November 26th, 2009, 5:37 pm

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..
AgentX
Active Member
Active Member
 
Posts: 5
Joined: November 23rd, 2009, 4:47 pm

Re: Problems adding mouse event to Real-Time Marquee Component

Postby Kambiz » November 26th, 2009, 7:31 pm

Sounds strange!
I tested the code on Windows Vista, and it worked.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: Problems adding mouse event to Real-Time Marquee Component

Postby AgentX » November 27th, 2009, 9:23 am

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
AgentX
Active Member
Active Member
 
Posts: 5
Joined: November 23rd, 2009, 4:47 pm

Re: Problems adding mouse event to Real-Time Marquee Component

Postby Kambiz » November 27th, 2009, 11:56 am

I suggest to use runtime package instead of DLL, then set main program's Application.Handle to runtime package's Application.Handle.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: Problems adding mouse event to Real-Time Marquee Component

Postby AgentX » November 27th, 2009, 4:15 pm

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.. ;)
AgentX
Active Member
Active Member
 
Posts: 5
Joined: November 23rd, 2009, 4:47 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 2 guests