📄 unitmain.pas
字号:
// workaround, because anchors seems not to work here
JvPageControlComps.width := self.width - 40;
end;
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('http', 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);
var
A, B: Double;
begin
A := 0;
B := 0;
ShowMessageFmt('%f', [A / B]);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -