- request combobox item heights through onMeasureItem when style is ownerdraw variable + misc bugs with ItemHeight (report 0008113)

git-svn-id: trunk@11070 -
This commit is contained in:
paul 2007-05-04 01:26:23 +00:00
parent 1e323b22a7
commit f83756a0d3
5 changed files with 56 additions and 11 deletions

View File

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

View File

@ -6,7 +6,7 @@
Initial Revision : Thu July 1st CST 1999
***************************************************************************/
******************** *******************************************************/
*****************************************************************************
* *
@ -42,4 +42,4 @@ initialization
finalization
FreeWidgetSet;
end.
end.

View File

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

View File

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

View File

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