📄 wwrich.pas
字号:
RichEdit1.ExecuteReplaceDialog;
end;
procedure TwwRichEditForm.Font1Click(Sender: TObject);
begin
RichEdit1.ExecuteFontDialog;
RefreshControls;
end;
Procedure TwwRichEditForm.SetRichEditFontName(Value: string);
var Format: TCharFormat;
begin
if RichEdit1.selAttributes.Name=Value then exit;
FillChar(Format, SizeOf(TCharFormat), 0);
Format.cbSize := SizeOf(TCharFormat);
with Format do
begin
dwMask:= CFM_FACE OR CFM_CHARSET;
StrPLCopy(szFaceName, Value, SizeOf(szFaceName));
bCharSet := RichEdit1.GetCharSetOfFontName(Value);
end;
SendMessage(RichEdit1.Handle, EM_SETCHARFORMAT, SCF_SELECTION, LPARAM(@Format));
end;
procedure TwwRichEditForm.FontNameComboCloseUp(Sender: TwwDBComboBox;
Select: Boolean);
begin
if not Select then exit;
SetRichEditFontName(FontNameCombo.Text);
RichEdit1.SetFocus;
RefreshControls;
end;
procedure TwwRichEditForm.FontSizeComboCloseUp(Sender: TwwDBComboBox;
Select: Boolean);
begin
if not Select then exit;
if FontSizeCombo.text='' then exit;
RichEdit1.SelAttributes.Size:= StrToInt(FontSizeCombo.Text);
RichEdit1.SetFocus;
RefreshControls;
end;
procedure TwwRichEditForm.BulletStyle1Click(Sender: TObject);
begin
TempDown:= (richedit1.Paragraph.Numbering = nsBullet);
BulletButton.OnClick(Sender);
end;
procedure TwwRichEditForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
if RichEdit1.readOnly then begin
if ord(key)=vk_escape then Close;
end
else if ord(key)=vk_escape then begin
if reoCloseOnEscape in RichEdit1.EditorOptions then
Close
else
Undo1Click(Sender)
end
else begin
if GetKeyState(VK_CONTROL) >=0 then exit;
if ord(key)=(ord('B')+1-ord('A')) then begin
TempDown:= fsBold in richedit1.SelAttributes.Style;
BoldButton.onClick(BoldButton);
key:= #0;
end
else if ord(key)=(ord('U')+1-ord('A')) then begin
TempDown:= fsUnderline in richedit1.SelAttributes.Style;
UnderlineButton.onClick(UnderlineButton);
key:= #0;
end
else if ord(key)=(ord('I')+1-ord('A')) then begin
TempDown:= fsItalic in richedit1.SelAttributes.Style;
ItalicButton.onClick(ItalicButton);
key:= #0;
end
end
end;
procedure TwwRichEditForm.UpdateStatusBar;
var KeyState: TKeyboardState;
begin
GetKeyboardState(KeyState);
with wwInternational.RichEdit do begin
if KeyState [VK_NumLock] <> 0 then StatusBar.Panels[2].text:= NUMLockCaption
else StatusBar.Panels[2].text:= '';
if KeyState [VK_Capital] <> 0 then StatusBar.Panels[1].text:= CAPLockCaption
else StatusBar.Panels[1].text:= '';
end;
end;
procedure TwwRichEditForm.FormShow(Sender: TObject);
var i: integer;
OrigRichEditModified: boolean;
begin
InitColorMenu;
OrigOnHint := Application.OnHint;
Application.OnHint := FormChangeHint;
{ Save previuos modified flag, as CopyRichEditTo incorrect sets this to True }
OrigRichEditModified:= OrigRichEdit.modified;
OrigRichEdit.CopyRichEditTo(RichEdit1);
OrigRichEdit.modified:= OrigRichEditModified;
Screen.Cursor:= crDefault;
RichEdit1.GutterWidth:= 6;
for i:= 0 to Screen.Fonts.Count-1 do begin
if (RichEdit1.EffectiveEditWidth=rewWindowSize) or
(Printer.Fonts.indexOf(Screen.Fonts[i])>=0) then
FontNameCombo.Items.Add(Screen.Fonts[i]);
end;
UpdateStatusBar;
RefreshControls;
RichEdit1.modified:= False;
with RichEdit1 do begin
if ReadOnly then begin
EditorOptions:= EditorOptions -
[reoShowLoad, reoShowSaveAs, reoShowSaveExit,
reoShowStatusBar, reoShowFormatBar, reoShowToolBar, reoShowRuler, reoShowSpellCheck];
end;
if not wwIsClass(RichEdit1.classtype, 'TwwDBRichEditMSWord') then
EditorOptions:= EditorOptions - [reoShowSpellCheck];
if not (reoShowLoad in EditorOptions) then begin
Load1.visible:= false;
LoadButton1.visible:= False;
end;
if not (reoShowSaveAs in EditorOptions) then begin
SaveAs1.visible:= false;
SaveAsButton.visible:= False;
end;
if not (reoShowPrint in EditorOptions) then begin
Print1.visible:= false;
PrintButton.visible:= False;
end;
if not (reoShowPrintPreview in EditorOptions) then begin
PrintPreview1.visible:= false;
PrintPreviewButton.visible:= False;
end;
if not (reoShowSpellCheck in EditorOptions) or RichEdit1.ReadOnly then begin
Tools1.visible:= False;
Spelling1.visible:= false;
SpellButton.visible:= False;
end;
if not (reoShowJustifybutton in EditorOptions) or RichEdit1.ReadOnly then
begin
JustifyButton.visible:= False;
end;
{ 9/15/98 - Only show if not readonly }
if (not (reoShowInsertObject in EditorOptions)) or
(reoDisableOLE in OLEOptions) or (RichEdit1.ReadOnly) then begin
InsertObject1.visible:= false;
Insert1.visible:= false;
end;
if ([reoShowPrint, reoShowPageSetup, reoShowPrintPreview] * EditorOptions = []) then
FileSep2.visible:= False;
if not (reoShowPageSetup in EditorOptions) then PageSetup1.visible:= false;
if not (reoShowSaveExit in EditorOptions) then begin
SaveExit1.visible:= false;
end;
if ([reoShowLoad,reoShowSaveExit] * EditorOptions = []) then
FileSep1.visible:= False;
{ Reposition format buttons so that there is no whitespace }
if not PrintButton.visible then
begin
Bevel1.Left:= Bevel1.Left - PrintButton.Width;
PrintPreviewButton.Left:= PrintPreviewButton.Left - PrintButton.Width;
end;
if not PrintPreviewButton.visible then
begin
Bevel1.Left:= Bevel1.Left - PrintPreviewButton.Width -6;
Bevel1.Visible:= false; //Left:= Bevel1.Left - PrintButton.Width;
end;
FindButton.Left:= Bevel1.left + 5;
SpellButton.Left:= FindButton.Left + FindButton.Width;
if SpellButton.visible then
ToolBarBevel1.Left:= SpellButton.Left + SpellButton.Width + 3
else ToolBarBevel1.left:= FindButton.Left + FindButton.Width + 3;
if not JustifyButton.visible then
begin
Bevel4.Left:= (485 * PixelsPerInch) div 96
end;
BulletButton.Left:= Bevel4.Left + 5;
HighlightButton.Left:= BulletButton.Left + (24 * PixelsPerInch) div 96;
CutButton.Left:= ToolBarBevel1.Left + 5;
CopyButton.Left:= CutButton.Left + CutButton.Width;
PasteButton.Left:= CopyButton.Left + CopyButton.Width;
Bevel2.Left:= PasteButton.Left + PasteButton.Width + 3;
UndoButton.Left:= Bevel2.Left + 5;
RedoButton.Left:= UndoButton.Left + UndoButton.Width;
if RedoButton.visible then
UserButtonBevel.Left:= RedoButton.Left + RedoButton.Width + 3
else if UndoButton.visible then
UserButtonBevel.Left:= UndoButton.Left + UndoButton.Width + 3;
StatusBar.visible:= reoShowStatusBar in EditorOptions;
FormatBar.visible:= reoShowFormatBar in EditorOptions;
ToolBar.visible:= reoShowToolBar in EditorOPtions;
ToolBarBevel.visible:= reoShowToolBar in EditorOPtions;
FormatBarBevel.visible:= reoShowFormatBar in EditorOptions;
RulerPanel.visible:= reoShowRuler in EditorOPtions;
if ReadOnly then begin
Format1.visible:= False;
View1.visible:= False;
NewButton.visible:= False;
end;
Toolbar1.checked:= ToolBar.visible;
Formatbar1.checked:= FormatBar.visible;
StatusBar1.checked:= StatusBar.visible;
Ruler1.checked:= RulerPanel.visible;
if OrigRichEdit.UserSpeedButton1<>Nil then with OrigRichEdit.UserSpeedButton1 do
begin
UserButtonBevel.visible:= True;
OldParent1:= parent;
parent:= ToolBar;
visible:= True;
Flat:= (reoFlatButtons in OrigRichEdit.EditorOptions);
Left:= UndoButton.Left + UndoButton.Width + 32;
Top:= UndoButton.Top;
Height:= UndoButton.Height;
end;
if OrigRichEdit.UserSpeedButton2<>Nil then with OrigRichEdit.UserSpeedButton2 do
begin
UserButtonBevel.visible:= True;
OldParent2:= parent;
parent:= ToolBar;
visible:= True;
Flat:= (reoFlatButtons in OrigRichEdit.EditorOptions);
Top:= UndoButton.Top;
Height:= UndoButton.Height;
if OrigRichEdit.UserSpeedButton1<>Nil then
Left:= OrigRichEdit.UserSpeedButton1.Left + OrigRichEdit.UserSpeedButton1.Width
else
Left:= UndoButton.Left + UndoButton.Width + 32;
end
end;
if not (reoFlatButtons in OrigRichEdit.EditorOptions) then
begin
Toolbar.height:= Toolbar.Height + 4;
Formatbar.height:= Formatbar.Height + 2;
with Toolbar do begin
for i:= 0 to ControlCount-1 do
begin
if Controls[i] is TSpeedButton then
with Controls[i] as TSpeedButton do
begin
Top:= Top + 2;
Margin:= Margin - 1;
Flat:= False;
end
else if Controls[i] is TBevel then
with Controls[i] as TBevel do
begin
Controls[i].visible:= False;
end
end
end;
with Formatbar do begin
for i:= 0 to ControlCount-1 do
begin
if Controls[i] is TSpeedButton then
with Controls[i] as TSpeedButton do
begin
Top:= Top + 1;
Margin:= Margin - 1;
Flat:= False;
end
else if Controls[i] is TBevel then
with Controls[i] as TBevel do
begin
Controls[i].visible:= False;
end
end
end
end;
Width:= wwAdjustPixels(Width, PixelsPerInch);
Height:= wwAdjustPixels(Height, PixelsPerInch);
with StatusBar do begin
Panels[1].Width:= wwAdjustPixels(Panels[1].Width, PixelsPerInch);
Panels[2].Width:= wwAdjustPixels(Panels[2].Width, PixelsPerInch);
Panels[3].Width:= wwAdjustPixels(Panels[3].Width, PixelsPerInch);
end;
ApplyIntl;
{ if Assigned(OrigRichEdit.OnMenuLoadClick) then Load1.OnClick:= OrigRichEdit.OnMenuLoadClick;
if Assigned(OrigRichEdit.OnMenuPrintClick) then Print1.OnClick:= OrigRichEdit.OnMenuPrintClick;
if Assigned(OrigRichEdit.OnMenuSaveAsClick) then SaveAs1.OnClick:= OrigRichEdit.OnMenuSaveAsClick;
if Assigned(OrigRichEdit.OnMenuSaveAndExitClick) then SaveExit1.OnClick:= OrigRichEdit.OnMenuSaveAndExitClick;
}
richedit1.DoInitDialog(self);
FormResize(self);
if reoShowMainMenuIcons in RichEdit1.EditorOptions then
MainMenu1.Images:= ImageList1;
end;
procedure TwwRichEditForm.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (ssCtrl in Shift) and (key=ord('Z')) then Undo1Click(Sender);
UpdateStatusBar;
end;
procedure TwwRichEditForm.Paragraph1Click(Sender: TObject);
begin
if RichEdit1.ExecuteParagraphDialog then
TwwRulerPanel(RulerPanel).UpdateDragIcons;
end;
procedure TwwRichEditForm.Edit1Click(Sender: TObject);
begin
RefreshControls;
end;
procedure TwwRichEditForm.Print1Click(Sender: TObject);
var //i: integer;
DoDefault: boolean;
begin
DoDefault:= True;
if Assigned(OrigRichEdit.OnMenuPrintClick) then
OrigRichEdit.OnMenuPrintClick(self, RichEdit1, DoDefault);
if not DoDefault then exit;
{Note: In order for an uncollated printout to take place, the target printer }
{ must support the setting of # of Copies via the Win API, and many do not. }
{ Thus, the Collate option is set to TRUE and NOTHING is done if the user }
{ changes it to FALSE (it still produces a collated printout)... }
printdialog1.collate:= True;
if printdialog1.execute then
begin
// for i:= 1 to printdialog1.copies do { 2/15/2000}
richedit1.Print(OrigRichEdit.PrintJobName);
end
end;
procedure TwwRichEditForm.UpdateFormatToolBar(ShowToolBar, ShowFormatBar: boolean);
begin
if ShowToolBar then begin
if ShowFormatBar then begin
ToolBarBevel.visible:= True;
ToolBar.visible:= True;
ToolBar1.checked:= True;
FormatBarBevel.visible:= True;
FormatBar.visible:= True;
FormatBar1.checked:= True;
end
else begin
FormatBar.visible:= False;
FormatBarBevel.visible:= False;
FormatBar1.checked:= False;
ToolBarBevel.visible:= True;
ToolBar.visible:= True;
ToolBar1.checked:= True;
end
end
else begin
if ShowFormatBar then begin
ToolBar.visible:= False;
ToolBarBevel.visible:= False;
ToolBar1.checked:= False;
FormatBarBevel.visible:= True;
FormatBar.visible:= True;
FormatBar1.checked:= True;
end
else begin
FormatBar.visible:= False;
FormatBarBevel.visible:= False;
FormatBar1.checked:= False;
ToolBar.visible:= False;
ToolBarBevel.visible:= FAlse;
ToolBar1.checked:= False;
end
end;
end;
procedure TwwRichEditForm.Toolbar1Click(Sender: TObject);
begin
UpdateFormatToolBar(not ToolBar.visible, FormatBar.visible);
ToolBar1.checked:= ToolBar.visible;
FormResize(self);
end;
procedure TwwRichEditForm.FormatBar1Click(Sender: TObject);
begin
UpdateFormatToolBar(ToolBar.visible, not FormatBar.visible);
FormatBar1.checked:= FormatBar.visible;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -