diff --git a/lcl/include/customcombobox.inc b/lcl/include/customcombobox.inc index f254dcd00f..552136754c 100644 --- a/lcl/include/customcombobox.inc +++ b/lcl/include/customcombobox.inc @@ -576,7 +576,17 @@ end; ------------------------------------------------------------------------------} function TCustomComboBox.GetItemHeight: Integer; begin - Result:=FItemHeight; + // FItemHeight is not initialized at class creating. we can, but with what value? + // so, if it still uninitialized (=0), then we ask widgetset + if (FStyle in [csOwnerDrawFixed, csOwnerDrawVariable]) and (FItemHeight > 0) then + begin + Result := FItemHeight + end else + begin + Result := TWSCustomComboBoxClass(WidgetSetClass).GetItemHeight(Self); + if Result <> 0 then + FItemHeight := Result; + end; end; {------------------------------------------------------------------------------ @@ -597,9 +607,12 @@ end; ------------------------------------------------------------------------------} procedure TCustomComboBox.SetItemHeight(const AValue: Integer); begin - if AValue=FItemHeight then exit; - FItemHeight:=AValue; - // ToDo + if AValue = FItemHeight then + exit; + + FItemHeight := AValue; + if Style in [csOwnerDrawFixed, csOwnerDrawVariable] then + TWSCustomComboBoxClass(WidgetSetClass).SetItemHeight(Self, FItemHeight); end; {------------------------------------------------------------------------------ @@ -904,20 +917,23 @@ procedure TCustomComboBox.LMMeasureItem(var TheMessage: TLMMeasureItem); var AHeight: Integer; begin - with TheMessage.MeasureItemStruct^ do begin + with TheMessage.MeasureItemStruct^ do + begin if Self.ItemHeight <> 0 then AHeight := Self.ItemHeight else - Aheight := ItemHeight; - MeasureItem(Integer(ItemId), AHeight); - if AHeight>0 then + AHeight := ItemHeight; + if FStyle = csOwnerDrawVariable then + MeasureItem(ItemId, AHeight); + if AHeight > 0 then ItemHeight := AHeight; end; end; procedure TCustomComboBox.LMSelChange(var TheMessage); begin - if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit; + if [csLoading, csDestroying, csDesigning] * ComponentState <> [] then + exit; Select; end; diff --git a/lcl/interfaces/win32/interfaces.pp b/lcl/interfaces/win32/interfaces.pp index 9bd39eb4a0..b8930e106c 100644 --- a/lcl/interfaces/win32/interfaces.pp +++ b/lcl/interfaces/win32/interfaces.pp @@ -6,7 +6,7 @@ Initial Revision : Thu July 1st CST 1999 - ***************************************************************************/ + ******************** *******************************************************/ ***************************************************************************** * * @@ -42,4 +42,4 @@ initialization finalization FreeWidgetSet; -end. \ No newline at end of file +end. diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index 5cf513296e..e99322fe1f 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -99,6 +99,9 @@ type class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; override; class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); override; + + class function GetItemHeight(const ACustomComboBox: TCustomComboBox): Integer; override; + class procedure SetItemHeight(const ACustomComboBox: TCustomComboBox; const AItemHeight: Integer); override; end; { TWin32WSComboBox } @@ -774,6 +777,18 @@ begin TWin32ListStringList(AList).Sorted := IsSorted; end; +class function TWin32WSCustomComboBox.GetItemHeight(const ACustomComboBox: TCustomComboBox): Integer; +begin + Result := SendMessage(ACustomComboBox.Handle, CB_GETITEMHEIGHT, 0, 0); +end; + +class procedure TWin32WSCustomComboBox.SetItemHeight(const ACustomComboBox: TCustomComboBox; const AItemHeight: Integer); +begin + // size requests are done through WM_MeasureItem + // SendMessage(ACustomComboBox.Handle, CB_SETITEMHEIGHT, AItemHeight, -1); + // SendMessage(ACustomComboBox.Handle, CB_SETITEMHEIGHT, AItemHeight, 0); + RecreateWnd(ACustomComboBox); +end; { TWin32WSCustomEdit helper functions } function EditGetSelStart(WinHandle: HWND): integer; diff --git a/lcl/stdctrls.pp b/lcl/stdctrls.pp index a1be784fbc..f688edd2c0 100644 --- a/lcl/stdctrls.pp +++ b/lcl/stdctrls.pp @@ -413,6 +413,7 @@ type property OnKeyDown; property OnKeyPress; property OnKeyUp; + property OnMeasureItem; property OnMouseDown; property OnMouseMove; property OnMouseUp; @@ -1374,3 +1375,4 @@ initialization end. + diff --git a/lcl/widgetset/wsstdctrls.pp b/lcl/widgetset/wsstdctrls.pp index b007e1c7d2..90b48e9e96 100644 --- a/lcl/widgetset/wsstdctrls.pp +++ b/lcl/widgetset/wsstdctrls.pp @@ -85,6 +85,9 @@ type class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; virtual; class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); virtual; + + class function GetItemHeight(const ACustomComboBox: TCustomComboBox): Integer; virtual; + class procedure SetItemHeight(const ACustomComboBox: TCustomComboBox; const AItemHeight: Integer); virtual; end; TWSCustomComboBoxClass = class of TWSCustomComboBox; @@ -335,6 +338,15 @@ class procedure TWSCustomComboBox.Sort(const ACustomComboBox: TCustomComboBox; begin end; +class function TWSCustomComboBox.GetItemHeight(const ACustomComboBox: TCustomComboBox): Integer; +begin + Result := 0; +end; + +class procedure TWSCustomComboBox.SetItemHeight(const ACustomComboBox: TCustomComboBox; const AItemHeight: Integer); +begin +end; + { TWSCustomEdit } class function TWSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;