⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitmain.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 3 页
字号:
procedure TMainform.btnLoadIdeClick(Sender: TObject);
var
  aFileStringList : TStringList;
  SearchPathExpr  : string;
begin
  if ModuleOfAddr(TheFormArray[FormID].ClassInfo) = '' then
  begin
    MessageDlg(
      'This functionality is disabled unless you build the demo from the'#13+
      'Delphi IDE with map file generation enabled.', mtWarning, [mbOK], 0);
    Exit;
  end;

  screen.Cursor := crHourGlass;

  // uses the function 'ModuleOfAddr' from JclDebug unit to get the unit name
  SearchPathExpr := ExtractFilePath(Application.ExeName) +
    ModuleOfAddr(TheFormArray[FormID].ClassInfo) + '.pas';
  StrReplace(SearchPathExpr, '\bin', '\examples', [rfIgnoreCase]);

  // uses AdvBuildFileList to get the file location in the example diretory tree
  aFileStringList := TStringList.create;
  AdvBuildFileList(SearchPathExpr, faAnyFile, aFileStringList, amAny,
   [flFullNames, flRecursive], '', nil);

  screen.Cursor := crDefault;

  if aFileStringList.Count < 1 then
    MessageDlg('File not found', mtError, [mbOK], 0)
  else
    ShellExecute(0, nil, PChar('"' +aFileStringList.Strings[0]+ '"'), nil, nil, SW_SHOWNORMAL);

 StatusBar.SimpleText := 'file ''' + aFileStringList.Strings[0] + ''' has been launched';
 aFileStringList.free;
end;

procedure TMainform.CompClick(Sender: TObject);

procedure addWithFormat(aStr: string);
begin
  JvRichEditHints.selattributes.style := [fsBold];  // set bold attribute
  JvRichEditHints.selattributes.Color := clNavy;    // color to blue
  JvRichEditHints.seltext := aStr;
  JvRichEditHints.selattributes.style := [];        // revert to normal
  JvRichEditHints.selattributes.Color := clBlack;
  // JvRichEditHints.selstart := JvRichEditHints.getTextLen; // set caret to end of text
end;

var
  aSL, allSections, tempSL: TStringList;
  i, j : integer;
  IniFile: TIniFile;
begin

 if (JvListBoxAllDemos.ItemIndex = -1) and (Sender = JvListBoxAllDemos) then // File is loading of nothing is selected
   exit;

 aSL:= TStringList.Create;
 IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + '\data\JvMegaDemoAllDemoForms.ini');
 JvRichEditHints.Text := '';

 // there are 3 possible callers for his method:

 if Sender is TJvXPBarItem then
    aSL.CommaText := IntToStr(TJvXPBarItem(sender).Tag)

 else if Sender = JvListBoxAllDemos then
 begin
   // we have only the Demo Title, so we have to search for it in the while ini file
   IniFile.ReadSections(aSL);
   for i := 0 to aSL.Count -1 do
     if IniFile.ReadString(aSL[i], 'Title', '') = JvListBoxAllDemos.Items[JvListBoxAllDemos.ItemIndex] then
     begin
       aSL.CommaText := aSL[i];
       break;
     end;
 end
 else if Sender = JvListBoxDemosCompNameSorted then
 begin
   addWithFormat(JvListBoxDemosCompNameSorted.Items[JvListBoxDemosCompNameSorted.ItemIndex]);
   JvRichEditHints.Lines.add(' is used in following Demos:');
   // we have one the Comonent Name, so we have to search in whole ini, in the comma seperated valuues
   allSections := TStringList.create;
   tempSL := TStringList.create;
   IniFile.ReadSections(allSections);
   for i := 0 to allSections.Count -1 do
   begin
     tempSL.CommaText := IniFile.ReadString(allSections[i], 'compsUsed', '');
     for j := 0 to tempSL.count -1 do
       if tempSL[j] = JvListBoxDemosCompNameSorted.Items[JvListBoxDemosCompNameSorted.ItemIndex] then
         aSL.Add(allSections[i]);
   end;

   allSections.Free;
   tempSL.Free;
 end
 else // the comps in the "Comps as in the Delphi IDE"
 begin
   aSL.CommaText :=(Sender as TControl).Hint;
   addWithFormat((Sender as TControl).Name);
   JvRichEditHints.Lines.add(' is used in following Demos:');
 end;

 // in the CommaText of the StringList aSL are now the DemoFormId[s]
 for i := 0 to aSL.Count -1 do
 begin
  JvRichEditHints.Lines.Add('');
  addWithFormat('http:' + aSL[i] + ' ' + IniFile.ReadString(aSL[i], 'Title', ''));
  JvRichEditHints.Lines.Add('');
  JvRichEditHints.Lines.Add(IniFile.ReadString(aSL[i], 'Descr', ''));
 end;

 FreeAndNil(aSL);
 FreeAndNil(IniFile);
end;

procedure TMainform.JvNavPanelBtnIdePageCtrlClick(Sender: TObject);
begin
 JvXPBarIDE.Collapsed := not JvXPBarIDE.Collapsed;
end;

procedure TMainform.ShowJVCLAboutDlg(Sender: TObject);
begin
 JvJVCLAboutComp.Execute;
end;

procedure TMainform.ShellExecHint(Sender: TObject);
var
  aFileName : string;
begin

  if Sender is TControl then
    aFileName := TControl(Sender).Hint
  else if Sender is TJvXPBarItem then
    aFileName := TJvXPBarItem(Sender).Hint
  else
  begin
    MessageDlg('Unknown Sender Type! Could not extract FileName from Hint', mtError, [mbOK], 0);
    exit;
  end;

  // check if aFileName is a real filename
  if (pos('www', aFileName) = 0) and (pos('mailto', aFileName) = 0) then
  begin
    aFileName := ExtractFileDir(Application.ExeName) + '\' + aFileName; 
    if not FileExists(aFilename) then
    begin
      MessageDlg('File ''' + aFilename + ''' could not be found!', mtError, [mbOK], 0);
      exit;
    end;
  end;
  
  screen.Cursor := crHourGlass;
  ShellExecute(0, Nil, PChar(aFileName), Nil, Nil, SW_SHOWNORMAL);
  StatusBar.SimpleText := 'file ''' + aFileName + ''' has been launched';
  screen.Cursor := crDefault;
end;

procedure TMainform.JvNavPanelBtnExitClick(Sender: TObject);
begin
 close;
end;

procedure TMainform.JvXPBarIDECollapsedChange(Sender: TObject; Collapsing: Boolean);
begin
 if Collapsing then
   JvCaptionPanel1.Top := JvCaptionPanel1.Top - 83
 else
   JvCaptionPanel1.Top := JvCaptionPanel1.Top + 83;
end;

procedure TMainform.WinXPBarEnsureOnlyOneExpanded(Sender: TObject; Collapsing: Boolean);
// this procedure ensures that only one group is expanded - if the user choose so
var
  i : integer;
begin
 if JvCheckBoxAllowOnlyOneExpanded.Checked = false then
   exit;

 if Collapsing then
   exit;
   
 // collapse all other JvXPBars except the sender
 for i := 0 to JvXPContainer1.ControlCount -1 do
   if JvXPContainer1.Controls[i] <> Sender then
     TJvXPBar(JvXPContainer1.Controls[i]).collapsed := true;
end;

procedure TMainform.JvRichEditHintsURLClick(Sender: TObject;
  const URLText: String; Button: TMouseButton);
begin
 if StrIsDigit(copy(UrlText, 6, 99)) then
   self.CreateDemoForm(StrToInt(copy(UrlText, 6, 99)))
 else
   ShellExecute(0, nil, PChar('"' + UrlText + '"'), nil, nil, SW_SHOWNORMAL);
end;

procedure TMainform.JvListBoxAllDemosChange(Sender: TObject);
var
  IniFile: TIniFile;
  allDemoFrms: TStringList;
  i: integer;
begin
  IniFile  := TIniFile.Create(ExtractFilePath(Application.ExeName) + '\data\JvMegaDemoAllDemoForms.ini');
  allDemoFrms := TStringList.Create;
  try
    IniFile.ReadSections(allDemoFrms);
    for I := 0 to allDemoFrms.Count -1 do
    begin
      JvListBoxAllDemos.Items.AddObject(IniFile.ReadString(allDemoFrms[i], 'Title', ''), nil)
    end;
  finally
    IniFile.Free;
    allDemoFrms.Free;
  end;
end;

procedure TMainform.JvNavPanelBtnJumpHelpClick(Sender: TObject);
var
  i : integer;
  firstLine : string;
begin
 // get the first word in the JvRichedit, becaues it is the component Name
 // not a very nice design, but at least it works
 firstLine := JvRichEditHints.Lines[0];

 if firstLine = '' then
 begin
   MessageDlg(
     'This function is only availible when a component from the PageControl in '#13 +
     '''Components as in the Delphi IDE'' is the current item!', mtWarning, [mbOK], 0);
   exit;
 end;
 i := 0;

 while firstLine[i] <> ' ' do
   inc(i);

 Application.HelpKeyword('T' + copy(FirstLine, 1, i -1));
 StatusBar.SimpleText := 'help topic ''T' + copy(FirstLine, 1, i -1) + ''' has been launched';
end;

procedure TMainform.JvXPBarSearchByCompNameAfterCollapsedChange(
  Sender: TObject; Collapsing: Boolean);
begin
 JvEdtCompSearch.setFocus;
end;

procedure TMainform.JvXPBarBrowseDemosAfterCollapsedChange(
  Sender: TObject; Collapsing: Boolean);
begin
 JvListBoxAllDemos.setFocus;
end;

procedure TMainform.JvNavPanelButton1Click(Sender: TObject);
begin
 StrToInt('JEDI');
end;

end.



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -