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 

Problems with OnMouseDown event in own omponent

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
Henryk
Guest





PostPosted: Sat Jan 27, 2007 9:29 pm    Post subject: Problems with OnMouseDown event in own omponent Reply with quote



hello, I have problems with creating a proper event handling in my
component. COuld you look where i am making mistake?

unit MojGradient;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, JvGradient;

type
TMojEvent = procedure(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer) of object;

type
TMojGradient3 = class(TjvGradient)

private
Over, Out : TNotifyEvent;
Down: TMojEvent;
procedure MouseEnter(var Message:TMessage);message cm_MouseEnter; //this is
working
procedure MouseLeave(var Message:TMessage);message cm_MouseLeave; //this is
working
procedure MouseDown(var Message:TWMNCLButtonDown);message WM_NCLButtonDown;
//this is not, why?

public

published
property OnMouseEnter: TNotifyEvent read Over write Over;
property OnMouseLeave: TNotifyEvent read Out write Out;
property OnMouseDown: TMojEvent read Down write Down;
end;

procedure Register;

implementation

procedure TMojGradient3.MouseDown(var Message:TWMNCLButtonDown);
begin
if Assigned(Down) then OnMouseDown(Self, mbLeft,
[ssLeft],Mouse.CursorPos.X,Mouse.CursorPos.Y);
Message.Result:=1;

end;

procedure TMojGradient3.MouseEnter(var Message:TMessage);
begin
if Assigned(Over) then OnMouseEnter(Self);
Message.Result:=1;
end;

procedure TMojGradient3.MouseLeave(var Message:TMessage);
begin
(* Tak j/w *)
if Assigned(Out)then OnMouseLeave(Self);
Message.Result:=1;
end;

procedure Register;
begin //Rejestrowanie komponentu
RegisterComponents('Samples', [TMojGradient3]);
end;

end.

and test on my form like this:

procedure TForm1.MojGradient41MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ShowMessage('BlaBla');
end;
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing 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.