Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.05.15;
Скачать: CL | DM;

Вниз

caption   Найти похожие ветки 

 
tytus ©   (2003-05-01 17:46) [0]

Как для нового (создаваемого) компонента написать параметр Caption? Когда запускаю прогу, то выдает ошибку ERead Error Property Caption does not exists. Я прописал в Published Property Caption;?????


 
Cr@sh ©   (2003-05-01 18:09) [1]

Код в студию! (ц)


 
tytus ©   (2003-05-01 18:18) [2]

to Cr@sh
Вот кодunit MB;

interface

uses
SysUtils, Windows, Messages, Classes, Controls, Forms, Graphics, StdCtrls,
ExtCtrls, CommCtrl;

type
TMButton = class(TGraphicControl)
private
{ Private declarations }
MouseOnControl:Boolean;
FOnMouseEnter:TNotifyEvent;
FOnMouseLeave:TNotifyEvent;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure ButtonTextDraw(Canvas: TCanvas; const Caption: string;
TextBounds: TRect);

protected
{ Protected declarations }
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 Paint; override;

public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Click; override;
property OnMouseEnter:TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave:TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
published
{ Published declarations }
property OnClick;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;

property ParentShowHint;
property ShowHint;
end;

procedure Register;

implementation
var PaintRect:TRect;
procedure Register;
begin
RegisterComponents("MaPage", [TMButton]);
end;

constructor TMButton.Create(AOwner:TCOmponent);
begin inherited Create(AOwner);
MouseOnControl:=False;
setbounds(10,10,75,25);
Color:=$00efd3c6;

end;
destructor TMButton.Destroy;
begin

inherited Destroy;
end;

procedure TMButton.Paint;
var i:integer;tb:TRect;
begin
PaintRect:=ClientRect;
canvas.Pen.Color:=color;
with canvas do begin
for i:=paintrect.Top to (paintrect.Top+paintrect.Bottom) do begin
MoveTo(paintrect.Left,i);
LineTo(paintrect.Right,i);
Pen.Color:=canvas.Pen.Color-$6ff;
end; end;
frame3d(canvas,paintrect,$00efd3c6,$00c66931,2);
tb:=Rect(0,0,paintrect.Right-paintrect.Left,0);
buttontextdraw(canvas,Caption,tb);
end;

procedure TMButton.Click;
begin

inherited click;
end;

procedure TMButton.CMMouseEnter(var Message:TMessage);
begin
MouseOnControl:=True;
color:=color+$2eff;
repaint;
end;

procedure TMButton.CMMouseLeave(var Message:TMessage);
begin
MouseOnControl:=False;
color:=$00efd3c6;
repaint;
end;

procedure TMButton.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin if MouseOnControl=true then begin
paintrect:=clientrect;
Frame3d(canvas,paintrect,$00c66931,$00efd3c6,2);
inherited MouseDown(Button, Shift, X, Y);end;
{invalidate;}
end;

procedure TMButton.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
repaint;
inherited MouseUp(Button, Shift, X, Y);
{ invalidate;}
end;

procedure TMButton.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
inherited MouseMove(Shift, X, Y);
{invalidate; }
end;
procedure TMButton.ButtonTextDraw(Canvas: TCanvas; const Caption: string;
TextBounds: TRect);
begin
with canvas do begin
brush.Style:=bsClear;
OffSetRect(TextBounds,1,1);
font.Color:=clblack;
DrawText(handle,PChar(Caption),Length(Caption),TextBounds,
DT_CENTER or DT_VCENTER);
end;
end;

end.



Страницы: 1 вся ветка

Текущий архив: 2003.05.15;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.013 c
7-47018
asdf622
2003-03-20 17:08
2003.05.15
Очистка памяти. Как сделать?


7-47010
Vlad Oshin
2003-03-19 12:20
2003.05.15
Как отключать оборудование. (например, Сетевую плату.)


14-46915
Шурыгин Евгений
2003-04-22 17:38
2003.05.15
Как создать переводчик типа сократа 97?


4-47052
_BasiL_
2003-03-18 09:27
2003.05.15
Перехват потока открытия файлов


3-46650
Wedos
2003-04-22 10:50
2003.05.15
Сохранение базы