diff --git a/lcl/interfaces/wince/wincecallback.inc b/lcl/interfaces/wince/wincecallback.inc index 01283caf77..395e8b0066 100644 --- a/lcl/interfaces/wince/wincecallback.inc +++ b/lcl/interfaces/wince/wincecallback.inc @@ -546,7 +546,7 @@ Var Parent: TWinControl; Sibling: TControl; WinControl: TWinControlAccess absolute Sibling; - PreviousCheckState: LRESULT; + LParamFlag: LRESULT; i: Integer; begin Parent := RadioButton.Parent; @@ -557,9 +557,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; @@ -1176,9 +1179,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; @@ -2100,9 +2103,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 diff --git a/lcl/interfaces/wince/winceint.pp b/lcl/interfaces/wince/winceint.pp index d0e7e88b36..42521cca31 100644 --- a/lcl/interfaces/wince/winceint.pp +++ b/lcl/interfaces/wince/winceint.pp @@ -106,6 +106,9 @@ const WM_LCL_SOCK_ASYNC = WM_USER; + //flag used to avoid propagating LM_CHANGE for TCustomCheckBox + SKIP_LMCHANGE = 1000; + type { Policy for using the "OK" close button in the title instead of diff --git a/lcl/interfaces/wince/wincewsstdctrls.pp b/lcl/interfaces/wince/wincewsstdctrls.pp index ded7c5d2a1..50c9ef378d 100644 --- a/lcl/interfaces/wince/wincewsstdctrls.pp +++ b/lcl/interfaces/wince/wincewsstdctrls.pp @@ -1330,8 +1330,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; { TWinCEWSToggleBox }