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:
blikblum 2010-09-16 14:08:01 +00:00
parent f42d3f84d8
commit 0d632cce9c
3 changed files with 14 additions and 10 deletions

View File

@ -560,7 +560,7 @@ var
Parent: TWinControl;
Sibling: TControl;
WinControl: TWinControlAccess absolute Sibling;
PreviousCheckState: LRESULT;
LParamFlag: LRESULT;
i: Integer;
begin
Parent := RadioButton.Parent;
@ -571,9 +571,12 @@ var
begin
// Pass previous state through LParam so the event handling can decide
// 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.WParam(BST_UNCHECKED), Windows.LParam(PreviousCheckState));
Windows.WParam(BST_UNCHECKED), Windows.LParam(LParamFlag));
end;
end;
end;
@ -1253,9 +1256,9 @@ begin
Flags := BST_INDETERMINATE
else
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.WPARAM(Flags), Windows.LPARAM(Flags + 1));
Windows.WPARAM(Flags), 0);
end;
LMessage.Msg := LM_CLICKED;
end;
@ -2340,9 +2343,8 @@ begin
end;
BM_SETCHECK:
begin
//LParam holds previous state
//Propagate LM_CHANGED when state is changed
if LParam <> WParam then
//LParam holds BST_CHECKED, BST_UNCHECKED or SKIP_LMCHANGE;
if LParam <> SKIP_LMCHANGE then
LMessage.Msg := LM_CHANGED;
if lWinControl is TRadioButton then
begin

View File

@ -87,6 +87,8 @@ const
IDC_SIZENWSE, IDC_SIZENS, IDC_SIZENESW, IDC_SIZE, IDC_IBEAM, IDC_CROSS,
IDC_ARROW, IDC_ARROW, IDC_ARROW);
//flag used to avoid propagating LM_CHANGE for TCustomCheckBox
SKIP_LMCHANGE = 1000;
type
PInitCommonControlsEx = ^TInitCommonControlsEx;

View File

@ -1613,8 +1613,8 @@ begin
else
Flags := Windows.WParam(BST_INDETERMINATE);
end;
//Pass the same state through lParam to avoid the OnChange event be fired
Windows.SendMessage(ACustomCheckBox.Handle, BM_SETCHECK, Flags, LPARAM(Flags));
//Pass SKIP_LMCHANGE through lParam to avoid the OnChange event be fired
Windows.SendMessage(ACustomCheckBox.Handle, BM_SETCHECK, Flags, SKIP_LMCHANGE);
end;
{ TWin32WSToggleBox }