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; 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

View File

@ -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;

View File

@ -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 }