You've already forked lazarus-ccr
richmemo: selection change win32 implementation
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3803 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -107,6 +107,9 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
type
|
||||||
|
TIntCustomRichMemo = class(TCustomRichMemo);
|
||||||
|
|
||||||
const
|
const
|
||||||
AlignmentToEditFlags: array[TAlignment] of DWord =
|
AlignmentToEditFlags: array[TAlignment] of DWord =
|
||||||
(
|
(
|
||||||
@ -128,15 +131,40 @@ begin
|
|||||||
Windows.InvalidateRect(AHandle, nil, true);
|
Windows.InvalidateRect(AHandle, nil, true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function RichEditNotifyProc(const AWinControl: TWinControl; Window: HWnd;
|
||||||
|
Msg: UInt; WParam: Windows.WParam; LParam: Windows.LParam;
|
||||||
|
var MsgResult: Windows.LResult; var WinProcess: Boolean): Boolean;
|
||||||
|
var
|
||||||
|
sch : PSELCHANGE;
|
||||||
|
begin
|
||||||
|
Result:=false; // we need to catch just notifications,
|
||||||
|
// any other message should be handled in a "Default" manner
|
||||||
|
// So, default result is false;
|
||||||
|
case Msg of
|
||||||
|
WM_NOTIFY: begin
|
||||||
|
sch:=PSELCHANGE(LPARAM);
|
||||||
|
if sch^.nmhdr.code=EN_SELCHANGE then
|
||||||
|
begin
|
||||||
|
if Assigned(AWinControl) and (AWinControl is TCustomRichMemo) then
|
||||||
|
TIntCustomRichMemo(AWinControl).DoSelectionChange;
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function RichEditProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
function RichEditProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
|
||||||
LParam: Windows.LParam): LResult; stdcall;
|
LParam: Windows.LParam): LResult; stdcall;
|
||||||
begin
|
begin
|
||||||
if Msg = WM_PAINT then begin
|
case Msg of
|
||||||
//todo: LCL WM_PAINT handling prevents richedit from drawing correctly
|
WM_PAINT : begin
|
||||||
Result := CallDefaultWindowProc(Window, Msg, WParam, LParam)
|
//todo: LCL WM_PAINT handling prevents richedit from drawing correctly
|
||||||
//Result := WindowProc(Window, Msg, WParam, LParam)
|
Result := CallDefaultWindowProc(Window, Msg, WParam, LParam)
|
||||||
end else
|
//Result := WindowProc(Window, Msg, WParam, LParam)
|
||||||
|
end;
|
||||||
|
else
|
||||||
Result := WindowProc(Window, Msg, WParam, LParam);
|
Result := WindowProc(Window, Msg, WParam, LParam);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TWin32RichMemoStringsW }
|
{ TWin32RichMemoStringsW }
|
||||||
@ -221,21 +249,33 @@ 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;
|
||||||
|
eventmask : LParam;
|
||||||
begin
|
begin
|
||||||
|
eventmask := SendMessage(ACustomEdit.Handle, EM_GETEVENTMASK, 0, 0);
|
||||||
|
SendMessage(ACustomEdit.Handle, EM_SETEVENTMASK, 0, 0);
|
||||||
|
|
||||||
range.cpMin := NewStart;
|
range.cpMin := NewStart;
|
||||||
range.cpMax := NewStart;
|
range.cpMax := NewStart;
|
||||||
SendMessage(ACustomEdit.Handle, EM_EXSETSEL, 0, LPARAM(@range));
|
SendMessage(ACustomEdit.Handle, EM_EXSETSEL, 0, LPARAM(@range));
|
||||||
InvalidateRect(ACustomEdit.Handle, nil, false);
|
InvalidateRect(ACustomEdit.Handle, nil, false);
|
||||||
|
|
||||||
|
SendMessage(ACustomEdit.Handle, EM_SETEVENTMASK, 0, eventmask);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSCustomRichMemo.SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer);
|
class procedure TWin32WSCustomRichMemo.SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer);
|
||||||
var
|
var
|
||||||
range : Tcharrange;
|
range : Tcharrange;
|
||||||
|
eventmask : LParam;
|
||||||
begin
|
begin
|
||||||
|
eventmask := SendMessage(ACustomEdit.Handle, EM_GETEVENTMASK, 0, 0);
|
||||||
|
SendMessage(ACustomEdit.Handle, EM_SETEVENTMASK, 0, 0);
|
||||||
|
|
||||||
SendMessage(ACustomEdit.Handle, EM_EXGETSEL, 0, LPARAM(@range));
|
SendMessage(ACustomEdit.Handle, EM_EXGETSEL, 0, LPARAM(@range));
|
||||||
range.cpMax := range.cpMin + NewLength;
|
range.cpMax := range.cpMin + NewLength;
|
||||||
SendMessage(ACustomEdit.Handle, EM_EXSETSEL, 0, LPARAM(@range));
|
SendMessage(ACustomEdit.Handle, EM_EXSETSEL, 0, LPARAM(@range));
|
||||||
InvalidateRect(ACustomEdit.Handle, nil, false);
|
InvalidateRect(ACustomEdit.Handle, nil, false);
|
||||||
|
|
||||||
|
SendMessage(ACustomEdit.Handle, EM_SETEVENTMASK, 0, eventmask);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSCustomRichMemo.CutToClipboard(const AWinControl: TWinControl);
|
class procedure TWin32WSCustomRichMemo.CutToClipboard(const AWinControl: TWinControl);
|
||||||
@ -259,6 +299,7 @@ var
|
|||||||
Params : TCreateWindowExParams;
|
Params : TCreateWindowExParams;
|
||||||
RichClass : AnsiString;
|
RichClass : AnsiString;
|
||||||
ACustomMemo : TCustomMemo;
|
ACustomMemo : TCustomMemo;
|
||||||
|
eventmask : LPARAM;
|
||||||
begin
|
begin
|
||||||
InitRichEdit;
|
InitRichEdit;
|
||||||
RichClass := GetRichEditClass;
|
RichClass := GetRichEditClass;
|
||||||
@ -269,7 +310,7 @@ begin
|
|||||||
|
|
||||||
// general initialization of Params
|
// general initialization of Params
|
||||||
|
|
||||||
// if you're using 0.9.28.2 compiler, uncomment the line,
|
// if you're using 0.9.28.2 lazarus, uncomment the line,
|
||||||
// PrepareCreateWindow(AWinControl, Params);
|
// PrepareCreateWindow(AWinControl, Params);
|
||||||
// and comment the following like (it's for 0.9.30 compatiblity):
|
// and comment the following like (it's for 0.9.30 compatiblity):
|
||||||
PrepareCreateWindow(AWinControl, AParams, Params);
|
PrepareCreateWindow(AWinControl, AParams, Params);
|
||||||
@ -306,7 +347,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
// create window
|
// create window
|
||||||
FinishCreateWindow(AWinControl, Params, false);
|
FinishCreateWindow(AWinControl, Params, false);
|
||||||
|
|
||||||
|
eventmask := SendMessage(AWinControl.Handle, EM_GETEVENTMASK, 0, 0);
|
||||||
|
eventmask := eventmask or ENM_SELCHANGE;
|
||||||
|
SendMessage(AWinControl.Handle, EM_SETEVENTMASK, 0, eventmask);
|
||||||
|
|
||||||
// memo is not a transparent control -> no need for parentpainting
|
// memo is not a transparent control -> no need for parentpainting
|
||||||
|
PArams.WindowInfo^.ParentMsgHandler := @RichEditNotifyProc;
|
||||||
Params.WindowInfo^.needParentPaint := false;
|
Params.WindowInfo^.needParentPaint := false;
|
||||||
Result := Params.Window;
|
Result := Params.Window;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user