📄 echmmain.pas
字号:
begin
if IsActiveEdit ='webDesign' then
SaveDocument(LongBool(TdxBarLargeButton(Sender).Tag))
else SaveFile(False);
end;
procedure TEchmForm.dxBarButtonSaveAsClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
SaveDocument(LongBool(TdxBarLargeButton(Sender).Tag))
else SaveFile(True);
end;
procedure TEchmForm.dxBarButtonPrintClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
ActiveWebDesign.Print else
if PrintDialog.Execute then ActiveEditor.Print(FileName);
end;
procedure TEchmForm.dxBarButtonExitClick(Sender: TObject);
begin
Close;
end;
procedure TEchmForm.dxBarButtonUndoClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.Undo;
end else
SendMessage(ActiveEditor.Handle, EM_UNDO, 0, 0);
end;
procedure TEchmForm.dxBarButtonCutClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.Cut;
end else
ActiveEditor.CutToClipboard;
end;
procedure TEchmForm.dxBarButtonCopyClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.Copy;
end else
ActiveEditor.CopyToClipboard;
end;
procedure TEchmForm.dxBarButtonPasteClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.Paste;
end else
ActiveEditor.PasteFromClipboard;
end;
procedure TEchmForm.dxBarButtonClearClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.Clear;
end else
ActiveEditor.ClearSelection;
end;
procedure TEchmForm.dxBarButtonSelectAllClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.SelectAll;
end else
ActiveEditor.SelectAll;
end;
procedure TEchmForm.dxBarButtonFindClick(Sender: TObject);
begin
with ActiveEditor do
begin
SelLength := 0;
with TFindDialog.Create(Application) do
begin
Options := Options + [frHideUpDown];
OnFind := FindOne;
Execute;
end;
end;
end;
procedure TEchmForm.dxBarButtonReplaceClick(Sender: TObject);
begin
with ActiveEditor do
begin
SelLength := 0;
with TReplaceDialog.Create(Application) do
begin
OnFind := FindOne;
OnReplace := ReplaceOne;
Execute;
end;
end;
end;
procedure TEchmForm.dxBarComboFontNameChange(Sender: TObject);
var
V : OleVariant;
begin
if not FUpdating then
if IsActiveEdit ='webDesign' then
begin
V := dxBarComboFontName.Text;
ActiveWebDesign.Edit.FontName(V);
end else
ActiveEditor.SelAttributes.Name := dxBarComboFontName.Text;
end;
procedure TEchmForm.dxBarComboFontSizeChange(Sender: TObject);
var
V : OleVariant;
begin
if not FUpdating then
if IsActiveEdit ='webDesign' then
begin
V := StrToInt(dxBarComboFontSize.Text) + 1;
ActiveWebDesign.Edit.FontSize(V);
end else
ActiveEditor.SelAttributes.Size := StrToInt(dxBarComboFontSize.Text);
end;
procedure TEchmForm.dxBarButtonBoldClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.Edit.Bold;
end else
begin
with ActiveEditor.SelAttributes do
if dxBarButtonBold.Down then
Style := Style + [fsBold]
else
Style := Style - [fsBold];
end;
end;
procedure TEchmForm.dxBarButtonItalicClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.Edit.Italic;
end else
begin
with ActiveEditor.SelAttributes do
if dxBarButtonItalic.Down then
Style := Style + [fsItalic]
else
Style := Style - [fsItalic];
end;
end;
procedure TEchmForm.dxBarButtonUnderlineClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.Edit.UnderLine;
end else
begin
with ActiveEditor.SelAttributes do
if dxBarButtonUnderline.Down then
Style := Style + [fsUnderline]
else
Style := Style - [fsUnderline];
end;
end;
procedure TEchmForm.dxBarComboFontColorChange(Sender: TObject);
var
V: OleVariant;
begin
if IsActiveEdit ='webDesign' then
begin
V := ColorToHTML(dxBarComboFontColor.Color);
if LongBool(TdxBarColorCombo(sender).Tag) then
begin
ActiveWebDesign.Edit.ForeColor(dxBarComboFontColor.Color);
end else
begin
ActiveWebDesign.Edit.BackColor(dxBarComboFontColor.Color);
end;
end else
ActiveEditor.SelAttributes.Color := dxBarComboFontColor.Color;
end;
procedure TEchmForm.dxBarButtonBulletsClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
//? if Boolean(TAction(Sender).Tag) then
//? CmdID := DECMD_ORDERLIST //带编号的列表
//? else
//? CmdID := DECMD_UNORDERLIST; //带项目符号列表
ActiveWebDesign.Edit.InsertOrderedList;
end else
ActiveEditor.Paragraph.Numbering := TNumberingStyle(dxBarButtonBullets.Down);
end;
procedure TEchmForm.dxBarButtonAlignClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
case TdxBarLargeButton(Sender).Tag-15 of
0: ActiveWebDesign.Edit.JustifyLeft;
1: ActiveWebDesign.Edit.JustifyCenter;
2: ActiveWebDesign.Edit.JustifyRight;
else ActiveWebDesign.Edit.JustifyFull;
end;
end else
begin
if TdxBarLargeButton(Sender).Down then
ActiveEditor.Paragraph.Alignment := TAlignment(TdxBarLargeButton(Sender).Tag-15)
else
ActiveEditor.Paragraph.Alignment := taLeftJustify;
end;
end;
procedure TEchmForm.dxBarButtonProtectedClick(Sender: TObject);
begin
with ActiveEditor.SelAttributes do Protected := not Protected;
end;
procedure TEchmForm.dxBarButtonFontClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
//? ActiveWebDesign.Edit.FontName(cbFontName.Text);
end else
begin
FontDialog.Font.Assign(ActiveEditor.SelAttributes);
if FontDialog.Execute then
ActiveEditor.SelAttributes.Assign(FontDialog.Font);
end;
end;
procedure TEchmForm.dxBarListWindowsGetData(Sender: TObject);
begin
with dxBarListWindows do
ItemIndex := Items.IndexOfObject(PCT.ActivePage);
end;
procedure TEchmForm.dxBarListWindowsClick(Sender: TObject);
begin
with dxBarListWindows do
PCT.ActivePageIndex:=ItemIndex;
end;
procedure TEchmForm.dxBarButtonOnWebClick(Sender: TObject);
begin
ShellExecute(0, nil, 'http://www.hy-br.com', nil, nil, SW_RESTORE);
end;
procedure TEchmForm.dxBarMRUFilesClick(Sender: TObject);
var
AFileName: String;
FFrame:TFrame; I:integer;
begin
if FFrame <> nil then FFrame:=nil;
AFileName := dxBarMRUFiles.Items[dxBarMRUFiles.ItemIndex];
if FileExists(AFileName) then
begin
with TcxTabSheet.Create(Self) do
begin
PageControl:=PCT;
PCT.ActivePageIndex:= PageIndex;
FFrame := TEchmChildForm.Create(self);
with FFrame do begin
Name:='EchmChildForm'+IntToStr(PageIndex);
Parent := PCT.ActivePage;
Align:=alClient;
Visible := true;
Font.Name := '宋体';
Font.Size := 9;
if (ExtractFileExt(AFileName)='.htm') or
(ExtractFileExt(AFileName)='.html') then
begin
FDocPathName := '';
try
for I:=0 to ComponentCount-1 do
begin
if Components[I].InheritsFrom(THTMLEdit) then
begin
THTMLEdit(Components[I]).Open(AFileName);
FDocPathName := AFileName;
end;
if Components[I].InheritsFrom(TcxPageControl) then
begin
TcxPageControl(Components[I]).ActivePageIndex:=0;
TcxPageControl(Components[I]).OnChange := cxPageControlChange;
end;
end;
Caption := FDocPathName;
IsActiveEdit :='webDesign';
except
ShowMessage('打开文档失败');
end;
end else
begin
for I:=0 to ComponentCount-1 do
begin
if Components[I].InheritsFrom(TRichEdit) then
begin
TRichEdit(Components[I]).Lines.LoadFromFile(AFileName);
TRichEdit(Components[I]).OnChange := EditorChange;
TRichEdit(Components[I]).OnSelectionChange := EditorSelectionChange;
end;
if Components[I].InheritsFrom(TcxPageControl) then
begin
TcxPageControl(Components[I]).ActivePageIndex:=1;
TcxPageControl(Components[I]).OnChange := cxPageControlChange;
end;
end;
IsActiveEdit :='Editor';
SetModified(False);
end;
end;
end;
//dxBarMRUFiles.RemoveItem(AFileName, nil);
dxBarListWindows.Items.AddObject(AFileName, Self);
end else
Application.MessageBox(PChar(AFileName+#10#13+'文件没找到.'),'Open',MB_OK or MB_ICONERROR)
end;
procedure TEchmForm.dxBarButtonStdStyleClick(Sender: TObject);
begin
BarManager.Style := bmsStandard;
dxStatusBar.PaintStyle := stpsStandard;
end;
procedure TEchmForm.dxBarButtonEnhancedStyleClick(Sender: TObject);
begin
BarManager.Style := bmsEnhanced;
dxStatusBar.PaintStyle := stpsStandard;
end;
procedure TEchmForm.dxBarButtonFlatStyleClick(Sender: TObject);
begin
BarManager.Style := bmsFlat;
dxStatusBar.PaintStyle := stpsFlat;
end;
procedure TEchmForm.dxBarButtonXPStyleClick(Sender: TObject);
begin
BarManager.Style := bmsXP;
dxStatusBar.PaintStyle := stpsXP;
end;
procedure TEchmForm.dxBarButtonOffice11StyleClick(Sender: TObject);
begin
BarManager.Style := bmsOffice11;
dxStatusBar.PaintStyle := stpsOffice11;
end;
procedure TEchmForm.dxBarLargeButton2Click(Sender: TObject);
begin
ShellExecute(Handle, PChar('OPEN'), PChar('http://www.hy-br.com'), nil, nil, SW_SHOWMAXIMIZED);
end;
procedure TEchmForm.actAboutExecute(Sender: TObject);
begin
with TEchmAboutForm.Create(nil) do
try
ShowModal;
finally
Free;
end;
end;
procedure TEchmForm.dxBarButtonBitmapClick(Sender: TObject);
const
Filter = '*.JPG|*.JPG|*.*|*.*';
begin
OpenDialog.Filter := Filter;
OpenDialog.FileName := '';
if OpenDialog.Execute then
begin
if IsActiveEdit ='webDesign' then
begin
InsertBGImage(ActiveWebDesign,OpenDialog.FileName); //webDesign
end else
begin
InsertBitmapIntoRichEdit(OpenDialog.FileName, ActiveEditor);
ActiveEditor.SetFocus;
end;
end;
end;
procedure TEchmForm.dxBarButtonChmCompilerClick(Sender: TObject);
var
GChmCompiler: TChmCompiler;
const
Filter = 'CHM项目文件(*.HHP)|*.HHP';
begin
OpenDialog.Filter := Filter;
OpenDialog.FileName := '';
if OpenDialog.Execute then
begin
Gchmcompiler:=TChmCompiler.Default;
if GChmCompiler.Compile(OpenDialog.FileName) then
begin
showmessage('OK');
end;
end;
end;
procedure TEchmForm.dxBarButtonchmPropertyClick(Sender: TObject);
begin
with TfrmChmProperty.Create(nil) do
try
ShowModal;
finally
Free;
end;
end;
procedure TEchmForm.dxBarButtonTableClick(Sender: TObject);
begin
with TTablePropertyForm.Create(nil) do
begin
try
if ShowModal = IDOK then
begin
if IsActiveEdit ='webDesign' then
begin
InsertTable( edtNumRows.Value,edtNumCols.Value,TableAttrs,CellAttrs,ActiveWebDesign);
end else
begin
InsertTableRichEdit( edtNumRows.Value,edtNumCols.Value,TableAttrs,CellAttrs,ActiveEditor);
end;
end;
finally
Free;
end;
end;
end;
// DHTMLEdit
procedure TEchmForm.actFilePrintExecute(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.Print;
end;
end;
procedure TEchmForm.dxBarButtonHTMLObjectClick(Sender: TObject);
begin
if IsActiveEdit ='webDesign' then
begin
ActiveWebDesign.Insert(GetHTMLText(TAction(Sender).Tag - 101))
//InsertHTMLObject的Tag从101开始,故要减去101
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -