5,392
社区成员
发帖
与我相关
我的任务
分享
tabSheetList:TStringList;
function TbsMainForm.GetTabSheet(tabName: string): TcxTabSheet;
var tempSheet:TcxTabSheet;
tempName:string;
tempDirName:string;
begin
Result:=nil;
if tabName='' then
begin
Exit;
end;
tempDirName:=ExtractFileDir(ParamStr(0));
tempName:=StringReplace(tabName,tempDirName+'\','',[rfReplaceAll]);
tempName:=Copy(tempName,1,pos('.',tempName)-1);
if tabSheetList.IndexOf('cx'+tempName)<>-1 then
begin
//存在 则SHOW TcxTabSheet
//如何找到已经存在的对应的 TcxTabSheet(根据.NAME来判断)
tempSheet:=....?????
MainPG.ActivePage:=tempSheet;
end
else
begin
//不存在则新建一个TcxTabSheet
try
tempSheet:=TcxTabSheet.Create(MainPG);
with tempSheet do
begin
AllowCloseButton:=True;
Caption:=tempName;
Enabled:=True;
Name:='cx'+tempName;
Visible:=True;
Parent:=MainPG;
ParentWindow:=MainPG.Handle;
TabVisible:=True;
end;
tabSheetList.Add(tempSheet.Name);
Result:=tempSheet;
MainPG.ActivePage:=tempSheet;
finally
end;
end;
end;
for i := 0 to MainPG.PageCount-1 do
begin
if MainPG.Pages[i].Name=('cx'+tempName) then
begin
MainPG.ActivePage:=MainPG.Pages[i];
Result:=MainPG.Pages[i];
ShowMessage('find');
end;
end;
if (Components[i] is TcxTabSheet) then
这句都找不到
if FindComponent('cx'+tempName)<>nil then
begin
ShowMessage('find');
end;
for I := 0 to ComponentCount-1 do
begin
if (Components[i] is TcxTabSheet) then
if TcxTabSheet(Components[i]).Name=('cx'+tempName) then
begin
ShowMessage('find');
end;
end;
行不通,找不到