mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 17:19:23 +02:00
win32: use a hardcoded flag to avoid sending LM_CHANGED msg to LCL when handling BM_SETCHECK (TCustomCheckBox), fixes #17425
git-svn-id: trunk@27386 -
This commit is contained in:
parent
f42d3f84d8
commit
0d632cce9c
@ -560,7 +560,7 @@ var
|
|||||||
Parent: TWinControl;
|
Parent: TWinControl;
|
||||||
Sibling: TControl;
|
Sibling: TControl;
|
||||||
WinControl: TWinControlAccess absolute Sibling;
|
WinControl: TWinControlAccess absolute Sibling;
|
||||||
PreviousCheckState: LRESULT;
|
LParamFlag: LRESULT;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Parent := RadioButton.Parent;
|
Parent := RadioButton.Parent;
|
||||||
@ -571,9 +571,12 @@ var
|
|||||||
begin
|
begin
|
||||||
// Pass previous state through LParam so the event handling can decide
|
// Pass previous state through LParam so the event handling can decide
|
||||||
// when to propagate LM_CHANGE (New State <> Previous State)
|
// when to propagate LM_CHANGE (New State <> Previous State)
|
||||||
PreviousCheckState := Windows.SendMessage(WinControl.WindowHandle, BM_GETCHECK, 0, 0);
|
LParamFlag := Windows.SendMessage(WinControl.WindowHandle, BM_GETCHECK, 0, 0);
|
||||||
|
// Pass SKIP_LMCHANGE through LParam if previous state is already unchecked
|
||||||
|
if LParamFlag = BST_UNCHECKED then
|
||||||
|
LParamFlag := SKIP_LMCHANGE;
|
||||||
Windows.SendMessage(WinControl.WindowHandle, BM_SETCHECK,
|
Windows.SendMessage(WinControl.WindowHandle, BM_SETCHECK,
|
||||||
Windows.WParam(BST_UNCHECKED), Windows.LParam(PreviousCheckState));
|
Windows.WParam(BST_UNCHECKED), Windows.LParam(LParamFlag));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1253,9 +1256,9 @@ begin
|
|||||||
Flags := BST_INDETERMINATE
|
Flags := BST_INDETERMINATE
|
||||||
else
|
else
|
||||||
Flags := BST_CHECKED;
|
Flags := BST_CHECKED;
|
||||||
//pass a different values in WParam and WParam to force sending LM_CHANGE
|
//pass 0 through LParam to force sending LM_CHANGE
|
||||||
Windows.SendMessage(lWinControl.Handle, BM_SETCHECK,
|
Windows.SendMessage(lWinControl.Handle, BM_SETCHECK,
|
||||||
Windows.WPARAM(Flags), Windows.LPARAM(Flags + 1));
|
Windows.WPARAM(Flags), 0);
|
||||||
end;
|
end;
|
||||||
LMessage.Msg := LM_CLICKED;
|
LMessage.Msg := LM_CLICKED;
|
||||||
end;
|
end;
|
||||||
@ -2340,9 +2343,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
BM_SETCHECK:
|
BM_SETCHECK:
|
||||||
begin
|
begin
|
||||||
//LParam holds previous state
|
//LParam holds BST_CHECKED, BST_UNCHECKED or SKIP_LMCHANGE;
|
||||||
//Propagate LM_CHANGED when state is changed
|
if LParam <> SKIP_LMCHANGE then
|
||||||
if LParam <> WParam then
|
|
||||||
LMessage.Msg := LM_CHANGED;
|
LMessage.Msg := LM_CHANGED;
|
||||||
if lWinControl is TRadioButton then
|
if lWinControl is TRadioButton then
|
||||||
begin
|
begin
|
||||||
|
@ -87,6 +87,8 @@ const
|
|||||||
IDC_SIZENWSE, IDC_SIZENS, IDC_SIZENESW, IDC_SIZE, IDC_IBEAM, IDC_CROSS,
|
IDC_SIZENWSE, IDC_SIZENS, IDC_SIZENESW, IDC_SIZE, IDC_IBEAM, IDC_CROSS,
|
||||||
IDC_ARROW, IDC_ARROW, IDC_ARROW);
|
IDC_ARROW, IDC_ARROW, IDC_ARROW);
|
||||||
|
|
||||||
|
//flag used to avoid propagating LM_CHANGE for TCustomCheckBox
|
||||||
|
SKIP_LMCHANGE = 1000;
|
||||||
|
|
||||||
type
|
type
|
||||||
PInitCommonControlsEx = ^TInitCommonControlsEx;
|
PInitCommonControlsEx = ^TInitCommonControlsEx;
|
||||||
|
@ -1613,8 +1613,8 @@ begin
|
|||||||
else
|
else
|
||||||
Flags := Windows.WParam(BST_INDETERMINATE);
|
Flags := Windows.WParam(BST_INDETERMINATE);
|
||||||
end;
|
end;
|
||||||
//Pass the same state through lParam to avoid the OnChange event be fired
|
//Pass SKIP_LMCHANGE through lParam to avoid the OnChange event be fired
|
||||||
Windows.SendMessage(ACustomCheckBox.Handle, BM_SETCHECK, Flags, LPARAM(Flags));
|
Windows.SendMessage(ACustomCheckBox.Handle, BM_SETCHECK, Flags, SKIP_LMCHANGE);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TWin32WSToggleBox }
|
{ TWin32WSToggleBox }
|
||||||
|
Loading…
Reference in New Issue
Block a user