You've already forked lazarus-ccr
fix for win32RichMemo background color as suggested by Dusan.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@919 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -211,9 +211,10 @@ end;
|
|||||||
function TCustomRichMemo.GetStyleRange(CharOfs: Integer; var RangeStart,
|
function TCustomRichMemo.GetStyleRange(CharOfs: Integer; var RangeStart,
|
||||||
RangeLen: Integer): Boolean;
|
RangeLen: Integer): Boolean;
|
||||||
begin
|
begin
|
||||||
if HandleAllocated then
|
if HandleAllocated then begin
|
||||||
Result := TWSCustomRichMemoClass(WidgetSetClass).GetStyleRange(Self, CharOfs, RangeStart, RangeLen)
|
Result := TWSCustomRichMemoClass(WidgetSetClass).GetStyleRange(Self, CharOfs, RangeStart, RangeLen);
|
||||||
else begin
|
if Result and (RangeLen = 0) then RangeLen := 1;
|
||||||
|
end else begin
|
||||||
RangeStart := -1;
|
RangeStart := -1;
|
||||||
RangeLen := -1;
|
RangeLen := -1;
|
||||||
Result := false;
|
Result := false;
|
||||||
|
@ -42,6 +42,8 @@ type
|
|||||||
|
|
||||||
TWin32WSCustomRichMemo = class(TWSCustomRichMemo)
|
TWin32WSCustomRichMemo = class(TWSCustomRichMemo)
|
||||||
published
|
published
|
||||||
|
class procedure SetColor(const AWinControl: TWinControl); 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;
|
||||||
|
|
||||||
@ -92,6 +94,13 @@ end;
|
|||||||
|
|
||||||
{ TWin32WSCustomRichMemo }
|
{ TWin32WSCustomRichMemo }
|
||||||
|
|
||||||
|
class procedure TWin32WSCustomRichMemo.SetColor(const AWinControl: TWinControl);
|
||||||
|
begin
|
||||||
|
// this methos is implemented, because Win32RichMemo doesn't use
|
||||||
|
// default LCL WM_PAINT message!
|
||||||
|
SendMessage(AWinControl.Handle, EM_SETBKGNDCOLOR, 0, AWinControl.Color);
|
||||||
|
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;
|
||||||
@ -151,8 +160,10 @@ begin
|
|||||||
Flags := Flags and not WS_HSCROLL
|
Flags := Flags and not WS_HSCROLL
|
||||||
else
|
else
|
||||||
Flags := Flags or ES_AUTOHSCROLL;
|
Flags := Flags or ES_AUTOHSCROLL;
|
||||||
|
|
||||||
if ACustomMemo.BorderStyle=bsSingle then
|
if ACustomMemo.BorderStyle=bsSingle then
|
||||||
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
|
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
|
||||||
|
|
||||||
pClassName := @RichClass[1];
|
pClassName := @RichClass[1];
|
||||||
WindowTitle := StrCaption;
|
WindowTitle := StrCaption;
|
||||||
end;
|
end;
|
||||||
@ -185,19 +196,23 @@ begin
|
|||||||
RichEditManager.SetSelectedTextStyle(AWinControl.Handle, Params);
|
RichEditManager.SetSelectedTextStyle(AWinControl.Handle, Params);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWin32WSCustomRichMemo.GetTextAttributes(
|
class function TWin32WSCustomRichMemo.GetTextAttributes(const AWinControl: TWinControl;
|
||||||
const AWinControl: TWinControl; TextStart: Integer; var Params: TIntFontParams
|
TextStart: Integer; var Params: TIntFontParams): Boolean;
|
||||||
): Boolean;
|
|
||||||
var
|
var
|
||||||
OrigStart : Integer;
|
OrigStart : Integer;
|
||||||
OrigLen : Integer;
|
OrigLen : Integer;
|
||||||
NeedLock : Boolean;
|
NeedLock : Boolean;
|
||||||
|
eventmask : LongWord;
|
||||||
begin
|
begin
|
||||||
|
writeln('[GetTextAttributes] begin');
|
||||||
if not Assigned(RichEditManager) or not Assigned(AWinControl) then begin
|
if not Assigned(RichEditManager) or not Assigned(AWinControl) then begin
|
||||||
Result := false;
|
Result := false;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
eventmask := SendMessage(AWinControl.Handle, EM_GETEVENTMASK, 0, 0);
|
||||||
|
SendMessage(AWinControl.Handle, EM_SETEVENTMASK, 0, 0);
|
||||||
|
|
||||||
RichEditManager.GetSelection(AWinControl.Handle, OrigStart, OrigLen);
|
RichEditManager.GetSelection(AWinControl.Handle, OrigStart, OrigLen);
|
||||||
|
|
||||||
NeedLock := (OrigStart <> TextStart);
|
NeedLock := (OrigStart <> TextStart);
|
||||||
@ -207,8 +222,14 @@ begin
|
|||||||
Result := RichEditManager.GetSelectedTextStyle(AWinControl.Handle, Params );
|
Result := RichEditManager.GetSelectedTextStyle(AWinControl.Handle, Params );
|
||||||
RichEditManager.SetSelection(AWinControl.Handle, OrigStart, OrigLen);
|
RichEditManager.SetSelection(AWinControl.Handle, OrigStart, OrigLen);
|
||||||
UnlockRedraw(AWinControl.Handle);
|
UnlockRedraw(AWinControl.Handle);
|
||||||
end else
|
end else begin
|
||||||
|
LockRedraw(AWinControl.Handle);
|
||||||
Result := RichEditManager.GetSelectedTextStyle(AWinControl.Handle, Params);
|
Result := RichEditManager.GetSelectedTextStyle(AWinControl.Handle, Params);
|
||||||
|
UnlockRedraw(AWinControl.Handle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
SendMessage(AWinControl.Handle, EM_SETEVENTMASK, 0, eventmask);
|
||||||
|
writeln('[GetTextAttributes] end');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -236,12 +257,16 @@ var
|
|||||||
vInfo : TScrollInfo;
|
vInfo : TScrollInfo;
|
||||||
hVisible : Boolean;
|
hVisible : Boolean;
|
||||||
vVisible : Boolean;
|
vVisible : Boolean;
|
||||||
|
eventmask : longword;
|
||||||
begin
|
begin
|
||||||
if not Assigned(RichEditManager) or not Assigned(AWinControl) then begin
|
if not Assigned(RichEditManager) or not Assigned(AWinControl) then begin
|
||||||
Result := false;
|
Result := false;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
eventmask := SendMessage(AWinControl.Handle, EM_GETEVENTMASK, 0, 0);
|
||||||
|
SendMessage(AWinControl.Handle, EM_SETEVENTMASK, 0, 0);
|
||||||
|
|
||||||
RichEditManager.GetSelection(AWinControl.Handle, OrigStart, OrigLen);
|
RichEditManager.GetSelection(AWinControl.Handle, OrigStart, OrigLen);
|
||||||
LockRedraw(AWinControl.Handle);
|
LockRedraw(AWinControl.Handle);
|
||||||
InitScrollInfo(hInfo);
|
InitScrollInfo(hInfo);
|
||||||
@ -261,6 +286,8 @@ begin
|
|||||||
if vVisible then SetScrollInfo(AWinControl.Handle, SB_Vert, vInfo, false);
|
if vVisible then SetScrollInfo(AWinControl.Handle, SB_Vert, vInfo, false);
|
||||||
RichEditManager.SetSelection(AWinControl.Handle, OrigStart, OrigLen);
|
RichEditManager.SetSelection(AWinControl.Handle, OrigStart, OrigLen);
|
||||||
UnlockRedraw(AWinControl.Handle, false);
|
UnlockRedraw(AWinControl.Handle, false);
|
||||||
|
|
||||||
|
SendMessage(AWinControl.Handle, EM_SETEVENTMASK, 0, eventmask);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWin32WSCustomRichMemo.LoadRichText(
|
class function TWin32WSCustomRichMemo.LoadRichText(
|
||||||
|
@ -48,7 +48,6 @@ type
|
|||||||
class procedure SetHideSelection(RichEditWnd: Handle; AValue: Boolean); virtual;
|
class procedure SetHideSelection(RichEditWnd: Handle; AValue: Boolean); virtual;
|
||||||
class function LoadRichText(RichEditWnd: Handle; ASrc: TStream): Boolean; virtual;
|
class function LoadRichText(RichEditWnd: Handle; ASrc: TStream): Boolean; virtual;
|
||||||
class function SaveRichText(RichEditWnd: Handle; ADst: TStream): Boolean; virtual;
|
class function SaveRichText(RichEditWnd: Handle; ADst: TStream): Boolean; virtual;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
TRichManagerClass = class of TRichEditManager;
|
TRichManagerClass = class of TRichEditManager;
|
||||||
|
|
||||||
@ -77,13 +76,14 @@ end;
|
|||||||
function InitRichEdit: Boolean;
|
function InitRichEdit: Boolean;
|
||||||
begin
|
begin
|
||||||
if GlobalRichClass = '' then begin
|
if GlobalRichClass = '' then begin
|
||||||
if LoadLibrary('Msftedit.dll') <> 0 then begin
|
if LoadLibrary('Msftedit.dll') <> 0 then begin
|
||||||
GlobalRichClass := 'RichEdit50W'
|
GlobalRichClass := 'RichEdit50W';
|
||||||
end else if LoadLibrary('RICHED20.DLL') <> 0 then begin
|
end else if LoadLibrary('RICHED20.DLL') <> 0 then begin
|
||||||
if UnicodeEnabledOS then GlobalRichClass := 'RichEdit20W'
|
if UnicodeEnabledOS then GlobalRichClass := 'RichEdit20W'
|
||||||
else GlobalRichClass := 'RichEdit20A'
|
else GlobalRichClass := 'RichEdit20A'
|
||||||
end else if LoadLibrary('RICHED32.DLL') <> 0 then
|
end else if LoadLibrary('RICHED32.DLL') <> 0 then begin
|
||||||
GlobalRichClass := 'RichEdit';
|
GlobalRichClass := 'RichEdit';
|
||||||
|
end;
|
||||||
|
|
||||||
if not Assigned(RichEditManager) then
|
if not Assigned(RichEditManager) then
|
||||||
RichEditManager := TRichEditManager;
|
RichEditManager := TRichEditManager;
|
||||||
@ -208,7 +208,7 @@ begin
|
|||||||
Result := false;
|
Result := false;
|
||||||
if RichEditWnd = 0 then Exit;
|
if RichEditWnd = 0 then Exit;
|
||||||
|
|
||||||
textlen.flags := GTL_DEFAULT or GTL_NUMCHARS;
|
textlen.flags := GTL_NUMCHARS or GTL_USECRLF or GTL_PRECISE;
|
||||||
textlen.codepage := CP_UNICODE;
|
textlen.codepage := CP_UNICODE;
|
||||||
len := SendMessage(RichEditWnd, EM_GETTEXTLENGTHEX, WPARAM(@textlen), 0);
|
len := SendMessage(RichEditWnd, EM_GETTEXTLENGTHEX, WPARAM(@textlen), 0);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user