procedure TForm1.ECSpeedBtn2Change(Sender: TObject);
var
TxtHrzBar, TxtVrtBar: integer;
SelFontFormat: TFontParams;
begin
TxtHrzBar := GetScrollPos(RichMemo1.handle, SB_HORZ);
TxtVrtBar := GetScrollPos(RichMemo1.handle, SB_VERT);
if RichMemo1.SelLength = 0 then
begin
RichMemo1.GetTextAttributes(RichMemo1.SelStart, SelFontFormat);
if (fsBold in SelFontFormat.Style = False) then
SelFontFormat.Style := SelFontFormat.Style + [fsBold]
else
SelFontFormat.Style := SelFontFormat.Style - [fsBold];
RichMemo1.SetTextAttributes(RichMemo1.SelStart, 0, SelFontFormat);
end
else
begin
ReportPosition;
if (CurrentLin = 1) and (CurrentPos = 1) then
RichMemo1.GetTextAttributes(RichMemo1.SelStart, SelFontFormat) // get in place
else
RichMemo1.GetTextAttributes(RichMemo1.SelStart - 1, SelFontFormat); // get from prior
if (fsBold in SelFontFormat.Style = False) then
begin // not in
RichMemo1.SetRangeParams(RichMemo1.SelStart,
// int: begin position of selection, 0 sets start of file.
RichMemo1.SelLength,
// int: length of selection set.
[tmm_Styles],
// cst: modify types, [] sets to empty, or [tmm_Styles,tmm_Color]
'',
// str: font name, '' sets to empty.
0,
// int: font size, 0 sets to empty.
0,
// int: color, 0 sets to empty.
[fsBold],
// cst: adding styles, [] sets to empty, or [fsBold,fsItalic]
[]
// cst: remove styles, [] sets to empty, or [fsBold,fsItalic]
);
end
else
begin // is in
RichMemo1.SetRangeParams(RichMemo1.SelStart,
// int: begin position of selection, 0 sets start of file.
RichMemo1.SelLength,
// int: length of selection characters, -1 sets end of file.
[tmm_Styles],
// cst: modify types, [] sets to empty, or [tmm_Styles,tmm_Color]
'',
// str: font name, '' sets to empty.
0,
// int: font size, 0 sets to empty.
0,
// int: color, 0 sets to empty.
[],
// cst: adding styles, [] sets to empty, or [fsBold,fsItalic]
[
fsBold] // cst: remove styles, [] sets to empty, or [fsBold,fsItalic]
);
end;
end;
SendMessage(RichMemo1.handle, WM_HSCROLL,
MakeLong(SB_THUMBPOSITION, TxtHrzBar), 0);
SendMessage(RichMemo1.handle, WM_VSCROLL,
MakeLong(SB_THUMBPOSITION, TxtVrtBar), 0);
RichMemo1.SetFocus;
RichMemo1.Repaint;
end;