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

📄 richedit2.pas

📁 类似QQ的源码程序
💻 PAS
📖 第 1 页 / 共 5 页
字号:
      Exit;
    end;
  GetAttributes(Format);
  Result := Format.dwEffects and CFE_IMPRINT <>0;
end;

procedure TTextAttributes98.SetImprint(Value: Boolean);
var
  Format: TCharFormat2W;
begin
  if RichEdit.FVer10 then
    Exit;
  InitFormat(Format);
  with Format do
  begin
    dwMask := CFM_IMPRINT;
    if Value then
      dwEffects:= CFE_IMPRINT;
  end;
  SetAttributes(Format);
end;

function TTextAttributes98.GetIsURL: Boolean;
var
  Format: TCharFormat2W;
begin
  if RichEdit.FVer10 then
    begin
      Result:= False;
      Exit;
    end;
  GetAttributes(Format);
  Result := Format.dwEffects and CFE_LINK <>0;
end;

procedure TTextAttributes98.SetIsURL(Value: Boolean);
var
  Format: TCharFormat2W;
begin
  if RichEdit.FVer10 then
    Exit;
  InitFormat(Format);
  with Format do
  begin
    dwMask := CFM_LINK;
    if Value then
      dwEffects:= CFE_LINK;
  end;
  SetAttributes(Format);
end;

function TTextAttributes98.GetHeight: Integer;
begin
  Result := MulDiv(Size, RichEdit.FScreenLogPixels, 72);
end;

procedure TTextAttributes98.SetHeight(Value: Integer);
begin
  Size := MulDiv(Value, 72, RichEdit.FScreenLogPixels);
end;

function TTextAttributes98.GetStyle: TFontStyles;
var
  Format: TCharFormat2W;
begin
  if RichEdit.FVer10 then
    begin
      Result:= FOldAttr.Style;
      Exit;
    end;
  Result := [];
  GetAttributes(Format);
  with Format do
  begin
    if (dwEffects and Integer(CFE_BOLD)) <> 0 then Include(Result, fsBold);
    if (dwEffects and Integer(CFE_ITALIC)) <> 0 then Include(Result, fsItalic);
    if (dwEffects and Integer(CFE_UNDERLINE)) <> 0 then Include(Result, fsUnderline);
    if (dwEffects and Integer(CFE_STRIKEOUT)) <> 0 then Include(Result, fsStrikeOut);
  end;
end;

procedure TTextAttributes98.SetStyle(Value: TFontStyles);
var
  Format: TCharFormat2W;
begin
  if RichEdit.FVer10 then
    begin
      FOldAttr.Style:= Value;
      Exit;
    end;
  InitFormat(Format);
  with Format do
  begin
    dwMask := CFM_BOLD or CFM_ITALIC or CFM_STRIKEOUT or CFM_UNDERLINETYPE;
    if fsBold in Value then dwEffects := dwEffects or CFE_BOLD;
    if fsItalic in Value then dwEffects := dwEffects or CFE_ITALIC;
    if fsStrikeOut in Value then dwEffects := dwEffects or CFE_STRIKEOUT;
    bUnderlineType:= Ord(fsUnderline in Value);
  end;
  SetAttributes(Format);
end;

{ TParaAttributes98}
constructor TParaAttributes98.Create(AOwner: TCustomRichEdit98);
begin
  inherited Create(AOwner);
  RichEdit := AOwner;
end;

procedure TParaAttributes98.InitPara(var Paragraph: TParaFormat2);
begin
  FillChar(Paragraph, SizeOf(TParaFormat2), 0);
  Paragraph.cbSize := SizeOf(TParaFormat2);
end;

procedure TParaAttributes98.GetAttributes(var Paragraph: TParaFormat2);
begin
  InitPara(Paragraph);
  if RichEdit.HandleAllocated then
    RichEdit.Perform(EM_GETPARAFORMAT, 0, LPARAM(@Paragraph));
end;

procedure TParaAttributes98.SetAttributes(var Paragraph: TParaFormat2);
begin
  if RichEdit.HandleAllocated then
    RichEdit.Perform(EM_SETPARAFORMAT, 0, LPARAM(@Paragraph))
end;

function TParaAttributes98.GetFirstIndent: Double;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= TRichEdit(RichEdit).Paragraph.FirstIndent;
      Exit;
    end;
  GetAttributes(Paragraph);
  Result := Paragraph.dxStartIndent/20;
end;

procedure TParaAttributes98.SetFirstIndent(Value: Double);
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      TRichEdit(RichEdit).Paragraph.FirstIndent:= Round(Value);
      Exit;
    end;
  InitPara(Paragraph);
  with Paragraph do
  begin
    dwMask := PFM_STARTINDENT;
    dxStartIndent := Round(Value * 20);
  end;
  SetAttributes(Paragraph);
end;

function TParaAttributes98.GetLeftIndent: Double;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= TRichEdit(RichEdit).Paragraph.LeftIndent;
      Exit;
    end;
  GetAttributes(Paragraph);
  Result := Paragraph.dxOffset/20;
end;

procedure TParaAttributes98.SetLeftIndent(Value: Double);
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      TRichEdit(RichEdit).Paragraph.LeftIndent:= Round(Value);
      Exit;
    end;
  InitPara(Paragraph);
  with Paragraph do
  begin
    dwMask := PFM_OFFSET;
    dxOffset := Round(Value * 20);
  end;
  SetAttributes(Paragraph);
end;

function TParaAttributes98.GetRightIndent: Double;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= TRichEdit(RichEdit).Paragraph.RightIndent;
      Exit;
    end;
  GetAttributes(Paragraph);
  Result := Paragraph.dxRightIndent/20;
end;

procedure TParaAttributes98.SetRightIndent(Value: Double);
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      TRichEdit(RichEdit).Paragraph.RightIndent:= Round(Value);
      Exit;
    end;
  InitPara(Paragraph);
  with Paragraph do
  begin
    dwMask := PFM_RIGHTINDENT;
    dxRightIndent := Round(Value * 20);
  end;
  SetAttributes(Paragraph);
end;

function TParaAttributes98.GetSpaceBefore: Double;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= 0;
      Exit;
    end;
  GetAttributes(Paragraph);
  Result := Paragraph.dySpaceBefore/20;
end;

procedure TParaAttributes98.SetSpaceBefore(Value: Double);
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    Exit;
  InitPara(Paragraph);
  with Paragraph do
  begin
    dwMask := PFM_SPACEBEFORE;
    dySpaceBefore := Round(Value*20);
  end;
  SetAttributes(Paragraph);
end;

function TParaAttributes98.GetSpaceAfter: Double;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= 0;
      Exit;
    end;
  GetAttributes(Paragraph);
  Result := Paragraph.dySpaceAfter/20;
end;

procedure TParaAttributes98.SetSpaceAfter(Value: Double);
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    Exit;
  InitPara(Paragraph);
  with Paragraph do
  begin
    dwMask := PFM_SPACEAFTER;
    dySpaceAfter := Round(Value*20);
  end;
  SetAttributes(Paragraph);
end;

function TParaAttributes98.GetLineSpacing: Double;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= 0;
      Exit;
    end;
  GetAttributes(Paragraph);
  Result := Paragraph.dyLineSpacing/20;
end;

function TParaAttributes98.GetLineSpacingRule: TLineSpacingRule;
var
  Paragraph: TParaFormat2;
begin
  Result := lsrOrdinary;
  if RichEdit.FVer10 then Exit;
  GetAttributes(Paragraph);
  Result := TLineSpacingRule(Paragraph.bLineSpacingRule);
end;

procedure TParaAttributes98.SetLineSpacing(Rule: TLineSpacingRule; Value: Double);
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    Exit;
  InitPara(Paragraph);
  with Paragraph do
  begin
    dwMask := PFM_LINESPACING;
    bLineSpacingRule:= Ord(Rule);
    dyLineSpacing := Round(Value*20);
  end;
  SetAttributes(Paragraph);
end;

function TParaAttributes98.GetKeepTogether: Boolean;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= False;
      Exit;
    end;
  GetAttributes(Paragraph);
  Result := Paragraph.wReserved and PFE_KEEP <>0;
end;

procedure TParaAttributes98.SetKeepTogether(Value: Boolean);
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    Exit;
  InitPara(Paragraph);
  with Paragraph do
  begin
    dwMask := PFM_KEEP;
    if Value then
      wReserved:= PFE_KEEP;
  end;
  SetAttributes(Paragraph);
end;

function TParaAttributes98.GetKeepWithNext: Boolean;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= False;
      Exit;
    end;
  GetAttributes(Paragraph);
  Result := Paragraph.wReserved and PFE_KEEPNEXT <>0;
end;

procedure TParaAttributes98.SetKeepWithNext(Value: Boolean);
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    Exit;
  InitPara(Paragraph);
  with Paragraph do
  begin
    dwMask := PFM_KEEPNEXT;
    if Value then
      wReserved:= PFE_KEEPNEXT;
  end;
  SetAttributes(Paragraph);
end;

function TParaAttributes98.GetPageBreakBefore: Boolean;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= False;
      Exit;
    end;
  GetAttributes(Paragraph);
  Result := Paragraph.wReserved and PFE_PAGEBREAKBEFORE <>0;
end;

procedure TParaAttributes98.SetPageBreakBefore(Value: Boolean);
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    Exit;
  InitPara(Paragraph);
  with Paragraph do
  begin
    dwMask := PFM_PAGEBREAKBEFORE;
    if Value then
      wReserved:= PFE_PAGEBREAKBEFORE;
  end;
  SetAttributes(Paragraph);
end;

function TParaAttributes98.GetNoLineNumber: Boolean;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= False;
      Exit;
    end;
  GetAttributes(Paragraph);
  Result := Paragraph.wReserved and PFE_NOLINENUMBER <>0;
end;

procedure TParaAttributes98.SetNoLineNumber(Value: Boolean);
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    Exit;
  InitPara(Paragraph);
  with Paragraph do
  begin
    dwMask := PFM_NOLINENUMBER;
    if Value then
      wReserved:= PFE_NOLINENUMBER;
  end;
  SetAttributes(Paragraph);
end;

function TParaAttributes98.GetNoWidowControl: Boolean;
var
  Paragraph: TParaFormat2;
begin
  if RichEdit.FVer10 then
    begin
      Result:= False;
      Exit;
    end;
  

⌨️ 快捷键说明

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