home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1999 January
/
Chip_1999-01_cd.bin
/
zkuste
/
delphi
/
QDB
/
QDBG.ZIP
/
qdbgreg.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1998-07-29
|
5KB
|
175 lines
unit qdbgreg;
interface
uses
DsgnIntf;
type
TQDBGridEditor = class(TComponentEditor)
public
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
procedure ExecuteVerb(Index: Integer); override;
end;
procedure Register;
implementation
uses
SysUtils, Classes, Dialogs, Forms, TypInfo, Controls,
QDBView, QDBGrids, QDBGEdt;
(*
{$IFDEF WIN32}
{$R QDBVREG.R32}
{$ELSE}
{$R QDBVREG.R16}
{$ENDIF}
*)
function TQDBGridEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result:='Edit ' + Component.Name;
1: Result:='Load field defintions from QDB file';
else
end;
end;
function TQDBGridEditor.GetVerbCount: Integer;
var
t: TQDBItem;
begin
Result:=0;
if (Component as TQDBGrid).QDBItem = nil then
Exit;
t:=TQDBItem.Create(nil);
try
t.ReadOnly:=true;
t.FileName:=(Component as TQDBGrid).QDBItem.Filename;
t.FetchStructure;
if t.FieldCount > 0 then
Result := 2;
finally
t.Free;
end;
end;
type
THack = class(TQDBGrid);
procedure TQDBGridEditor.ExecuteVerb(Index: Integer);
var
D: TQDBGridEditDlg;
t: TQDBItem;
x: TQDBItem;
n: integer;
wasreadonly: boolean;
begin
case Index of
0:
begin
D := TQDBGridEditDlg.Create(Application);
try
with Component as TQDBGrid do
begin
D.Caption := Owner.Name + '.' + Name + D.Caption;
D.QDBGrid.Color:=Color;
D.QDBGrid.DefaultColWidth:=DefaultColWidth;
D.QDBGrid.DisplayThumbnails:=DisplayThumbnails;
D.QDBGrid.FixedColor:=FixedColor;
D.QDBGrid.Font:=Font;
D.QDBGrid.MatchRowHeightToFont:=MatchRowHeightToFont;
D.QDBGrid.Options:=Options + [QDBGrids.goSelectColumns];
D.QDBGrid.TitleFont:=TitleFont;
THack(D.QDBGrid).SetColumnCount(ColCount);
for n:=0 to Columns.Count-1 do
begin
D.QDBGrid.Columns[n].Alignment:=Columns[n].Alignment;
D.QDBGrid.Columns[n].ButtonStyle:=Columns[n].ButtonStyle;
D.QDBGrid.Columns[n].Color:=Columns[n].Color;
D.QDBGrid.Columns[n].DisplayMask:=Columns[n].DisplayMask;
D.QDBGrid.Columns[n].DropDownRows:=Columns[n].DropDownRows;
D.QDBGrid.Columns[n].EditMask:=Columns[n].EditMask;
D.QDBGrid.Columns[n].Font:=Columns[n].Font;
D.QDBGrid.Columns[n].LimitToList:=Columns[n].LimitToList;
D.QDBGrid.Columns[n].PickList:=Columns[n].PickList;
D.QDBGrid.Columns[n].ReadOnly:=Columns[n].ReadOnly;
D.QDBGrid.Columns[n].Title:=Columns[n].Title;
D.QDBGrid.Columns[n].TitleAlignment:=Columns[n].TitleAlignment;
D.QDBGrid.Columns[n].TitleFont:=Columns[n].TitleFont;
D.QDBGrid.ColWidths[n]:=ColWidths[n];
end;
D.QDBGrid.QDBItem:=QDBItem;
D.QDBGrid.QDBItem.FileName:=QDBItem.FileName;
wasreadonly:=QDBItem.ReadOnly;
D.QDBGrid.QDBItem.ReadOnly:=true;
end;
if D.ShowModal = mrOK then
begin
with Component as TQDBGrid do
begin
for n:=0 to Columns.Count-1 do
begin
Columns[n].Alignment:= D.QDBGrid.Columns[n].Alignment;
Columns[n].ButtonStyle:= D.QDBGrid.Columns[n].ButtonStyle;
Columns[n].Color:= D.QDBGrid.Columns[n].Color;
Columns[n].DisplayMask:= D.QDBGrid.Columns[n].DisplayMask;
Columns[n].DropDownRows:= D.QDBGrid.Columns[n].DropDownRows;
Columns[n].EditMask:= D.QDBGrid.Columns[n].EditMask;
Columns[n].Font:= D.QDBGrid.Columns[n].Font;
Columns[n].LimitToList:= D.QDBGrid.Columns[n].LimitToList;
Columns[n].PickList:= D.QDBGrid.Columns[n].PickList;
Columns[n].ReadOnly:= D.QDBGrid.Columns[n].ReadOnly;
Columns[n].Title:= D.QDBGrid.Columns[n].Title;
Columns[n].TitleAlignment:= D.QDBGrid.Columns[n].TitleAlignment;
Columns[n].TitleFont:= D.QDBGrid.Columns[n].TitleFont;
ColWidths[n]:= D.QDBGrid.ColWidths[n];
end;
QDBItem.ReadOnly:=wasreadonly;
end;
Designer.Modified;
end;
finally
D.Free;
end;
end;
1:
begin
t:=TQDBItem.Create(nil);
try
with (Component as THack) do
begin
x:=QDBItem;
QDBItem:=t;
QDBItem.FileName:=x.FileName;
QDBItem.FetchStructure;
THack(Component).SetColumnCount(FixedCols + QDBItem.FieldCount);
for n:=0 to FixedCols-1 do
begin
Columns[n].Title:='';
end;
for n:=FixedCols to Columns.Count-1 do
begin
Columns[n].Title:=QDBItem.FieldNames[n-FixedCols];
end;
QDBItem:=x;
end;
finally
t.Free;
end;
end;
else
end;
end;
procedure Register;
begin
RegisterComponents('IHSoftware', [TQDBGrid]);
RegisterComponentEditor(TQDBGrid,TQDBGridEditor);
end;
end.