📄 rm_jvrichedit.pas
字号:
end;
SetAttributes(Paragraph);
end;
function TJvParaAttributes.GetFirstIndent: Longint;
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
Result := Paragraph.dxStartIndent div 20;
end;
procedure TJvParaAttributes.SetFirstIndent(Value: Longint);
var
Paragraph: TJvParaFormat2;
begin
InitPara(Paragraph);
with Paragraph do
begin
dwMask := PFM_STARTINDENT;
dxStartIndent := Value * 20;
end;
SetAttributes(Paragraph);
end;
function TJvParaAttributes.GetHeadingStyle: THeadingStyle;
var
Paragraph: TJvParaFormat2;
begin
if RichEditVersion < 3 then
Result := 0
else
begin
GetAttributes(Paragraph);
Result := Paragraph.sStyle;
end;
end;
procedure TJvParaAttributes.SetHeadingStyle(Value: THeadingStyle);
var
Paragraph: TJvParaFormat2;
begin
if RichEditVersion < 3 then
Exit;
InitPara(Paragraph);
with Paragraph do
begin
dwMask := PFM_STYLE;
sStyle := Value;
end;
SetAttributes(Paragraph);
end;
function TJvParaAttributes.GetLeftIndent: Longint;
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
Result := Paragraph.dxOffset div 20;
end;
procedure TJvParaAttributes.SetLeftIndent(Value: Longint);
var
Paragraph: TJvParaFormat2;
begin
InitPara(Paragraph);
with Paragraph do
begin
dwMask := PFM_OFFSET;
dxOffset := Value * 20;
end;
SetAttributes(Paragraph);
end;
function TJvParaAttributes.GetRightIndent: Longint;
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
Result := Paragraph.dxRightIndent div 20;
end;
procedure TJvParaAttributes.SetRightIndent(Value: Longint);
var
Paragraph: TJvParaFormat2;
begin
InitPara(Paragraph);
with Paragraph do
begin
dwMask := PFM_RIGHTINDENT;
dxRightIndent := Value * 20;
end;
SetAttributes(Paragraph);
end;
function TJvParaAttributes.GetSpaceAfter: Longint;
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
Result := Paragraph.dySpaceAfter div 20;
end;
procedure TJvParaAttributes.SetSpaceAfter(Value: Longint);
var
Paragraph: TJvParaFormat2;
begin
if RichEditVersion < 2 then
Exit;
InitPara(Paragraph);
with Paragraph do
begin
dwMask := PFM_SPACEAFTER;
dySpaceAfter := Value * 20;
end;
SetAttributes(Paragraph);
end;
function TJvParaAttributes.GetSpaceBefore: Longint;
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
Result := Paragraph.dySpaceBefore div 20;
end;
procedure TJvParaAttributes.SetSpaceBefore(Value: Longint);
var
Paragraph: TJvParaFormat2;
begin
if RichEditVersion < 2 then
Exit;
InitPara(Paragraph);
with Paragraph do
begin
dwMask := PFM_SPACEBEFORE;
dySpaceBefore := Value * 20;
end;
SetAttributes(Paragraph);
end;
function TJvParaAttributes.GetLineSpacing: Longint;
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
Result := Paragraph.dyLineSpacing div 20;
end;
procedure TJvParaAttributes.SetLineSpacing(Value: Longint);
var
Paragraph: TJvParaFormat2;
begin
if RichEditVersion < 2 then
Exit;
GetAttributes(Paragraph);
with Paragraph do
begin
dwMask := PFM_LINESPACING;
dyLineSpacing := Value * 20;
end;
SetAttributes(Paragraph);
end;
function TJvParaAttributes.GetLineSpacingRule: TLineSpacingRule;
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
Result := TLineSpacingRule(Paragraph.bLineSpacingRule);
end;
procedure TJvParaAttributes.SetLineSpacingRule(Value: TLineSpacingRule);
var
Paragraph: TJvParaFormat2;
begin
if RichEditVersion < 2 then
Exit;
GetAttributes(Paragraph);
with Paragraph do
begin
dwMask := PFM_LINESPACING;
bLineSpacingRule := Ord(Value);
end;
SetAttributes(Paragraph);
end;
function TJvParaAttributes.GetTab(Index: Byte): Longint;
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
Result := Paragraph.rgxTabs[Index] div 20;
end;
procedure TJvParaAttributes.SetTab(Index: Byte; Value: Longint);
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
with Paragraph do
begin
rgxTabs[Index] := Value * 20;
dwMask := PFM_TABSTOPS;
if cTabCount < Index then
cTabCount := Index;
SetAttributes(Paragraph);
end;
end;
function TJvParaAttributes.GetTabCount: Integer;
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
Result := Paragraph.cTabCount;
end;
procedure TJvParaAttributes.SetTabCount(Value: Integer);
var
Paragraph: TJvParaFormat2;
begin
GetAttributes(Paragraph);
with Paragraph do
begin
dwMask := PFM_TABSTOPS;
cTabCount := Value;
SetAttributes(Paragraph);
end;
end;
function TJvParaAttributes.GetTableStyle: TParaTableStyle;
var
Paragraph: TJvParaFormat2;
begin
Result := tsNone;
if RichEditVersion < 2 then
Exit;
GetAttributes(Paragraph);
with Paragraph do
begin
if (wReserved and PFE_TABLEROW) <> 0 then
Result := tsTableRow
else
if (wReserved and PFE_TABLECELLEND) <> 0 then
Result := tsTableCellEnd
else
if (wReserved and PFE_TABLECELL) <> 0 then
Result := tsTableCell;
end;
end;
procedure TJvParaAttributes.SetTableStyle(Value: TParaTableStyle);
var
Paragraph: TJvParaFormat2;
begin
if RichEditVersion < 2 then
Exit;
InitPara(Paragraph);
with Paragraph do
begin
dwMask := PFM_TABLE;
case Value of
tsTableRow:
wReserved := PFE_TABLEROW;
tsTableCellEnd:
wReserved := PFE_TABLECELLEND;
tsTableCell:
wReserved := PFE_TABLECELL;
end;
end;
SetAttributes(Paragraph);
end;
procedure TJvParaAttributes.AssignTo(Dest: TPersistent);
var
I: Integer;
begin
if Dest is TParaAttributes then
begin
with TParaAttributes(Dest) do
begin
if Self.Alignment = paJustify then
Alignment := taLeftJustify
else
Alignment := TAlignment(Self.Alignment);
FirstIndent := Self.FirstIndent;
LeftIndent := Self.LeftIndent;
RightIndent := Self.RightIndent;
if Self.Numbering <> nsNone then
Numbering := TNumberingStyle(nsBullet)
else
Numbering := TNumberingStyle(nsNone);
for I := 0 to MAX_TAB_STOPS - 1 do
Tab[I] := Self.Tab[I];
end;
end
else
inherited AssignTo(Dest);
end;
procedure TJvParaAttributes.Assign(Source: TPersistent);
var
I: Integer;
Paragraph: TJvParaFormat2;
begin
if Source is TParaAttributes then
begin
Alignment := TParaAlignment(TParaAttributes(Source).Alignment);
FirstIndent := TParaAttributes(Source).FirstIndent;
LeftIndent := TParaAttributes(Source).LeftIndent;
RightIndent := TParaAttributes(Source).RightIndent;
Numbering := TJvNumbering(TParaAttributes(Source).Numbering);
for I := 0 to MAX_TAB_STOPS - 1 do
Tab[I] := TParaAttributes(Source).Tab[I];
end
else
if Source is TJvParaAttributes then
begin
TJvParaAttributes(Source).GetAttributes(Paragraph);
SetAttributes(Paragraph);
end
else
inherited Assign(Source);
end;
{ OLE utility routines }
function WStrLen(Str: PWideChar): Integer;
begin
Result := 0;
while Str[Result] <> #0 do
Inc(Result);
end;
procedure ReleaseObject(var Obj);
begin
if IUnknown(Obj) <> nil then
begin
{$IFNDEF COMPILER3_UP}
IUnknown(Obj).Release;
{$ENDIF}
IUnknown(Obj) := nil;
end;
end;
procedure CreateStorage(var Storage: IStorage);
var
LockBytes: ILockBytes;
begin
OleCheck(CreateILockBytesOnHGlobal(0, True, LockBytes));
try
OleCheck(StgCreateDocfileOnILockBytes(LockBytes, STGM_READWRITE
or STGM_SHARE_EXCLUSIVE or STGM_CREATE, 0, Storage));
finally
ReleaseObject(LockBytes);
end;
end;
procedure DestroyMetaPict(MetaPict: HGLOBAL);
begin
if MetaPict <> 0 then
begin
DeleteMetaFile(PMetaFilePict(GlobalLock(MetaPict))^.hMF);
GlobalUnlock(MetaPict);
GlobalFree(MetaPict);
end;
end;
function OleSetDrawAspect(OleObject: IOleObject; Iconic: Boolean;
IconMetaPict: HGLOBAL; var DrawAspect: Longint): HRESULT;
var
OleCache: IOleCache;
EnumStatData: IEnumStatData;
OldAspect, AdviseFlags, Connection: Longint;
TempMetaPict: HGLOBAL;
FormatEtc: TFormatEtc;
Medium: TStgMedium;
ClassID: TCLSID;
StatData: TStatData;
begin
Result := S_OK;
OldAspect := DrawAspect;
if Iconic then
begin
DrawAspect := DVASPECT_ICON;
AdviseFlags := ADVF_NODATA;
end
else
begin
DrawAspect := DVASPECT_CONTENT;
AdviseFlags := ADVF_PRIMEFIRST;
end;
if (DrawAspect <> OldAspect) or (DrawAspect = DVASPECT_ICON) then
begin
{$IFDEF COMPILER3_UP}
Result := OleObject.QueryInterface(IOleCache, OleCache);
{$ELSE}
Result := OleObject.QueryInterface(IID_IOleCache, OleCache);
{$ENDIF}
if Succeeded(Result) then
try
if DrawAspect <> OldAspect then
begin
{ Setup new cache with the new aspect }
FillChar(FormatEtc, SizeOf(FormatEtc), 0);
FormatEtc.dwAspect := DrawAspect;
FormatEtc.lIndex := -1;
Result := OleCache.Cache(FormatEtc, AdviseFlags, Connection);
end;
if Succeeded(Result) and (DrawAspect = DVASPECT_ICON) then
begin
TempMetaPict := 0;
if IconMetaPict = 0 then
begin
if Succeeded(OleObject.GetUserClassID(ClassID)) then
begin
TempMetaPict := OleGetIconOfClass(ClassID, nil, True);
IconMetaPict := TempMetaPict;
end;
end;
try
FormatEtc.cfFormat := CF_METAFILEPICT;
FormatEtc.ptd := nil;
FormatEtc.dwAspect := DVASPECT_ICON;
FormatEtc.lIndex := -1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -