Komponens váz

Top  Previous  Next

 

Ezt csak másold be, majd írd át, adj hozzá, vagy törölj belőle. Kis időmegtakarítás!

 


 

TShadeModel = (smFlat,smSmooth);

 

TPaintEvent      = procedure(Sender: TObject) of object;

TChangeWindow    = procedure(Sender: TObject; Cent: TPoint2D;  Zoom: Double) of object;

 

TAL_OpenGL = class(TCustomControl)

private

   procedure WMEraseBkGnd(var Message:TWMEraseBkGnd); message WM_ERASEBKGND;

   procedure WMPaint(var Msg: TWMPaint); message WM_PAINT;

   procedure WMSize(var Msg: TWMSize); message WM_SIZE;

   Procedure CMChildkey( Var msg: TCMChildKey ); message CM_CHILDKEY;

   procedure CMMouseEnter(var msg: TMessage); message CM_MOUSEENTER;

   procedure CMMouseLeave(var msg: TMessage); message CM_MOUSELEAVE;

protected

   procedure MouseDown(Button: TMouseButton; Shift: TShiftState;

     X, Y: Integer); override;

   procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;

   procedure MouseUp(Button: TMouseButton; Shift: TShiftState;

     X, Y: Integer); override;

   procedure KeyDown(var Key: Word;Shift: TShiftState); override;

   procedure KeyPress(var Key: Char); override;

   procedure DblClick;  override;

public

   constructor Create(AOwner: TComponent); override;

   destructor Destroy; override;

   procedure Paint; override;

published

   property CentralCross  : boolean   read FCentralCross write SetCentralCross;

   property OnMouseEnter  : TNotifyEvent read FOnMouseEnter write FOnMouseEnter;

   property OnMouseLeave  : TNotifyEvent read FOnMouseLeave write FOnMouseLeave;

   property OnPaint       : TPaintEvent read FOnPaint write FOnPaint;

end;

 

procedure Register;

 

implementation

 

procedure Register;

begin

RegisterComponents('AL', [TAL_OpenGL]);

end;

 

procedure TAL_OpenGL.CMChildkey(var msg: TCMChildKey);

var dx,dy: integer;

   k:integer;

begin

k:=16;

dx := 0; dy:=0;

msg.result := 1; // declares key as handled

Case msg.charcode of

   VK_ADD     : Zoom:=2*Zoom;

   VK_SUBTRACT: Zoom:=0.5*Zoom;

   VK_LEFT    : dx:=-k;

   VK_RIGHT   : dx:=k;

   VK_UP      : dy:=-k;

   VK_DOWN    : dy:=k;

Else

   msg.result:= 0;

   inherited;

End;

if (dx<>0) or (dy<>0) then

    ShiftWindow(dx,dy);

end;

 

procedure TAL_OpenGL.CMMouseEnter(var msg: TMessage);

begin

if TabStop then Setfocus;

if Assigned(FOnMouseEnter) then FOnMouseEnter(Self);

end;

 

procedure TAL_OpenGL.CMMouseLeave(var msg: TMessage);

begin

if Assigned(FOnMouseLeave) then FOnMouseLeave(Self);

end;

 

procedure TAL_OpenGL.Paint;

begin

If componentstate=[csDesigning] then begin

end;

    If Assigned(FOnPaint) then FOnPaint(Self);

end;

 

       

 

procedure TAL_OpenGL.WMEraseBkGnd(var Message: TWMEraseBkGnd);

begin

Message.Result := 1

end;

 

end.