diff --git a/lcl/include/customlistbox.inc b/lcl/include/customlistbox.inc index 4f16c8009c..e657e6b144 100644 --- a/lcl/include/customlistbox.inc +++ b/lcl/include/customlistbox.inc @@ -33,14 +33,22 @@ procedure TCustomListBox.AssignCacheToItemData(const AIndex: Integer; const AData: Pointer); begin if PCustomListBoxItemRecord(AData)^.Selected or (FItemIndex = AIndex) then + begin + LockSelectionChange; SendItemSelected(AIndex, True); + UnlockSelectionChange; + end; end; procedure TCustomListBox.Loaded; begin inherited Loaded; if HandleAllocated then + begin + LockSelectionChange; SendItemIndex; + UnlockSelectionChange; + end; end; {------------------------------------------------------------------------------ @@ -202,10 +210,7 @@ begin end; end; -{------------------------------------------------------------------------------ - procedure TCustomListBox.LMSelChange(var TheMessage); -------------------------------------------------------------------------------} -procedure TCustomListBox.LMSelChange(var TheMessage); +procedure TCustomListBox.IntfSelectionChanged; begin if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit; //debugln('TCustomListBox.LMSelChange ',Name,':',ClassName,' ItemIndex=',dbgs(ItemIndex),' FLockSelectionChange=',dbgs(FLockSelectionChange)); @@ -214,6 +219,14 @@ begin DoSelectionChange(FLockSelectionChange=0); end; +{------------------------------------------------------------------------------ + procedure TCustomListBox.LMSelChange(var TheMessage); +------------------------------------------------------------------------------} +procedure TCustomListBox.LMSelChange(var TheMessage); +begin + IntfSelectionChanged; +end; + {------------------------------------------------------------------------------ procedure TCustomListBox.SendItemSelected(Index: integer; IsSelected: boolean); @@ -221,11 +234,8 @@ end; ------------------------------------------------------------------------------} procedure TCustomListBox.SendItemSelected(Index: integer; IsSelected: boolean); begin - if HandleAllocated then begin - LockSelectionChange; + if HandleAllocated then TWSCustomListBoxClass(WidgetSetClass).SelectItem(Self, Index, IsSelected); - UnlockSelectionChange; - end; end; {------------------------------------------------------------------------------} @@ -367,13 +377,8 @@ end; procedure TCustomListBox.SendItemIndex; begin - LockSelectionChange; - try - // TODO 64bit - TWSCustomListBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex); - finally - UnlockSelectionChange; - end; + // TODO 64bit + TWSCustomListBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex); end; {------------------------------------------------------------------------------} diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index 8351f4e449..48347c77b3 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -508,6 +508,9 @@ begin Windows.SendMessage(Handle, LB_SETSEL, Windows.WParam(true), Windows.LParam(AIndex)); end else Windows.SendMessage(Handle, LB_SETCURSEL, Windows.WParam(AIndex), 0); + + // windows does not send selection changed notify message + ACustomListBox.IntfSelectionChanged; end; procedure TWin32WSCustomListBox.SetSelectionMode(const ACustomListBox: TCustomListBox; diff --git a/lcl/stdctrls.pp b/lcl/stdctrls.pp index e8ddd70f35..d4bbbb40ed 100644 --- a/lcl/stdctrls.pp +++ b/lcl/stdctrls.pp @@ -450,6 +450,10 @@ type procedure Clear; virtual; procedure LockSelectionChange; procedure UnlockSelectionChange; + public + { to be called by widgetset backend } + // equivalent of LM_SELCHANGED + procedure IntfSelectionChanged; virtual; public property Align; property Anchors; @@ -1252,6 +1256,10 @@ end. { ============================================================================= $Log$ + Revision 1.204 2005/05/06 09:39:49 micha + introduce intfselectionchanged procedure for widgetsets that do not send LM_SELCHANGED automatically + fix senditemindex to cause onclick event + Revision 1.203 2005/05/02 09:17:08 mattias started TButtonActionLink