公司要重写delphi 有这个必要吗??????????????????????????????????????????????(5分)

  • 主题发起人 主题发起人 wyn
  • 开始时间 开始时间
苦力活。不用脑力的工作。[:)]
 
脑子有屎!!!!!!!!!!!!!!!!!!!!!!!
 
很有必要的,如果你公司的客戶是非常難的就非常有必要!
客戶說要修改一下Tedit.color等,難道你每個控件都去修改!
所以寫一些控件基於這些VCL的自定義控件,要修改時改一下這個控件不就OK嗎??
!!!![:D]
 
哈哈。做这样的事确实是没有必要的。

看了文章的标题,吓了一跳。仔细一看,你们要做的简直是无用功。
我最欣赏的控件是raize,那就是专业级的感觉。但仔细看代码,人
家还是基于TControl来写。差不多将GUI部分重写了一轮儿。

如果你们想要这样做,那么,就别说是要重写VCL,应该说是再开发
一套界面控件包。——如果是后者,还是很有钱途的。
随便说一下,这样的控件包一定不要在中国卖。反正我一准儿是用D的。
哈哈哈。
 
我不知道你們要改寫到什麼程度。

但我們現在也在"開發自己的控件":有的僅僅是把默認字體改一下而已。
這樣一勞永逸,以後編程時省了很多設置的時間。(我們用的是 JB)
 
edymill:客戶說要修改一下Tedit.color等,難道你每個控件都去修改!
-------
其实这个并不难呀,只要一个for循环就搞定了的事。如果你愿意,写个通
用的Function来处理也是成的。
 
这样好麻烦啊
 
WYN,你在干什么?
 
[?][?][?][?][?][?][?][?][?][?][?][?]
 
[?][?][?][?][?][?]
 
[:D]你是在 Borland 公司吗?
 
你们公司应该去写操作系统.
 
to wyn:你贴的这个代码如何接啊!
 
to wyn: who to use
 
wyn兄的的swDBGrid只能在delphi6里使用。为什么你不继承一个???
看看我写的吧!
{********************************************}
{ }
{ ZebraDBGrid version 1.2 }
{ }
{ ELIESER MORAIS DOS REIS }
{ Copyright(C) 1999. All rights reserved. }
{ }
{ Please send bugs, comments and }
{ sugestions to: }
{ }
{ elieser@startrekmail.com }
{ }
{********************************************}

{############################################
# #
# THIS COMPONENT IS DEDICATED TO MY FRIEND #
# C A R L O S A U G U S T O #
# #
############################################}

unit zebdbgrid;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, DB;

type

TDrawFieldCellEvent = procedure (Sender: TObject; Field : TField;
Var Color : TColor; Var Font : TFont; Row: longint) of object;

Tzebdbgrid = class(TCustomDBGrid)
private
OldColumn:TColumn;
OldColor:TColor;

FZebra: Boolean;
FZebraColor, FZebraFontColor: TColor;
FSelectColor: TColor;
FDrawFieldCellEvent : TDrawFieldCellEvent;
procedure SetZebra(Value: Boolean);
procedure SetZebraColor(Value: TColor);
procedure SetZebraFontColor(Value: TColor);
procedure SetSelectColor(Value: TColor);
protected
procedure DrawCell(ACol, ARow: Longint; ARect: TRect;
AState: TGridDrawState); override;
procedure Scroll(Distance: Integer); override;

procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
property Canvas;
property SelectedRows;
published
property Align;
property BorderStyle;
property Color;
property Columns stored False;
property Ctl3D;
property DataSource;
property DefaultDrawing;
property DragCursor;
property DragMode;
property Enabled;
property FixedColor;
property Font;
property ImeMode;
property ImeName;
property Options;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ReadOnly;
property ShowHint;
property TabOrder;
property TabStop;
property TitleFont;
property Visible;
property Zebra: Boolean read FZebra write SetZebra default False;
property ZebraColor: TCOlor read FZebraColor write SetZebraColor
default clWindowText;
property ZebraFontColor: TColor read FZebraFontColor write SetZebraFontColor
default clAqua;
property SelectColor: TCOlor read FSelectColor write SetSelectColor
default clBlue;
property OnCellClick;
property OnColEnter;
property OnColExit;
property OnColumnMoved;
property OnDrawDataCell;
property OnDrawColumnCell;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEditButtonClick;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnStartDrag;
property OnTitleClick;

property OnMouseDown;
property OnMOuseMove;
property OnMouseUp;
property OnEndDock;
end;

procedure Register;

implementation
{
var
DrawBitmap: TBitmap;
UserCount: Integer;

procedure UsesBitmap;
begin
if UserCount = 0 then
DrawBitmap := TBitmap.Create;
Inc(UserCount);
end;

procedure ReleaseBitmap;
begin
Dec(UserCount);
end;

function Max(X, Y: Integer): Integer;
begin
Result := Y;
if X > Y then Result := X;
end;

procedure WriteText(ACanvas: TCanvas; ARect: TRect; DX, DY: Integer;
const Text: string; Alignment: TAlignment);
const
AlignFlags : array [TAlignment] of Integer =
( DT_LEFT or DT_WORDBREAK or DT_EXPANDTABS or DT_NOPREFIX,
DT_RIGHT or DT_WORDBREAK or DT_EXPANDTABS or DT_NOPREFIX,
DT_CENTER or DT_WORDBREAK or DT_EXPANDTABS or DT_NOPREFIX );
var
B, R: TRect;
I, Left: Integer;
begin
I := ColorToRGB(ACanvas.Brush.Color);
if GetNearestColor(ACanvas.Handle, I) = I then
begin
case Alignment of
taLeftJustify:
Left := ARect.Left + DX;
taRightJustify:
Left := ARect.Right - ACanvas.TextWidth(Text) - 3;
else
Left := ARect.Left + (ARect.Right - ARect.Left) shr 1
- (ACanvas.TextWidth(Text) shr 1);
end;
ExtTextOut(ACanvas.Handle, Left, ARect.Top + DY, ETO_OPAQUE or
ETO_CLIPPED, @ARect, PChar(Text), Length(Text), nil);
end else
begin
with DrawBitmap, ARect do
begin
Width := Max(Width, Right - Left);
Height := Max(Height, Bottom - Top);
R := Rect(DX, DY, Right - Left - 1, Bottom - Top - 1);
B := Rect(0, 0, Right - Left, Bottom - Top);
end;
with DrawBitmap.Canvas do
begin
Font := ACanvas.Font;
Font.Color := ACanvas.Font.Color;
Brush := ACanvas.Brush;
Brush.Style := bsSolid;
FillRect(B);
SetBkMode(Handle, TRANSPARENT);
DrawText(Handle, PChar(Text), Length(Text), R, AlignFlags[Alignment]);
end;
ACanvas.CopyRect(ARect, DrawBitmap.Canvas, B);
end;
end;
}
constructor Tzebdbgrid.Create(AOwner : TComponent);
begin
inherited Create(AOwner);

FZebra := True;
FZebraColor := clAqua;
FZebraFontColor := clWindowText;
FSelectColor := clYellow;

Options:=Options+[dgRowSelect]-[dgIndicator];

// UsesBitmap;
end;

destructor Tzebdbgrid.Destroy;
begin
// ReleaseBitmap;
inherited Destroy;
end;

procedure Tzebdbgrid.SetZebra(Value: Boolean);
begin
FZebra := Value;
Refresh;
end;

procedure Tzebdbgrid.SetZebraColor(Value: TColor);
begin
FZebraColor := Value;
Refresh;
end;

procedure Tzebdbgrid.SetZebraFontColor(Value: TColor);
begin
FZebraFontColor := Value;
Refresh;
end;

procedure Tzebdbgrid.SetSelectColor(Value: TColor);
begin
if not (dgRowSelect in Options) then
exit;
FSelectColor := Value;
Refresh;
end;

procedure Tzebdbgrid.DrawCell(ACol, ARow: Longint; ARect: TRect;
AState: TGridDrawState);
var
OldActive: Integer;
// Indicator: Integer;
Highlight: Boolean;
Value: string;
DrawColumn: TColumn;
// FrameOffs: Byte;
cl: TColor;
fn: TFont;
begin
if csLoading in ComponentState then
begin
Canvas.Brush.Color := Color;
Canvas.FillRect(ARect);
Exit;
end;

if (gdFixed in AState) and (ACol - IndicatorOffset < 0) then begin
inherited DrawCell(ACol, ARow, ARect, AState);
exit;
end;

if (dgTitles in Options) And (ARow = 0) then begin
inherited DrawCell(ACol, ARow, ARect, AState);
exit;
end;

if(dgTitles in Options) then
Dec(ARow);
Dec(ACol, IndicatorOffset);
if (gdFixed in AState) and ([dgRowLines, dgColLines] * Options =
[dgRowLines, dgColLines]) then
begin
InflateRect(ARect, -1, -1);
// FrameOffs := 1;
end;
// else
// FrameOffs := 2;
with Canvas do
begin
DrawColumn := Columns[ACol];
Font := DrawColumn.Font;
Brush.Color := DrawColumn.Color;
Font.Color := DrawColumn.Font.Color;
if FZebra and Odd(ARow) then
begin
Brush.Color := FZebraColor;
Font.Color := FZebraFontColor;
end;
//---
if (dgRowSelect in Options)and(gdSelected in AState)then
begin
Brush.color:=FSelectColor;
end;
//---
if (DataLink = nil) or not DataLink.Active then
FillRect(ARect) else
begin
Value := '';
OldActive := DataLink.ActiveRecord;
try
DataLink.ActiveRecord := ARow;
if Assigned(DrawColumn.Field) then
begin
Value := DrawColumn.Field.DisplayText;
if Assigned(FDrawFieldCellEvent) then
begin
cl := Brush.Color;
fn := Font;
FDrawFieldCellEvent(self, DrawColumn.Field, cl, fn, ARow);
Brush.Color := cl;
Font := fn;
end;
end;
Highlight := HighlightCell(ACol, ARow, Value, AState);
if Highlight and (not FZebra) then
begin
Brush.Color := clHighlight;
Font.Color := clHighlightText;
end;

if DefaultDrawing then
DefaultDrawColumnCell(ARect, ACol, DrawColumn, AState);

if Columns.State = csDefault then
DrawDataCell(ARect, DrawColumn.Field, AState);

DrawColumnCell(ARect, ACol, DrawColumn, AState);

finally
DataLink.ActiveRecord := OldActive;
end;
if DefaultDrawing and (gdSelected in AState)
and ((dgAlwaysShowSelection in Options) or Focused)
and not (csDesigning in ComponentState)
and not (dgRowSelect in Options)
and (UpdateLock = 0)
and (ValidParentForm(Self).ActiveControl = Self) then
Windows.DrawFocusRect(Handle, ARect);
end;
end;
if (gdFixed in AState) and ([dgRowLines, dgColLines] * Options =
[dgRowLines, dgColLines]) then
begin
InflateRect(ARect, 1, 1);
DrawEdge(Canvas.Handle, ARect, BDR_RAISEDINNER, BF_BOTTOMRIGHT);
DrawEdge(Canvas.Handle, ARect, BDR_RAISEDINNER, BF_TOPLEFT);
end;
end;

procedure Tzebdbgrid.Scroll(Distance: Integer);
begin
inherited Scroll(Distance);
if FZebra then Refresh;
end;

procedure Tzebdbgrid.MouseMove(Shift: TShiftState;X, Y: Integer);
var
Cell: TGridCoord;
DrawColumn: TColumn;
begin
inherited MouseMove(Shift, X, Y);

if csDesigning in ComponentState then
exit;

Cell := MouseCoord(X, Y);
if (Cell.X < 0) and (Cell.Y < 0) then
begin
Exit;
end;
DrawColumn :=Columns[Cell.x];
if OldColumn=nil then
begin
OldColumn:=DrawColumn;
OldColor:=DrawColumn.Title.Font.Color ;
Exit;
end;

if (OldColumn=DrawColumn) then
exit;
try
OldColumn.Title.Font.Color :=OldColor;
OldColor:=DrawColumn.Title.Font.Color ;
OldColumn:=DrawColumn;
DrawColumn.Title.Font.Color :=clBlue;
except
OldColumn:=DrawColumn;
DrawColumn.Title.Font.Color :=clBlue;

end;
end;

procedure Register;
begin
RegisterComponents('Yyy', [Tzebdbgrid]);
end;

end.
 
能不能不要贴这么长的代码啊,要贴去 http://delphi.itschem.com/
建议两位把你们的代码发到那里去,把这里的删掉吧,翻页太麻烦了
 
我完全同意改delphi的帮助,全中文的话可以出书啊
 
http://delphi.itschem.com/dispdoc.asp?id=195
 
后退
顶部