Merhaba arkadaşlar...
Bu soruyu diğer forumada yazmıştım ama orası kapanmış heral. Olsun buraya da yazarım.
Şimdi ben TCustomControl den türetilmiş bir bileşen yazıyorum. BU bileşenin içinde bi tane TEdit nesnesi var.Sıkıntım şu . Bu bileşeni kullanırken Object Inspector dan TEdit nesnesinin tüm özelliklerine ve dahada önemlisi Olaylarına erişmek ve kod yazmak istiyorum. Yani TLabelEdit bileşeni gibi. Hem Label a hemde Edite ulaşılabiliyor. Benim istediğimde bööyle bişey.Mümkünse azcık yardım.
Bu arada yeni forumumuzda gıcır gıcır valla.İnsan yazmaya kıyamıyo.
Bileşen sorunu
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
Merhaba,
dediğin tarzda birşey daha önce hiç denemedim ancak bununla ilgili birkaç bileşeni incelersen sanırım sana fikir verir.
http://www.torry.net adresinden source kodu olan birkaç bileşen indirip incele.
Umarım çözersin.
Kolay gelsin.
dediğin tarzda birşey daha önce hiç denemedim ancak bununla ilgili birkaç bileşeni incelersen sanırım sana fikir verir.
http://www.torry.net adresinden source kodu olan birkaç bileşen indirip incele.
Umarım çözersin.
Kolay gelsin.
Selam istediğin tarzda bir yapı için aşağıdaki örneği yolluyorum umarım işine yarar.
Mehmet
Mehmet
Kod: Tümünü seç
unit CaptionEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
StdCtrls;
type
TCaptionEdit = class(TEdit)
private
FCaption: TCaption;
FCaptionFont: TFont;
FCaptionGap: Integer;
FCaptionLabel: TLabel;
FCaptionYOffset: Integer;
procedure CMEnabledChanged(var Message: TMessage); message
CM_ENABLEDCHANGED;
procedure CMVisibleChanged(var Message: TMessage); message
CM_VISIBLECHANGED;
procedure DrawCaptionLabel;
procedure CaptionFontChangedEvent(Sender: TObject);
procedure SetCaption(const Value: TCaption);
procedure SetCaptionFont(const Value: TFont);
procedure SetCaptionGap(const Value: Integer);
procedure SetCaptionLabel(const Value: TLabel);
procedure SetCaptionYOffset(const Value: Integer);
procedure WMWindowPosChanged(var Message: TWMWindowPosChanged);
message WM_WINDOWPOSCHANGED;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Caption: TCaption read FCaption write SetCaption;
property CaptionFont: TFont read FCaptionFont write SetCaptionFont;
property CaptionGap: Integer read FCaptionGap write SetCaptionGap;
property CaptionYOffset: Integer read FCaptionYOffset write
SetCaptionYOffset;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TCaptionEdit]);
end;
{ TCaptionEdit }
constructor TCaptionEdit.Create(AOwner: TComponent);
begin
inherited;
FCaptionFont := TFont.Create;
FCaptionFont.OnChange := CaptionFontChangedEvent;
FCaptionLabel := TLabel.Create(Self);
FCaptionGap := 6;
FCaptionYOffset := 3;
end;
destructor TCaptionEdit.Destroy;
begin
FCaptionFont.Free;
inherited;
end;
procedure TCaptionEdit.CMEnabledChanged(var Message: TMessage);
begin
inherited;
DrawCaptionLabel;
end;
procedure TCaptionEdit.CMVisibleChanged(var Message: TMessage);
begin
inherited;
DrawCaptionLabel;
end;
procedure TCaptionEdit.DrawCaptionLabel;
begin
FCaptionLabel.Visible := Visible;
FCaptionLabel.Transparent := False;
FCaptionLabel.Parent := nil;
if FCaption <> '' then FCaptionLabel.Parent := Parent;
if FCaptionLabel.Parent <> nil then
begin
FCaptionLabel.Caption := FCaption;
FCaptionLabel.Font.Assign(FCaptionFont);
FCaptionLabel.Left := Left - FCaptionLabel.Width - FCaptionGap;
FCaptionLabel.Top := Top + FCaptionYOffset;
FCaptionLabel.Enabled := Enabled;
end;
end;
procedure TCaptionEdit.CaptionFontChangedEvent(Sender: TObject);
begin
DrawCaptionLabel;
end;
procedure TCaptionEdit.SetCaption(const Value: TCaption);
begin
if Value <> FCaption then
begin
FCaption := Value;
DrawCaptionLabel;
end;
end;
procedure TCaptionEdit.SetCaptionFont(const Value: TFont);
begin
if Value <> FCaptionFont then
begin
FCaptionFont := Value;
DrawCaptionLabel;
end;
end;
procedure TCaptionEdit.SetCaptionGap(const Value: Integer);
begin
if Value <> FCaptionGap then
begin
FCaptionGap := Value;
DrawCaptionLabel;
end;
end;
procedure TCaptionEdit.SetCaptionLabel(const Value: TLabel);
begin
if Value <> FCaptionLabel then
begin
FCaptionLabel := Value;
DrawCaptionLabel;
end;
end;
procedure TCaptionEdit.SetCaptionYOffset(const Value: Integer);
begin
if Value <> FCaptionYOffset then
begin
FCaptionYOffset := Value;
DrawCaptionLabel;
end;
end;
procedure TCaptionEdit.WMWindowPosChanged(var Message:
TWMWindowPosChanged);
begin
inherited;
if not (csDestroying in ComponentState) then
DrawCaptionLabel;
end;
end.
Teşekkür ederim arkadaşlar. Sorunu çözdüm. Gönderdiğiniz kodda da aslında yanıtı var. TCaption nesnesi.
Söyle tanımlamam gerkiyormuş;
Bu şekilde denedim istediğim oldu.TCaption nesnesi içinde aynı şey geçerli. TColor,TFont, Integer, Boolean ... aslında tüm tipler için aynı şeyi yapmıyormuyuz ? TEdit 'in ne farkı var ki. Bir an için şeyttiremedik heral.
Sağolun arkadaşlar...
Söyle tanımlamam gerkiyormuş;
Kod: Tümünü seç
published
property Edit: TEdit read FEdit write SetEdit;
Sağolun arkadaşlar...