S
sunweikey
Unregistered / Unconfirmed
GUEST, unregistred user!
我有几个在delhpi3下开发的控件,想升级到DELHPI5或者更高版本,希望有经验的高手给予帮助,谢谢!
第一个问题是:
{$IFDEF VER120} {Borland Delphi 4.0 }
type
TDesigner = IDesigner;
TFormDesigner = IFormDesigner;
{$ENDIF}
从该语句看是该控件是可以在delhpi4下可以使用,如果在delhpi5下编辑是不是应该改为
//{$IFDEF VER120} {Borland Delphi 4.0 }
type
TDesigner = IDesigner;
TFormDesigner = IFormDesigner;
//{$ENDIF}
2:
{$IFDEF VER120} {Borland Delphi 4.0 }
procedure ComponentDeleted(Component: IPersistent); override;
{$ELSE}
procedure ComponentDeleted(Component: TComponent); override;
{$ENDIF}
3:
{$IFDEF VER120} {Borland Delphi 4.0 }
procedure TDBGridEHColumnsEditor.ComponentDeleted(Component: IPersistent);
begin
if ExtractPersistent(Component) = DBGridEH then begin
{$ELSE}
procedure TDBGridEHColumnsEditor.ComponentDeleted(Component: TComponent);
begin
if Component = DBGridEH then begin
{$ENDIF}
DBGridEH := nil;
Close;
end;
end;
4:
procedure TDBGridEHColumnsEditor.ListView1Change(Sender: TObject;
Item: TListItem; Change: TItemChange);
var
FComponents: TComponentList;
i: Integer;
// ListItem: TListItem;
begin
if (Change <> ctState) then Exit;
tbDeleteSelected.Enabled := ListView1.SelCount > 0;
tbRestoreDefaults.Enabled := ListView1.Items.Count > 0;
miDeleteSelected.Enabled := ListView1.SelCount > 0;
miRestoreDefaults.Enabled := ListView1.Items.Count > 0;
miSelectAll.Enabled := ListView1.Items.Count > 0;
tbMoveDown.Enabled := ListView1.Items.Count > 0;
tbMoveUp.Enabled := ListView1.Items.Count > 0;
tbAddAllFields.Enabled := Assigned(DBGridEH) and Assigned(DBGridEH.DataSource) and
Assigned(DBGridEH.Datasource.Dataset) and (DBGridEH.Datasource.Dataset.FieldCount > 0);
if CheckCollection and Active then begin
FComponents := TComponentList.Create;
if (ListView1.SelCount > 0) then begin
for i := ListView1.Items.Count - 1 downto 0 do
if (ListView1.Items.Selected = True) and Assigned(ListView1.Items.Data) then
FComponents.Add(TColumnEH(ListView1.Items.Data));★★★★该处出错说的是,提示是不能把值加给FComponent,说FComponent 不能装TColumnEH这种类!
end
else FComponents.Add(DBGridEH.Columns);
SetSelection(FComponents);
end;
end;
第一个问题是:
{$IFDEF VER120} {Borland Delphi 4.0 }
type
TDesigner = IDesigner;
TFormDesigner = IFormDesigner;
{$ENDIF}
从该语句看是该控件是可以在delhpi4下可以使用,如果在delhpi5下编辑是不是应该改为
//{$IFDEF VER120} {Borland Delphi 4.0 }
type
TDesigner = IDesigner;
TFormDesigner = IFormDesigner;
//{$ENDIF}
2:
{$IFDEF VER120} {Borland Delphi 4.0 }
procedure ComponentDeleted(Component: IPersistent); override;
{$ELSE}
procedure ComponentDeleted(Component: TComponent); override;
{$ENDIF}
3:
{$IFDEF VER120} {Borland Delphi 4.0 }
procedure TDBGridEHColumnsEditor.ComponentDeleted(Component: IPersistent);
begin
if ExtractPersistent(Component) = DBGridEH then begin
{$ELSE}
procedure TDBGridEHColumnsEditor.ComponentDeleted(Component: TComponent);
begin
if Component = DBGridEH then begin
{$ENDIF}
DBGridEH := nil;
Close;
end;
end;
4:
procedure TDBGridEHColumnsEditor.ListView1Change(Sender: TObject;
Item: TListItem; Change: TItemChange);
var
FComponents: TComponentList;
i: Integer;
// ListItem: TListItem;
begin
if (Change <> ctState) then Exit;
tbDeleteSelected.Enabled := ListView1.SelCount > 0;
tbRestoreDefaults.Enabled := ListView1.Items.Count > 0;
miDeleteSelected.Enabled := ListView1.SelCount > 0;
miRestoreDefaults.Enabled := ListView1.Items.Count > 0;
miSelectAll.Enabled := ListView1.Items.Count > 0;
tbMoveDown.Enabled := ListView1.Items.Count > 0;
tbMoveUp.Enabled := ListView1.Items.Count > 0;
tbAddAllFields.Enabled := Assigned(DBGridEH) and Assigned(DBGridEH.DataSource) and
Assigned(DBGridEH.Datasource.Dataset) and (DBGridEH.Datasource.Dataset.FieldCount > 0);
if CheckCollection and Active then begin
FComponents := TComponentList.Create;
if (ListView1.SelCount > 0) then begin
for i := ListView1.Items.Count - 1 downto 0 do
if (ListView1.Items.Selected = True) and Assigned(ListView1.Items.Data) then
FComponents.Add(TColumnEH(ListView1.Items.Data));★★★★该处出错说的是,提示是不能把值加给FComponent,说FComponent 不能装TColumnEH这种类!
end
else FComponents.Add(DBGridEH.Columns);
SetSelection(FComponents);
end;
end;