📄 mainunit.pas
字号:
TreeView1.Items[i].Expanded := False;
end;
FGroupExpandList.Clear;
end;
TreeView1.ClearSelection;
FUpdateFlag := False;
if (FCurrentGroup <> '回收站') and (FGroupList.IndexOf(FCurrentGroup) < 0) then
FCurrentGroup := '';
SelectGroup(FCurrentGroup);
SetSelectOpenMenuItem;
TreeView1.Items.EndUpdate;
TreeView1.Tag := 0;
end;
function TTheMainForm.UpdateListView(DefaultFlag: Boolean = False): TListItem;
var
i: Integer;
CurrentItem, ParentGroup, Value: string;
begin
Result := nil;
CurrentItem := '';
if ListView1.ItemFocused <> nil then
CurrentItem := ListView1.ItemFocused.SubItems[11];
if ListView1.Selected <> nil then
CurrentItem := ListView1.Selected.SubItems[11];
ListView1.Tag := 1;
ListView1.Items.BeginUpdate;
ListView1.Clear;
ListView1.TabStop := False;
for i := 0 to FAllList.Count - 1 do
begin
ParentGroup := FIniFile.ReadString(FAllList[i], 'Parent', '');
Value := FIniFile.ReadString(FAllList[i], 'Type', '');
if (FAllList[i] <> FCurrentGroup) and (ParentGroup = FCurrentGroup) and ((Value = '功能组') or (Value = '功能项')) then
begin
AddListView(FAllList[i]);
if DefaultFlag and (FUserFile.ReadString(FUserRealName, 'DefaultItem', '') = FAllList[i]) then
Result := ListView1.Items[ListView1.Items.Count - 1];
end;
end;
if Result <> nil then
begin
Result.Focused := True;
Result.Selected := True;
end
else
if ListView1.Items.Count > 0 then
begin
ListView1.Items[0].Focused := True;
i := SelectName(CurrentItem);
if i > -1 then
ListView1.Items[i].Focused := True;
end;
if FSortNameFlag then
SortName.Execute
else
SortIndex.Execute;
ListView1.Items.EndUpdate;
ListView1.Tag := 0;
end;
procedure TTheMainForm.UpdateSysPara;
var
Value: string;
aIcon: TIcon;
Index: Integer;
Flag: Boolean;
begin
Value := FIniFile.ReadString('Default', 'Caption', '');
if Value = '' then
Value := FDefaultTitle;
Application.Title := Value;
Caption := Application.Title;
Hint := Caption;
Value := FIniFile.ReadString('Default', 'Icon', '');
Index := Pos('/', Value);
Flag := Index > 0;
if Flag then
begin
try
Index := StrToInt(Copy(Value, Index + 1, Length(Value) - Index)) - 1;
if Index < 0 then
Index := 0;
except
Index := 0;
end;
Value := Copy(Value, 1, Pos('/', Value) - 1);
end;
if Value <> '' then
begin
aIcon := TIcon.Create;
try
if Flag or (UpperCase(ExtractFileExt(Value)) = '.EXE') or (UpperCase(ExtractFileExt(Value)) = '.DLL') or (UpperCase(ExtractFileExt(Value)) = '.OCX') then
begin
if Index + 1 > Integer(ExtractIcon(HInstance, PChar(ProcessFileName(Value, True, False, False)), $FFFFFFFF)) then
Index := 0;
aIcon.Handle := ExtractIcon(HInstance, PChar(ProcessFileName(Value, True, False, False)), Index);
end
else
aIcon.LoadFromFile(ProcessFileName(Value, True, False, False));
if aIcon.Handle > 1 then
Application.Icon.Assign(aIcon);
except
end;
aIcon.Free;
end
else
Application.Icon.Assign(FDefaultIcon);
Icon.Assign(Application.Icon);
Application.HelpFile := ProcessFileName(FIniFile.ReadString('Default', 'HelpFile', ''), True, False, False);
if Application.HelpFile = '' then
Application.HelpFile := Copy(Application.ExeName, 1, Length(Application.ExeName) - Length(ExtractFileExt(Application.ExeName))) + '.HLP';
FHelpFile := Application.HelpFile;
if (FHelpFile = '') or (not FileExists(FHelpFile) and (UpperCase(ExtractFileExt(FHelpFile)) = '.HLP')) then
Application.HelpFile := '';
Value := FIniFile.ReadString('Default', 'HomePage', '');
Index := Pos(',', Value);
if Index > 0 then
begin
Label3.Hint := Trim(Copy(Value, 1, Index - 1));
Value := Trim(Copy(Value, Index + 1, Length(Value) - Index));
end
else begin
Label3.Hint := Trim(Value);
Value := '';
end;
if Value = '' then
Label3.Caption := '欲了解更多信息,请访问我们的网站'
else
Label3.Caption := Trim(Value);
Panel9Resize(Panel9);
if (Label3.Hint <> '') and (Pos('//', Label3.Hint) = 0) then
Label3.Hint := 'http://' + Label3.Hint;
Label3.Enabled := Label3.Hint <> '';
Value := FIniFile.ReadString('Default', 'EMail', '');
Index := Pos(',', Value);
if Index > 0 then
begin
Label4.Hint := Trim(Copy(Value, 1, Index - 1));
Value := Trim(Copy(Value, Index + 1, Length(Value) - Index));
end
else begin
Label4.Hint := Trim(Value);
Value := '';
end;
if Value = '' then
Label4.Caption := '如在使用中遇到问题,请给我们发邮件'
else
Label4.Caption := Trim(Value);
Panel10Resize(Panel10);
if UpperCase(Copy(Label4.Hint, 1, 7)) = 'MAILTO:' then
Label4.Hint := Copy(Label4.Hint, 8, Length(Label4.Hint) - 7);
Label4.Enabled := Label4.Hint <> '';
StatusBar1.Invalidate;
end;
procedure TTheMainForm.UpdateList(PreserveFlag: Boolean = True; TreeFlag: Boolean = True);
var
Flag: Boolean;
i: Integer;
ParentGroup, Value: string;
DeleteStrings: TStringList;
begin
if FIniFile <> nil then
begin
FGroupExpandList.Clear;
if PreserveFlag then
for i := 0 to TreeView1.Items.Count - 1 do
begin
if i = 0 then
ParentGroup := ''
else
if TreeView1.Items[i].Level = 0 then
ParentGroup := '回收站'
else
ParentGroup := FGroupList[Integer(TreeView1.Items[i].Data)];
if TreeView1.Items[i].Expanded then
FGroupExpandList.Add(ParentGroup + '=1');
end;
end
else begin
FIniFile := TMemIniFile.Create(FIniFileName);
FIniFile.CaseSensitive := True;
DeleteFile(FIniFileName);
end;
FAllList.Clear;
FGroupList.Clear;
FIniFile.ReadSections(FAllList);
DeleteStrings := TStringList.Create;
for i := 0 to FAllList.Count - 1 do
begin
Value := FIniFile.ReadString(FAllList[i], 'Type', '');
if (FAllList[i] = '') or (FAllList[i] = 'Default') or ((Value <> '功能组') and (Value <> '功能项')) then
DeleteStrings.Add(IntToStr(i))
else begin
ParentGroup := FIniFile.ReadString(FAllList[i], 'Parent', '');
if ParentGroup = FAllList[i] then
begin
FIniMustSave := True;
FIniFile.WriteString(FAllList[i], 'Parent', '');
end;
Flag := True;
ParentGroup := FIniFile.ReadString(FAllList[i], 'Parent', '');
while (ParentGroup <> '') and (ParentGroup <> '回收站') do
begin
if FIniFile.ReadString(ParentGroup, 'Parent', '') = ParentGroup then
begin
FIniMustSave := True;
FIniFile.WriteString(ParentGroup, 'Parent', '');
end;
Value := FIniFile.ReadString(ParentGroup, 'Type', '');
if Value <> '功能组' then
begin
DeleteStrings.Add(IntToStr(i));
Flag := False;
Break;
end;
ParentGroup := FIniFile.ReadString(ParentGroup, 'Parent', '');
end;
Value := FIniFile.ReadString(FAllList[i], 'Type', '');
if Flag and (Value = '功能组') then
FGroupList.Add(FAllList[i]);
end;
end;
for i := DeleteStrings.Count - 1 downto 0 do
begin
if FAllList[StrToInt(DeleteStrings[i])] <> 'Default' then
begin
FIniMustSave := True;
FIniFile.EraseSection(FAllList[StrToInt(DeleteStrings[i])]);
end;
FAllList.Delete(StrToInt(DeleteStrings[i]));
end;
DeleteStrings.Free;
UpdateSysPara;
if TreeFlag then
UpdateTreeView;
end;
procedure TTheMainForm.FormCreate(Sender: TObject);
var
aWinControl: TWinControl;
i: Integer;
begin
aWinControl := ShowHintString('正在启动系统 ...');
Application.OnException := ApplicationEventsException;
AppendMenu(GetSystemMenu(Handle, False), MF_SEPARATOR, 0, '');
AppendMenu(GetSystemMenu(Handle, False), MF_STRING, CM_MINIMIZE, '最小化所有窗口(&L)');
AppendMenu(GetSystemMenu(Handle, False), MF_SEPARATOR, 0, '');
AppendMenu(GetSystemMenu(Handle, False), MF_STRING, CM_ABOUT, '关于(&A)...');
CorbaConnection1 := TCorbaConnection.Create(Self);
FDefaultTitle := Application.Title;
FDefaultIcon := TIcon.Create;
FDefaultIcon.Assign(Application.Icon);
FAllList := TStringList.Create;
FAllList.CaseSensitive := True;
FGroupList := TStringList.Create;
FGroupList.CaseSensitive := True;
FGroupExpandList := TStringList.Create;
FGroupExpandList.CaseSensitive := True;
FimageFileList := TStringList.Create;
FImageIndexList := TStringList.Create;
FItemPropertyForms := TStringList.Create;
FOpenedHandles := TStringList.Create;
FLibHandles := TStringList.Create;
FViewStrings := TStringList.Create;
with FMyClipboard do
begin
Flag := 0;
Name := '';
end;
Panel4.Width := 0;
FIniMustSave := False;
FGoMenuFlag := False;
FSortNameFlag := False;
FUpdateFlag := False;
FSetSelectOpen := False;
FSetSelectOpening := False;
FThread := nil;
FPBLocked := False;
FPBLockedMe := False;
FPBMessaging := False;
FCheckEnabling := False;
try
ProcessIniFile;
UpdateList(False, False);
ProcessIniFile(True, True, '', ' ');
FUserFile := TMemIniFile.Create(FUserFileName);
FUserFile.CaseSensitive := True;
DeleteFile(FUserFileName);
except
aWinControl.Free;
Application.MessageBox('不能正常读写相关文件,系统无法启动!', '警告', MB_OK or MB_ICONSTOP);
PostMessage(Handle, WM_CLOSE, 0, 0);
Exit;
end;
CshUserFile;
FUserName := '';
if FUserFile.ReadString('Default', 'AutoShowUser', '') = '1' then
FUserName := FUserFile.ReadString('Default', 'UserName', '');
if ServerViewForm = nil then
ServerViewForm := TServerViewForm.Create(Application);
if GUIDForm = nil then
GUIDForm := TGUIDForm.Create(Application);
if CurrentRDM < 10 then
with GUIDForm do
begin
Edit1.Text := Key[CurrentRDM];
Edit2.Text := KeyName[CurrentRDM];
Edit1.ShowHint := True;
Edit2.ShowHint := True;
end;
SelfString := '<-' + UpperCase(Application.ExeName) + IntToStr(Random(High(Integer))) + '->';
aWinControl.Free;
FMessageID := 0;
FDefaultRDM := Unassigned;
FMiniFlag := True;
FLogin := False;
while not FLogin do
begin
if VarIsEmpty(FDefaultRDM) then
try
FDefaultRDM := FFactory.CreateComObject(nil) as IDispatch;
FDefaultRDM.Login(WideString(SelfString), '', False);
except
end;
i := 0;
while (RDM < 2) and (SystemParams.Values['Automation'] = 'Y') and (i < 100) do
begin
i := i + 1;
Application.ProcessMessages;
Sleep(0);
end;
if FMiniFlag then
FMiniFlag := RDM > 1;
if (RDM < 2) and (SystemParams.Values['UserName'] <> '') then
FLogin := ShowLoginForm(SystemParams.Values['UserName'], SystemParams.Values['Password'], True)
else
FLogin := ShowLoginForm(FUserName);
FMiniFlag := False;
if RDM < 2 then
Break;
end;
if FLogin and ((FUserRealName = '') or not FUserFile.SectionExists(FUserRealName)) then
FLogin := False;
if FLogin then
Application.ShowMainForm := True
else
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
function TTheMainForm.NewSectionName(const BasicStr: string; First: Cardinal): string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -