问一个很初级的问题,大家不要笑我,我是新人(10分)

T

tttttt6

Unregistered / Unconfirmed
GUEST, unregistred user!
下载的那些别人做的控件是怎么用的啊??我下载了别人的控件,但是不知道怎么在我的程序里调用这些控件
 
L

lichaogang

Unregistered / Unconfirmed
GUEST, unregistred user!
安装,Delphi菜单上有一个Component项,下面有install component子项。
 
A

app2001

Unregistered / Unconfirmed
GUEST, unregistred user!
我认为,要先打开人家的控件,有些控件只要点SETUP就可以了,但是有些控件就需要手工安装,这样的情况下,你最好先看一下人家控件包中的说明文件,一般都有教你如何安装的,那些三方控件,能在很大程度上减轻你的工作量,帮你实现很多它们提供的功能而不需要你做太多的工作
 
T

tttttt6

Unregistered / Unconfirmed
GUEST, unregistred user!
安装完成后怎么使用他们的控件啊?怎么知道哪一个是他们的?
 
A

app2001

Unregistered / Unconfirmed
GUEST, unregistred user!
这玩意你安装成功后就会明白了,就好象小孩问结婚洞房是怎么回事一样,讲不清楚的,嘿,开个玩笑
 
O

oldsheep35

Unregistered / Unconfirmed
GUEST, unregistred user!
控件的安装方法有很多的!
建议你可以在论坛或其他地方搜一下这些方法!
我简单的说一下:有Setup的最好,(但有些还要手工加路径)
有些就是dpk文件,打开Install
有些要Add bpl文件
唉,还没有说完呢!不过你需要慢慢来!
app2001真是有幽默感!
 
T

tttttt6

Unregistered / Unconfirmed
GUEST, unregistred user!
全部安装完成后,我怎么知道我安装的控件在哪个组件栏里啊??
不会是叫我一个一个找吧???
 
A

app2001

Unregistered / Unconfirmed
GUEST, unregistred user!
似乎那些组件栏也不是很多吧,如果你对它熟的话,是很容易发现多了些什么的
 
O

oldsheep35

Unregistered / Unconfirmed
GUEST, unregistred user!
如果有pas文件
搜索一下里面的Regsiter方法的实现
那个“[]”中就是这个组件栏的名称了
没有的话可以在install package中找!
 
T

tttttt6

Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我控件的源码,它到底在组件栏的哪里??
unit fcLabel;
{
//
// Components : TfcCustomLabel, TfcLabel
//
// Copyright (c) 1999 by Woll2Woll Software
//
}
interface
{$i fcIfDef.pas}
{$Warnings Off}
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Math, fcCommon, fcText, db, dbctrls,
{$ifdef fcDelphi6Up}
VDBConsts
{$else
}
dbconsts
{$endif};
type
TfcCustomLabel = class(TGraphicControl)
private
// Property Storage Variables
FAutoSize: Boolean;
FFocusControl: TWinControl;
FTextOptions: TfcCaptionText;
FOnMouseEnter: TNotifyEvent;
FOnMouseLeave: TNotifyEvent;
function GetTransparent: Boolean;
procedure SetFocusControl(Value: TWinControl);
procedure SetTransparent(Value: Boolean);
// Message Handlers
procedure CMTextChanged(var Message: TMessage);
message CM_TEXTCHANGED;
procedure CMFontChanged(var Message: TMessage);
message CM_FONTCHANGED;
procedure CMDialogChar(var Message: TCMDialogChar);
message CM_DIALOGCHAR;
procedure CMMouseEnter(var Message: TWMMouse);
message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TWMMouse);
message CM_MOUSELEAVE;
protected
// Virtual Property Access Methods
procedure SetAutoSize(Value: Boolean);
virtual;
function GetLabelText: string;
virtual;
// Virtual Methods
procedure MouseEnter;
virtual;
procedure MouseLeave;
virtual;
// Overriden Methods
procedure Loaded;
override;
procedure Notification(AComponent: TComponent;
Operation: TOperation);
override;
procedure Paint;
override;
procedure WndProc(var Message: TMessage);
override;
property Canvas;
public
Patch: Variant;
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
function GetTextEnabled: Boolean;
virtual;
procedure AdjustBounds;
virtual;
property AutoSize: Boolean read FAutoSize write SetAutoSize default True;
property Caption;
property FocusControl: TWinControl read FFocusControl write SetFocusControl;
property TextOptions: TfcCaptionText read FTextOptions write FTextOptions;
property Transparent: Boolean read GetTransparent write SetTransparent default False;
property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
end;

TfcDBCustomLabel = class(TfcCustomLabel)
private
FDataLink: TFieldDataLink;
procedure DataChange(Sender: TObject);
function GetDataField: string;
function GetDataSource: TDataSource;
function GetField: TField;
function GetFieldText: string;
procedure SetDataField(const Value: string);
procedure SetDataSource(Value: TDataSource);
procedure CMGetDataLink(var Message: TMessage);
message CM_GETDATALINK;
protected
function GetLabelText: string;
override;
procedure Loaded;
override;
procedure Notification(AComponent: TComponent;
Operation: TOperation);
override;
procedure SetAutoSize(Value: Boolean);
override;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
function ExecuteAction(Action: TBasicAction): Boolean;
override;
function UpdateAction(Action: TBasicAction): Boolean;
override;
function UseRightToLeftAlignment: Boolean;
override;
property Field: TField read GetField;
// published
// property Align;
// property Anchors;
// property AutoSize default False;
// property AutoSize;// default False;
// property BiDiMode;
// property Caption;
// property Color;
// property Constraints;
property DataField: string read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;
// property DragCursor;
// property DragKind;
// property DragMode;
// property Enabled;
// property FocusControl;
// property Font;
// property ParentBiDiMode;
// property ParentColor;
// property ParentFont;
// property ParentShowHint;
// property PopupMenu;
// property TextOptions;
// property Transparent;
// property ShowHint;
// property Visible;
// property OnClick;
// property OnContextPopup;
// property OnDblClick;
// property OnDragDrop;
// property OnDragOver;
// property OnEndDock;
// property OnEndDrag;
// property OnMouseEnter;
// property OnMouseLeave;
// property OnMouseDown;
// property OnMouseMove;
// property OnMouseUp;
// property OnStartDock;
// property OnStartDrag;
end;

TfcLabel = class(TfcDBCustomLabel)
published
property Align;
property Anchors;
property AutoSize;
// property AutoSize default False;
property BiDiMode;
property Caption;
property Color;
property Constraints;
property DataField;
property DataSource;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property FocusControl;
property Font;
property ParentBiDiMode;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property TextOptions;
property Transparent;
property ShowHint;
property Visible;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
end;


implementation
// IUnknown
constructor TfcCustomLabel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csOpaque, csReplicatable];
FTextOptions := TfcCaptionText.Create(MakeCallbacks(Invalidate, AdjustBounds, GetTextEnabled),
Canvas, Font);
FAutoSize := True;
Height := 17;
Width := 65;
end;

destructor TfcCustomLabel.Destroy;
begin
FTextOptions.Free;
inherited;
end;

procedure TfcCustomLabel.Paint;
begin
with Canvasdo
begin
if not Transparent then
begin
Brush.Color := Self.Color;
Brush.Style := bsSolid;
FillRect(ClientRect);
end;
Brush.Style := bsClear;
TextOptions.Text := GetLabelText;
TextOptions.TextRect := ClientRect;
if TextOptions.DoubleBuffered then
TextOptions.UpdateFont(Self.Font);
// Correct for alignment
TextOptions.Draw;
end;
end;

function TfcCustomLabel.GetTextEnabled: Boolean;
begin
result := Enabled;
end;

function TfcCustomLabel.GetLabelText: string;
begin
Result := Caption;
end;

procedure TfcCustomLabel.AdjustBounds;
var
DC: HDC;
ARect: TRect;
X: Integer;
begin
if not (csReading in ComponentState) and FAutoSize then
begin
DC := GetDC(0);
Canvas.Handle := DC;
ARect := TextOptions.CalcDrawRect(True);
Canvas.Handle := 0;
ReleaseDC(0, DC);
x := Left;
if TextOptions.Alignment = taRightJustify then
x := (Left + Width) - fcRectWidth(ARect);
SetBounds(x, Top, fcRectWidth(ARect), fcRectHeight(ARect));
end;
end;

procedure TfcCustomLabel.SetAutoSize(Value: Boolean);
begin
if FAutoSize <> Value then
begin
FAutoSize := Value;
AdjustBounds;
Invalidate;
end;
end;

function TfcCustomLabel.GetTransparent: Boolean;
begin
result := not (csOpaque in ControlStyle);
end;

procedure TfcCustomLabel.SetFocusControl(Value: TWinControl);
begin
FFocusControl := Value;
if Value <> nil then
Value.FreeNotification(Self);
end;

procedure TfcCustomLabel.SetTransparent(Value: Boolean);
begin
if Transparent <> Value then
begin
if Value then
ControlStyle := ControlStyle - [csOpaque] else
ControlStyle := ControlStyle + [csOpaque];
Invalidate;
end;
end;

procedure TfcCustomLabel.Loaded;
begin
inherited;
AdjustBounds;
end;

procedure TfcCustomLabel.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FFocusControl) then
FFocusControl := nil;
end;

procedure TfcCustomLabel.CMTextChanged(var Message: TMessage);
begin
TextOptions.Text := Caption;
AdjustBounds;
Invalidate;
end;

procedure TfcCustomLabel.CMFontChanged(var Message: TMessage);
begin
inherited;
AdjustBounds;
end;

procedure TfcCustomLabel.CMDialogChar(var Message: TCMDialogChar);
begin
if (FFocusControl <> nil) and Enabled and (toShowAccel in TextOptions.Options) and
IsAccel(Message.CharCode, Caption) then
with FFocusControldo
if CanFocus then
begin
SetFocus;
Message.Result := 1;
end;
end;

procedure TfcCustomLabel.CMMouseEnter(var Message: TWMMouse);
begin
inherited;
MouseEnter;
end;

procedure TfcCustomLabel.CMMouseLeave(var Message: TWMMouse);
begin
inherited;
MouseLeave;
end;

procedure TfcCustomLabel.MouseEnter;
begin
if Assigned(FOnMouseEnter) then
FOnMouseEnter(self);
end;

procedure TfcCustomLabel.MouseLeave;
begin
if Assigned(FOnMouseLeave) then
FOnMouseLeave(self);
end;

procedure TfcCustomLabel.WndProc(var Message: TMessage);
begin
inherited;
end;

constructor TfcDBCustomLabel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csReplicatable];
// AutoSize := False;
FDataLink := TFieldDataLink.Create;
FDataLink.Control := Self;
FDataLink.OnDataChange := DataChange;
end;

destructor TfcDBCustomLabel.Destroy;
begin
FDataLink.Free;
FDataLink := nil;
inherited Destroy;
end;

procedure TfcDBCustomLabel.Loaded;
begin
inherited Loaded;
if (csDesigning in ComponentState) then
DataChange(Self);
end;

procedure TfcDBCustomLabel.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (FDataLink <> nil) and
(AComponent = DataSource) then
DataSource := nil;
end;

function TfcDBCustomLabel.UseRightToLeftAlignment: Boolean;
begin
Result := DBUseRightToLeftAlignment(Self, Field);
end;

procedure TfcDBCustomLabel.SetAutoSize(Value: Boolean);
begin
if AutoSize <> Value then
begin
if Value and FDataLink.DataSourceFixed then
DatabaseError(SDataSourceFixed);
inherited SetAutoSize(Value);
end;
end;

function TfcDBCustomLabel.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;

procedure TfcDBCustomLabel.SetDataSource(Value: TDataSource);
begin
if not (FDataLink.DataSourceFixed and (csLoading in ComponentState)) then
FDataLink.DataSource := Value;
if Value <> nil then
Value.FreeNotification(Self);
end;

function TfcDBCustomLabel.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;

procedure TfcDBCustomLabel.SetDataField(const Value: string);
begin
FDataLink.FieldName := Value;
end;

function TfcDBCustomLabel.GetField: TField;
begin
Result := FDataLink.Field;
end;

function TfcDBCustomLabel.GetFieldText: string;
function IsMemoField: boolean;
begin
result:= (FDataLink.Field<>Nil) and (FDataLink.Field is TBlobField)
{$ifdef win32}
and
(TBlobField(FDataLink.Field).BlobType=ftMemo)
{$endif}
end;
begin
if FDataLink.Field <> nil then
begin
if IsMemoField then
Result := FDataLink.Field.AsString
else
Result := FDataLink.Field.DisplayText;
end
else
begin
Result:= Caption;
if (Result='') and (DataSource<>nil) and
(csDesigning in ComponentState) then
Result := Name
end
end;

procedure TfcDBCustomLabel.DataChange(Sender: TObject);
begin
Caption := GetFieldText;
end;

function TfcDBCustomLabel.GetLabelText: string;
begin
if csPaintCopy in ControlState then
Result := GetFieldText else
Result := Caption;
end;

procedure TfcDBCustomLabel.CMGetDataLink(var Message: TMessage);
begin
Message.Result := Integer(FDataLink);
end;

function TfcDBCustomLabel.ExecuteAction(Action: TBasicAction): Boolean;
begin
Result := inherited ExecuteAction(Action) or (FDataLink <> nil) and
FDataLink.ExecuteAction(Action);
end;

function TfcDBCustomLabel.UpdateAction(Action: TBasicAction): Boolean;
begin
Result := inherited UpdateAction(Action) or (FDataLink <> nil) and
FDataLink.UpdateAction(Action);
end;
end.
 
A

app2001

Unregistered / Unconfirmed
GUEST, unregistred user!
你的组件栏里有没有Woll2Woll这个东西?
 
O

oldsheep35

Unregistered / Unconfirmed
GUEST, unregistred user!
"1stClass"!中的fcLabel嘛
 
T

tttttt6

Unregistered / Unconfirmed
GUEST, unregistred user!
你是从哪里看出来是"1stClass"!中的fcLabel的????
 
O

oldsheep35

Unregistered / Unconfirmed
GUEST, unregistred user!
这个单元只知道是fcLabel
这个控件组在fClass.pas(Unit)中一起注册的
你打开一看就知道了
 
T

tttttt6

Unregistered / Unconfirmed
GUEST, unregistred user!
安装成功了,找到了这个控件,但是使用的时候为什么总显示[Fatal Error] Unit1.pas(7): File not found: 'RzButton.dcu'
我看了,明明有RzButton.dcu这个文件,为什么总提示说找不到它???
 
C

clsfox

Unregistered / Unconfirmed
GUEST, unregistred user!
将'RzButton.dcu'的目录设成DELPHI的$DELPHI/目录或将该文件拷贝到$DELPHI/BPL目录下
 
C

chenshaizi

Unregistered / Unconfirmed
GUEST, unregistred user!
我看了,明明有RzButton.dcu这个文件,为什么总提示说找不到它???
一般需要把这个编译后的单位文件所在的目录加到DELPHI的搜索路径里。
Tools-->Environment Options->library点击第一个“...”样子的按键,然后把目录输入到唯一的一个文本框里ADD就OK了。另外:
[DELPHI]如何安装控件
安装方法:
1.对于单个控件,Component-->install component..-->PAS或DCU文件-->install
2.对于带*.dpk文件的控件包,File-->open(下拉列表框中选*.dpk)-->install即可.
3.对于带*.dpl文件的控件包,Install Packages-->Add-->dpl文件名即可。
4.如果以上Install按钮为失效的话,试试Compile按钮。
5.是run time lib则在option下的packages下的runtimepackes加之.
如果编译时提示文件找不到的话,一般是控件的安装目录不在delphi的Lib目录中,有两种方法可以解决:
1.把安装的原文件拷入到delphi的Lib目录下。
2.或者Tools-->Environment Options中把控件原代码路径加入到Delphi的Lib目录中即可。
 
T

tttttt6

Unregistered / Unconfirmed
GUEST, unregistred user!
多人接受答案了。
 
顶部