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

📄 wwrich.pas

📁 胜天进销存源码,国产优秀的进销存
💻 PAS
📖 第 1 页 / 共 4 页
字号:

procedure TwwRichEditForm.CopyButtonClick(Sender: TObject);
begin
  Copy1Click(Sender);
end;

procedure TwwRichEditForm.PasteButtonClick(Sender: TObject);
begin
   Paste1Click(Sender);
end;

procedure TwwRichEditForm.UndoButtonClick(Sender: TObject);
begin
   Undo1Click(Sender);
end;

procedure TwwRichEditForm.FontNameComboDropDown(Sender: TObject);
begin
   FontNameCombo.font.color:=clBlack;
end;

procedure TwwRichEditForm.FormChangeHint(Sender: TObject);
begin
   StatusBar.Panels[0].text:=Application.Hint;
end;

procedure TwwRichEditForm.ApplyIntl;
begin
    with wwInternational.RichEdit do begin

       if (reoShowHints in richedit1.EditorOptions) then begin
          FontNameCombo.ShowHint := True;
          FontSizeCombo.ShowHint := True;
          NewButton.ShowHint := True;
          LoadButton1.ShowHint := True;
          SaveAsButton.ShowHint := True;
          PrintButton.ShowHint := True;
          PrintPreviewButton.ShowHint := True;          
          FindButton.ShowHint := True;
          CutButton.ShowHint := True;
          CopyButton.ShowHint := True;
          UndoButton.ShowHint := True;
          RedoButton.ShowHint := True;
          PasteButton.ShowHint := True;
          BoldButton.ShowHint := True;
          UnderlineButton.ShowHint := True;
          ColorButton.ShowHint := True;
          ItalicButton.ShowHint := True;
          LeftButton.ShowHint := True;
          CenterButton.ShowHint := True;
          RightButton.ShowHint := True;
          JustifyButton.ShowHint := True;
          BulletButton.ShowHint := True;
          HighlightButton.ShowHint:= True;
          SpellButton.ShowHint:= True;

    {Change Hints}
    FontNameCombo.Hint := FontNameComboHint;
    FontSizeCombo.Hint := FontSizeComboHint;

    {Buttons}
    NewButton.Hint := NewButtonHint;
    LoadButton1.Hint := LoadButtonHint;
    SaveAsButton.Hint := SaveAsButtonHint;
    PrintButton.Hint := PrintButtonHint;
    PrintPreviewButton.Hint := PrintPreviewButtonHint;    
    FindButton.Hint := FindButtonHint;
    CutButton.Hint := CutButtonHint;
    CopyButton.Hint := CopyButtonHint;
    UndoButton.Hint := UndoButtonHint;
    SpellButton.Hint := SpellCheckHint;

    { 12/23/98 }
    {$ifdef wwdelphi4up}
    RedoButton.Hint := RedoButtonHint;
    {$endif}
    if RedoButton.Hint='' then RedoButton.Hint:= 'Redo | Reverses the last undo action';

    PasteButton.Hint := PasteButtonHint;
    BoldButton.Hint := BoldButtonHint;
    ColorButton.Hint := ColorButtonHint;
       
    UnderlineButton.Hint := UnderlineButtonHint;
    ItalicButton.Hint := ItalicButtonHint;
    LeftButton.Hint := LeftButtonHint;
    CenterButton.Hint := CenterButtonHint;
    JustifyButton.Hint := JustifyButtonHint;
    RightButton.Hint := RightButtonHint;
    BulletButton.Hint := BulletButtonHint;
    HighlightButton.Hint:= HighlightButtonHint;

    {File Menu Items}
    Load1.Hint:= LoadButton1.Hint;
    SaveAs1.Hint:= SaveAsButton.Hint;
    SaveExit1.Hint := SaveExitHint;
    Print1.Hint := PrintButton.Hint;
    PrintPreview1.Hint := PrintPreviewButton.Hint;
    PageSetup1.Hint:=PageSetupHint;
    Exit1.Hint:= ExitHint;

    {Edit Menu Items}
    Undo1.Hint:= UndoButton.Hint;
    Cut1.Hint:= CutButton.Hint;
    Copy1.Hint:= CopyButton.Hint;
    Paste1.Hint:= PasteButton.Hint;
    Find1.Hint:=FindButton.Hint;
    Clear1.Hint:= ClearHint;
    SelectAll1.Hint:= SelectAllHint;
    FindNext1.Hint:= FindNextHint;
    Replace1.Hint:=ReplaceHint;
    InsertObject1.Hint:=InsertObjectHint;
    Spelling1.Hint:= SpellCheckHint;

    {View Menu Items}
    Toolbar1.Hint:= ToolbarHint;
    FormatBar1.Hint:= FormatBarHint;
    StatusBar1.Hint :=ViewStatusBarHint;
    Options1.Hint:=OptionsHint;

    {Format Menu Items}
    Font1.Hint:=FontHint;
    BulletStyle1.Hint:= BulletButton.Hint;
    Paragraph1.Hint:= ParagraphHint;
    Tabs1.Hint:=TabsHint;

    end
    else Application.OnHint := nil;

{Change Menu Item Labels}

    File1.Caption := MenuLabels.FileCaption;
    Load1.Caption := MenuLabels.LoadCaption;
    SaveAs1.Caption := MenuLabels.SaveAsCaption;
    SaveExit1.Caption := MenuLabels.SaveExitCaption;
    Print1.Caption := MenuLabels.PrintCaption;
    PrintPreview1.Caption := MenuLabels.PrintPreviewCaption;
    PageSetup1.Caption := MenuLabels.PageSetupCaption;
    Exit1.Caption := MenuLabels.ExitCaption;

    Edit1.Caption := MenuLabels.EditCaption;
    Undo1.Caption := MenuLabels.UndoCaption;
    Cut1.Caption := MenuLabels.CutCaption;
    Copy1.Caption := MenuLabels.CopyCaption;
    Paste1.Caption := MenuLabels.PasteCaption;
    Clear1.Caption := MenuLabels.ClearCaption;
    Selectall1.Caption := MenuLabels.SelectallCaption;
    Find1.Caption:= MenuLabels.FindCaption;
    FindNext1.Caption:=MenuLabels.FindNextCaption;
    Replace1.Caption:=MenuLabels.ReplaceCaption;
    InsertObject1.Caption:=MenuLabels.InsertObjectCaption;
    {$ifdef wwdelphi4up}
    Insert1.Caption:= MenuLabels.InsertCaption;
    if Insert1.Caption='' then Insert1.caption:= '&Insert';
    Ruler1.Caption:= MenuLabels.RulerCaption;
    if Ruler1.Caption='' then Ruler1.caption:= '&Ruler';
    Redo1.Caption:= MenuLabels.RedoCaption;
    if Redo1.Caption='' then Redo1.caption:= '&Redo';
    {$endif}

    View1.Caption := MenuLabels.ViewCaption;
    Tools1.Caption := MenuLabels.ToolCaption;
    Spelling1.Caption := MenuLabels.SpellCheckCaption;
    Toolbar1.Caption:= MenuLabels.ToolbarCaption;
    FormatBar1.Caption:=MenuLabels.FormatBarCaption;
    StatusBar1.Caption:=MenuLabels.ViewStatusBarCaption;
    Options1.Caption:=MenuLabels.OptionsCaption;

    Format1.Caption:=MenuLabels.FormatCaption;
    Font1.Caption:=MenuLabels.FontCaption;
    BulletStyle1.Caption:=MenuLabels.BulletStyleCaption;
    Paragraph1.Caption:=MenuLabels.ParagraphCaption;
    Tabs1.Caption := MenuLabels.TabsCaption;

    Help1.Caption := MenuLabels.HelpCaption;
    end;
end;

procedure TwwRichEditForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
   Application.OnHint:= OrigOnHint;
   if OrigRichEdit.UserSpeedButton1<>Nil then
   begin
      OrigRichEdit.UserSpeedButton1.parent:= OldParent1;
      OrigRichEdit.UserSpeedButton1.visible:= false;
   end;
   if OrigRichEdit.UserSpeedButton2<>Nil then
   begin
      OrigRichEdit.UserSpeedButton2.parent:= OldParent2;
      OrigRichEdit.UserSpeedButton2.visible:= false;
   end;
end;

procedure TwwRichEditForm.Ruler1Click(Sender: TObject);
begin
   RulerPanel.visible:= not RulerPanel.visible;
   Ruler1.checked:= RulerPanel.visible;
   FormResize(self);
end;

procedure TwwRichEditForm.InsertObject1Click(Sender: TObject);
begin
   richedit1.InsertObjectDialog;
end;

procedure TwwRichEditForm.RedoButtonClick(Sender: TObject);
begin
   Redo1Click(Sender);
end;

procedure TwwRichEditForm.Redo1Click(Sender: TObject);
begin
    SendMessage(RichEdit1.Handle, EM_REDO, 0, 0);
    RefreshControls;
end;

{ Implement Color drop-down list }
procedure TwwRichEditForm.WMCommand(var Message: TWMCommand);
var item: TMenuItem;
begin
   inherited;
   if (Message.NotifyCode = 0) and (PopupMenu1<>nil) then
   begin
      item:= PopupMenu1.FindItem(Message.itemID, fkCommand);
      if item<>nil then Item.Click;
   end
end;

procedure TwwRichEditForm.WMMeasureItem(var Message: TWMMeasureItem);
var Item: TMenuItem;
  function GetMenuFont: HFONT;
  var
    NonClientMetrics: TNonClientMetrics;
  begin
    NonClientMetrics.cbSize := sizeof(NonClientMetrics);
    if SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @NonClientMetrics, 0) then
      Result := CreateFontIndirect(NonClientMetrics.lfMenuFont)
    else
      Result := GetStockObject(SYSTEM_FONT);
  end;
const
  VertPadding = 2;
  HorzPadding = 5;
begin
  inherited;
  if Message.MeasureItemStruct^.CtlType <> ODT_MENU then Exit;
  with Message.MeasureItemStruct^ do
  begin
    Item := TMenuItem(itemData);
    FCanvas.Handle := GetDC(0);
    FCanvas.Font.Handle := GetMenuFont;
    itemHeight := FCanvas.TextHeight(Item.Caption) + VertPadding;
    itemWidth := FCanvas.TextWidth(Item.Caption) + HorzPadding + ColorBoxWidth;
    FCanvas.Font.Handle := 0;
    ReleaseDC(0, FCanvas.Handle);
    FCanvas.Handle := 0;
  end;
end;

function DrawText(Canvas: TCanvas;
   AText: string; ARect: TRect; Style: Integer): TRect;
const
  DT_DISABLED = $80000;
begin
  with Canvas do begin
  // Used by DrawText API Function when "Item" has focus.
  SetBkColor(Handle, ColorToRGB(Brush.Color));
  SetTextColor(Handle, ColorToRGB(Font.Color));

  Refresh;
  if (Style and DT_DISABLED <> 0) and (Style and DT_CALCRECT = 0) then
  begin
    Font.Color := clBtnHighlight;
    OffSetRect(ARect, 1, 1);
    Windows.DrawText(Handle, PChar(AText), Length(AText), ARect, Style);
    SetBkMode(Handle, TRANSPARENT);
    OffSetRect(ARect, -1, -1);
    Font.Color := clBtnShadow;
  end;
  Windows.DrawTextEx(Handle, PChar(AText), Length(AText), ARect, Style, nil);
  result := ARect;
  end;
end;

procedure TwwRichEditForm.WMDrawItem(var Message: TWMDrawItem);
const
  VertMargin = 2;
  HorzMargin = 3;
var
  Item: TMenuItem;
  ColorRect: TRect;
begin
  inherited;
  if Message.DrawItemStruct^.CtlType <> ODT_MENU then Exit;
  with Message.DrawItemStruct^ do
  begin
    FCanvas.Handle := hDC;
    Item := TMenuItem(ItemData);
    if ODS_SELECTED and itemState <> 0 then begin
      FCanvas.Brush.Color := clHighlight;
      FCanvas.Pen.Color := clHighlightText;
      FCanvas.Pen.Color := clBlack;
      FCanvas.Font.Color := clHighlightText;
    end else begin
      FCanvas.Brush.Color := clBtnFace;
      FCanvas.Pen.Color := clWindowText;
      FCanvas.Font.Color := clWindowText
    end;
    FCanvas.FillRect(rcItem);

    ColorRect := Rect(rcItem.Left + HorzMargin, rcItem.Top + VertMargin, rcItem.Left + HorzMargin + ColorBoxWidth, rcItem.Bottom - VertMargin);
    DrawText(FCanvas, Item.Caption, Rect(ColorRect.Right + 1 * HorzMargin, rcItem.Top, rcItem.Right, rcItem.Bottom), DT_VCENTER or DT_SINGLELINE);

    FCanvas.Brush.Color := Item.Tag;
    FCanvas.Rectangle(ColorRect.Left, ColorRect.Top, ColorRect.Right, ColorRect.Bottom);

    FCanvas.Handle := 0;
  end;
end;

procedure TwwRichEditForm.ColorClick(Sender: TObject);
begin
   RichEdit1.SelAttributes.Color:= (Sender as TMenuItem).Tag;
end;

procedure TwwRichEditForm.InitColorMenu;
var i: Integer;
  procedure SetOwnerDraw(Item: TMenuItem);
  type TwwMenuItemInfo = packed record
    cbSize: UINT;
    fMask: UINT;
    fType: UINT;             { used if MIIM_TYPE}
    fState: UINT;            { used if MIIM_STATE}
    wID: UINT;               { used if MIIM_ID}
    hSubMenu: HMENU;         { used if MIIM_SUBMENU}
    hbmpChecked: HBITMAP;    { used if MIIM_CHECKMARKS}
    hbmpUnchecked: HBITMAP;  { used if MIIM_CHECKMARKS}
    dwItemData: DWORD;       { used if MIIM_DATA}
    dwTypeData: PAnsiChar;      { used if MIIM_TYPE}
    cch: UINT;               { used if MIIM_TYPE}
  end;
  var mii: TMenuItemInfo;
  begin
    FillChar(mii, SizeOf(TMenuItemInfo), 0);
    mii.cbSize := SizeOf(TwwMenuItemInfo);
    mii.fMask := MIIM_TYPE or MIIM_DATA;
    mii.fType := MFT_OWNERDRAW;
    mii.dwItemData := Integer(Item);
    SetMenuItemInfo(Item.Parent.Handle, Item.MenuIndex, True, mii);
  end;
begin
  for i := 0 to PopupMenu1.Items.Count - 1 do
  begin
    SetOwnerDraw(PopupMenu1.Items[i]);
    PopupMenu1.Items[i].OnClick:= ColorClick;
  end;
  Automatic1.Tag:= RichEdit1.Font.Color; { Use richedit's font color }
end;



procedure TwwRichEditForm.ColorButtonClick(Sender: TObject);
var p: TPoint;
begin
  p:= FormatBar.ClientToScreen(Point(ColorButton.left, ColorButton.Top + ColorButton.Height));
  TrackPopupMenu(PopupMenu1.Handle, TPM_LEFTALIGN,
     p.x-1, p.y, 0, handle, nil);
end;

procedure TwwRichEditForm.FormCreate(Sender: TObject);
begin
   FCanvas := TCanvas.Create;
end;

procedure TwwRichEditForm.FormDestroy(Sender: TObject);
begin
   FCanvas.Free;
end;

procedure TwwRichEditForm.Spelling1Click(Sender: TObject);
begin
   richedit1.MSWordSpellChecker;
end;

procedure TwwRichEditForm.SpellButtonClick(Sender: TObject);
begin
   Spelling1Click(Sender)
end;

procedure TwwRichEditForm.HighlightButtonClick(Sender: TObject);
begin
  with (Sender as TSpeedButton) do begin
     if not Down then RichEdit1.SetTextBackgroundColor(-1)
     else RichEdit1.SetTextBackgroundColor(RichEdit1.HighlightColor);
  end;
  RefreshControls;

end;

procedure TwwRichEditForm.BoldButtonMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
   tempdown:= (Sender as TSpeedButton).down;
end;

procedure TwwRichEditForm.JustifyButtonClick(Sender: TObject);
begin
   richedit1.SetParaFormat([rpoAlignment],
      wwInternational.RichEdit.ParagraphDialog.AlignJustify,
      False, 0, 0, 0, 0, nil, 0, 0, 0, 0);
   RefreshControls;
end;

end.

⌨️ 快捷键说明

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