Object Pascal问题(???)(45分)

  • 主题发起人 主题发起人 qddmh
  • 开始时间 开始时间
Q

qddmh

Unregistered / Unconfirmed
GUEST, unregistred user!
挺急得,大家帮忙!!
1。是否有集合数组这种用法?(如下:)
TLimitStatus = (lsBrowse, lsEdit, lsPrint, lsFTP, lsMail, lsBackUp);
TOperLimit = Set of TLimitStatus

const
OperLimitName: Array[0..5] of String = ('浏览', '编辑', '打印', 'FTP管理', 'Mail管理', '数据库备份');
//这里对动态集合树组复常量,可以吗?
OperLimitValue: Array[0..5] of TOperLimit = ([lsBrowse], [lsEdit], [lsPrint], [lsFTP], [lsMail], [lsBackUp]);
2。纪录中是否可用TStringList类型?如果可以怎样用?
TreeNodeData = record
LimitStatus: TStringList
//?
Classtype: string[2];
myname:string[8] ;
end
3。向下面用动态TReeNode数组是否可以?
var
NodeArray: Array of TTreeNode
//这
ParentNodeArray: Array of TTreeNode
//这
Num: integer;
ParentNum: integer;
Rec2: TUserInfo;
i: integer;
SetTreeNodeValue: PTreeNodeData;
begin
Treeview1.Items.Clear ;
Reset(F);
Num := 0;
ParentNum := 0;
while not Eof(F) do
begin
Read(F, Rec2);
if Num = 0 then
begin
SetLength(NodeArray, Num + 1)
//动态TTreeNode树组是否可以这样用?
NodeArray[Num].Text := Rec2.Text ;
NodeArray[Num].ImageIndex := Rec2.ImageID ;
PTreeNodeData(NodeArray[Num].Data).LimitStatus := Rec2.LimitValue ;
PTreeNodeData(NodeArray[Num].Data).Classtype := Rec2.LimitType ;
PTreeNodeData(NodeArray[Num].Data).Password := Rec2.Password

SetTreeNodeValue^.LimitStatus := Rec2.LimitValue ;
SetTreeNodeValue^.Classtype := Rec2.LimitType ;
SetTreeNodeValue^.Password := Rec2.Password ;
SetLength(ParentNodeArray, ParentNum + 1);
//是否可以将添加的Treeview1子对象存入动态数组中?
ParentNodeArray[ParentNum] := TreeView1.Items.AddObject(nil, Rec2.Text, TObject(SetTreeNodeValue));
ParentNodeArray1 := TreeView1.Items.AddObject(nil, Rec2.Text, TObject(SetTreeNodeValue));
Inc(Num);
Inc(ParentNum);
CurrentLevel := 0;
Continuous := True;
Exit;
end
我运行程序时,总在注释处报错, 高手解释一下, 美分了,45请笑纳。
 
1 没问题
2 可以这样用:
procedure TForm1.Button3Click(Sender: TObject);
var
tree:TreeNodeData;
begin
tree.LimitStatus:=TStringList.Create;
tree.LimitStatus.add('aaa');
tree.LimitStatus.add('bbb');
showmessage(tree.LimitStatus.text);
tree.LimitStatus.free;
end;

3 uses ...., comctrls;
 
jsxjd兄:
TNode = packed record
NodeName: string[50];
FatherIndex: Integer;
Index: Integer;
Node: TTreeNode

myList: TStringList;
end;
var
myNode: TNode;
当用myNode.Node时是否也要向TStringList对象那样创建,
如果是该怎样创建?
 
jsxjd
第一个问题,如下用法为什么部队?
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TLimitStatus = (lsBrowse, lsEdit, lsPrint, lsFTP, lsMail, lsBackUp);
TOperLimit = Set of TLimitStatus;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
OperLimitName: Array[0..5] of String = ('浏览', '编辑', '打印', 'FTP管理', 'Mail管理', '数据库备份');
//这里对动态集合树组复常量,可以吗?
OperLimitValue: Array[0..5] of TOperLimit = ([lsBrowse], [lsEdit], [lsPrint], [lsFTP], [lsMail], [lsBackUp]);
var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
TestCol: TOperLimit;
i: integer;
Has: boolean;
begin
Has := False;
TestCol := [lsBrowse];
for i := Low(OperLimitValue) to High(OperLimitValue) do
begin
if TestCol in OperLimitValue then
begin
Has := True;
end;
end;
if Has then
begin
Showmessage('has');
end;
end;
为什么部队, 真急死了, 帮忙看一下吧?
 
后退
顶部