31. august 2003 - 12:23
#2
Godt nok bortset fra at det ikke virker.
Her er nogle af de fejl der dukker op.
*********
requires
// vcl,
vcldb,
adortl,
Vcl40;
Windows,
Classes,
ADOInt,
ADODB,
{$IFDEF MDAC26}
ADO26_TLB,
{$ENDIF}
DB;
VH
SprøgerJørgen
31. august 2003 - 15:34
#6
I går hentede jeg sådan en her men hvad skal den bruges til ?
Hvor skal den installeres ?
Når engang jeg bliver rig ??? vil jeg have en Delphi 7.0 Proff
VH
SpørgerJørgen
{***********************************************************
* Label3dBorder version 1.0 - 32 bit *
* Copyright (C) April 22, 1997 Steen Hjelmstrand *
* *
***********************************************************
* Label with possibility of setting 5 different kinds *
* of 3-dimensional borders and an option of horisontal *
* alignment of the caption. *
* *
* Border: *
* Set BorderStyle"-property in the ObjectInspector. *
* *
* Horisontal alignment of caption: *
* Set "HorisontalAlign"-property in the ObjectInspector. *
* *
* NOTICE: *
* 1) If you set the horisontal alignment to "haCenter" or *
* "haBottom" then wordwrapping is not possible. If Wordwrap *
* is set to "True" the setting will be ignored. *
* *
* 2) This label has no "AutoSize"-property. I never use the *
* "AutoSize"-property myself, as I don't find it reliable, *
* so I didn't want to waste my time implementing it. *
* Sorry about that, if you happen to be an Autosize- *
* fanatic :-) *
* *
* If you have comments or find bugs please email me: *
* stone@image.dk *
*************************************************************}
unit Label3dB;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
StdCtrls, ExtCtrls;
type
TBorderStyle = (bsNone, bsLight, bsMedium, bsHeavy, bsFrame, bsRaisedFrame);
THorisontalAlign = (haTop, haCenter, haBottom);
TLabel3DBorder = class(TCustomLabel)
private
FHorisontalAlign : THorisontalAlign;
FBorderStyle : TBorderStyle;
procedure SetBorderStyle(Value: TBorderStyle);
procedure SetHorisontalAlign(Value: THorisontalAlign);
procedure DoDrawText(var Rect: TRect; Flags: Word);
{ Private declarations }
protected
procedure Paint; override;
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
{ Public declarations }
published
{ own properties}
property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsNone;
property HorisontalAlign: THorisontalAlign read FHorisontalAlign write SetHorisontalAlign default haTop;
{ inherited properties }
property Align;
property Alignment;
property Caption;
property Color;
property Cursor;
property DragCursor;
property DragMode;
property Enabled;
property FocusControl;
property Font;
property ParentColor;
property ParentFont;
property ParentShowHint;
property ShowAccelChar;
property ShowHint;
property Transparent;
property Visible;
property WordWrap;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
{ Published declarations }
end;
procedure Register;
implementation
constructor TLabel3dBorder.Create;
begin
inherited Create(AOwner);
FBorderStyle := bsNone;
AutoSize := False;
Height := 21;
Width := 84;
end;
procedure TLabel3dBorder.Paint;
const
Alignments: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
WordWraps: array[Boolean] of Word = (0, DT_WORDBREAK);
HorAlign: array[THorisontalAlign] of Word =
(0, DT_VCENTER or DT_SINGLELINE, DT_BOTTOM or DT_SINGLELINE);
var
Rect: TRect;
begin
with Canvas do begin
if not Transparent then begin
Brush.Color := Self.Color;
Brush.Style := bsSolid;
FillRect(ClientRect);
end;
Brush.Style := bsClear;
Rect := ClientRect;
case Ord(FBorderStyle) of
0:with Rect do InflateRect(Rect, -2, -2);
1:begin
Frame3D(Canvas, Rect, clBtnShadow, clBtnHighlight, 1);
with Rect do InflateRect(Rect, -1, -1);
end;
2:begin
Frame3D(Canvas, Rect, clBlack, clBtnHighlight, 1);
with Rect do InflateRect(Rect, -1, -1);
end;
3:begin
Frame3D(Canvas, Rect, clBtnShadow, clBtnHighlight, 1);
Frame3D(Canvas, Rect, clBlack, clBtnFace, 1);
end;
4:begin
Frame3D(Canvas, Rect, clBtnShadow, clBtnHighlight, 1);
Frame3D(Canvas, Rect, clBtnHighlight, clBtnShadow, 1);
end;
5:begin
Frame3D(Canvas, Rect, clBtnHighlight, clBtnShadow, 1);
Frame3D(Canvas, Rect, clBtnShadow, clBtnHighlight, 1);
end;
end;
with Rect do InflateRect(Rect, -1, -1);
DoDrawText(Rect, DT_EXPANDTABS or WordWraps[WordWrap] or
Alignments[Alignment] or HorAlign[FHorisontalAlign]);
end;
end;
procedure TLabel3dBorder.DoDrawText(var Rect: TRect; Flags: Word);
var
Text: string;
begin
Text := GetLabelText;
if (Flags and DT_CALCRECT <> 0) and ((Text = '') or ShowAccelChar and
(Text[1] = '&') and (Text[2] = #0)) then Text := Text + ' ';
if not ShowAccelChar then Flags := Flags or DT_NOPREFIX;
Canvas.Font := Font;
if not Enabled then Canvas.Font.Color := clGrayText;
DrawText(Canvas.Handle, PChar(Text), Length(Text), Rect, Flags);
end;
procedure TLabel3dBorder.SetBorderStyle(Value: TBorderStyle);
begin
if FBorderStyle <> Value then begin
FBorderStyle := Value;
Invalidate;
end;
end;
procedure TLabel3dBorder.SetHorisontalAlign(Value: THorisontalAlign);
begin
if FHorisontalAlign <> Value then begin
FHorisontalAlign := Value;
Invalidate;
end;
end;
procedure Register;
begin
RegisterComponents('Samples', [TLabel3DBorder]);
end;
end.
31. august 2003 - 15:44
#7
Du starter med at åbne uniten i Delphi og gemme den i en undermappe i din Delhi-mappe (lav evt. en mappe med navnet "Components").
Så går du op i menuen "Component", mens uniten stadigvæk er åbnet og aktuel (under det nye navn), og vælger "Install Component".
Vælg nu fanebladet "Into new package".
Feltet "Unit file name:" er udfyldt, hvis du har gjort det rigtigt.
Du kopierer nu indholdet i "Unit file name:" (Ctrl+C) til "Package file name:", men laver filnavn og endelse om, så der i stedet for f.eks. "C:\Programmer\Borland\Delphi4\Components\Extra\ColorPanel.pas" kommer til at stå "C:\Programmer\Borland\Delphi4\Components\Extra\ColorPanel_D4.dpk".
Tryk på OK.
Sig "OK" til den boks der kommer.
Når du lukker din nye package, så sig ja til at gemme.