You've already forked lazarus-ccr
richmemo: win32 setting RichEdit default font on WS SetFont method
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4147 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -59,6 +59,7 @@ type
|
|||||||
|
|
||||||
class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override;
|
class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override;
|
||||||
class procedure SetColor(const AWinControl: TWinControl); override;
|
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||||
|
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
||||||
|
|
||||||
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
|
||||||
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
|
||||||
@@ -378,6 +379,14 @@ begin
|
|||||||
SendMessage(AWinControl.Handle, EM_SETBKGNDCOLOR, 0, ColorToRGB(AWinControl.Color));
|
SendMessage(AWinControl.Handle, EM_SETBKGNDCOLOR, 0, ColorToRGB(AWinControl.Color));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TWin32WSCustomRichMemo.SetFont(const AWinControl: TWinControl;
|
||||||
|
const AFont: TFont);
|
||||||
|
begin
|
||||||
|
if not Assigned(AWinControl) then Exit;
|
||||||
|
Windows.SendMessage(AWinControl.Handle, WM_SETFONT, Windows.WParam(AFont.Reference.Handle), 1);
|
||||||
|
RichEditManager.SetDefaultTextStyle(AWinControl.Handle, GetFontParams(AFont));
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSCustomRichMemo.SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer);
|
class procedure TWin32WSCustomRichMemo.SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer);
|
||||||
var
|
var
|
||||||
range : Tcharrange;
|
range : Tcharrange;
|
||||||
|
@@ -163,6 +163,7 @@ type
|
|||||||
class function SetEventMask(RichEditWnd: Handle; eventmask: integer): Integer;
|
class function SetEventMask(RichEditWnd: Handle; eventmask: integer): Integer;
|
||||||
|
|
||||||
class function GetTextLength(RichEditWnd: Handle): Integer;
|
class function GetTextLength(RichEditWnd: Handle): Integer;
|
||||||
|
class function SetDefaultTextStyle(RichEditWnd: Handle; Params: TIntFontParams): Boolean; virtual;
|
||||||
class function SetSelectedTextStyle(RichEditWnd: Handle; Params: TIntFontParams): Boolean; virtual;
|
class function SetSelectedTextStyle(RichEditWnd: Handle; Params: TIntFontParams): Boolean; virtual;
|
||||||
class function GetSelectedTextStyle(RichEditWnd: Handle; var Params: TIntFontParams): Boolean; virtual;
|
class function GetSelectedTextStyle(RichEditWnd: Handle; var Params: TIntFontParams): Boolean; virtual;
|
||||||
class procedure SetTextUIStyle(RichEditWnd: Handle; const ui: TTextUIParam); virtual;
|
class procedure SetTextUIStyle(RichEditWnd: Handle; const ui: TTextUIParam); virtual;
|
||||||
@@ -333,6 +334,38 @@ begin
|
|||||||
Result := SendMessage(RichEditWnd, EM_GETTEXTLENGTHEX, WPARAM(@textlen), 0);
|
Result := SendMessage(RichEditWnd, EM_GETTEXTLENGTHEX, WPARAM(@textlen), 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TRichEditManager.SetDefaultTextStyle(RichEditWnd: Handle;
|
||||||
|
Params: TIntFontParams): Boolean;
|
||||||
|
var
|
||||||
|
w : WPARAM;
|
||||||
|
fmt : TCHARFORMAT2;
|
||||||
|
begin
|
||||||
|
if RichEditWnd = 0 then begin
|
||||||
|
Result := false;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
w := SCF_DEFAULT;
|
||||||
|
|
||||||
|
FillChar(fmt, sizeof(fmt), 0);
|
||||||
|
fmt.cbSize := sizeof(fmt);
|
||||||
|
|
||||||
|
fmt.dwMask := fmt.dwMask or CFM_COLOR;
|
||||||
|
fmt.crTextColor := Params.Color;
|
||||||
|
|
||||||
|
fmt.dwMask := fmt.dwMask or CFM_FACE;
|
||||||
|
// keep last char for Null-termination?
|
||||||
|
CopyStringToCharArray(Params.Name, fmt.szFaceName, LF_FACESIZE-1);
|
||||||
|
|
||||||
|
fmt.dwMask := fmt.dwMask or CFM_SIZE;
|
||||||
|
fmt.yHeight := Params.Size * TwipsInFontSize;
|
||||||
|
|
||||||
|
fmt.dwMask := fmt.dwMask or CFM_EFFECTS or CFM_SUBSCRIPT or CFM_SUPERSCRIPT;
|
||||||
|
fmt.dwEffects := FontStylesToEffects(Params.Style) or VScriptPosToEffects(Params.VScriptPos);
|
||||||
|
|
||||||
|
Result := SendMessage(RichEditWnd, EM_SETCHARFORMAT, w, PtrInt(@fmt))>0;
|
||||||
|
end;
|
||||||
|
|
||||||
class function TRichEditManager.SetSelectedTextStyle(RichEditWnd: Handle;
|
class function TRichEditManager.SetSelectedTextStyle(RichEditWnd: Handle;
|
||||||
Params: TIntFontParams): Boolean;
|
Params: TIntFontParams): Boolean;
|
||||||
var
|
var
|
||||||
|
Reference in New Issue
Block a user