1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80:
| unit Obutton;
interface
uses SysUtils, Classes,graphics, Controls;
type TObutton = class(TCustomControl) private pressed: boolean; color: Tcolor; protected procedure paint; override; procedure mousedown(button:tmousebutton; shift:tshiftstate; x,y:integer);override; procedure mouseup (button: tmousebutton; shift:tshiftstate; x,y :integer);override; public constructor create (Aowner: tcomponent) ; override ; published end;
procedure Register;
implementation const OColor: Array[1..3] of tcolor =(clblack, clgray,clwhite);
procedure Register; begin RegisterComponents('Zusätzlich', [TObutton]); end; constructor tobutton.create (AOwner: TComponent) ; begin inherited create (Aowner); Color := clbtnface; canvas.brush.color := color; pressed:= false; setBounds (0,0,50,50); end;
procedure tobutton.paint; var i:integer; begin if pressed then for i := 1 to 3 do begin Canvas.pen.color := Ocolor[(i+1)div 2] ; canvas.arc (i,i,width-i, height-i,i,i,i,i); end else for i := 1 to 3 do begin Canvas.pen.color := ocolor[i]; canvas.arc (i,i,width-i, height-i,i,i,i,i); end; canvas.ellipse (3,3,width-3, Height-3); end; procedure tobutton.mousedown(button: tmousebutton; Shift: tshiftstate; x,y:integer); begin inherited mousedown (button, shift,x,y); if button = mbleft then begin Pressed:= true; Paint; end; end;
procedure tobutton.mouseup (button: tmousebutton; shift:tshiftstate; x,y :integer); begin inherited Mouseup (button, shift,x,y); pressed:= false; paint; end;
end. |