- 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; function TCustomComboBox.GetItemHeight: Integer;
begin 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; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -597,9 +607,12 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomComboBox.SetItemHeight(const AValue: Integer); procedure TCustomComboBox.SetItemHeight(const AValue: Integer);
begin begin
if AValue=FItemHeight then exit; if AValue = FItemHeight then
FItemHeight:=AValue; exit;
// ToDo
FItemHeight := AValue;
if Style in [csOwnerDrawFixed, csOwnerDrawVariable] then
TWSCustomComboBoxClass(WidgetSetClass).SetItemHeight(Self, FItemHeight);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -904,20 +917,23 @@ procedure TCustomComboBox.LMMeasureItem(var TheMessage: TLMMeasureItem);
var var
AHeight: Integer; AHeight: Integer;
begin begin
with TheMessage.MeasureItemStruct^ do begin with TheMessage.MeasureItemStruct^ do
begin
if Self.ItemHeight <> 0 then if Self.ItemHeight <> 0 then
AHeight := Self.ItemHeight AHeight := Self.ItemHeight
else else
Aheight := ItemHeight; AHeight := ItemHeight;
MeasureItem(Integer(ItemId), AHeight); if FStyle = csOwnerDrawVariable then
if AHeight>0 then MeasureItem(ItemId, AHeight);
if AHeight > 0 then
ItemHeight := AHeight; ItemHeight := AHeight;
end; end;
end; end;
procedure TCustomComboBox.LMSelChange(var TheMessage); procedure TCustomComboBox.LMSelChange(var TheMessage);
begin begin
if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit; if [csLoading, csDestroying, csDesigning] * ComponentState <> [] then
exit;
Select; Select;
end; end;

View File

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

View File

@ -99,6 +99,9 @@ type
class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; override; class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; override;
class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); 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; end;
{ TWin32WSComboBox } { TWin32WSComboBox }
@ -774,6 +777,18 @@ begin
TWin32ListStringList(AList).Sorted := IsSorted; TWin32ListStringList(AList).Sorted := IsSorted;
end; 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 } { TWin32WSCustomEdit helper functions }
function EditGetSelStart(WinHandle: HWND): integer; function EditGetSelStart(WinHandle: HWND): integer;

View File

@ -413,6 +413,7 @@ type
property OnKeyDown; property OnKeyDown;
property OnKeyPress; property OnKeyPress;
property OnKeyUp; property OnKeyUp;
property OnMeasureItem;
property OnMouseDown; property OnMouseDown;
property OnMouseMove; property OnMouseMove;
property OnMouseUp; property OnMouseUp;
@ -1374,3 +1375,4 @@ initialization
end. end.

View File

@ -85,6 +85,9 @@ type
class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; virtual; class function GetItems(const ACustomComboBox: TCustomComboBox): TStrings; virtual;
class procedure Sort(const ACustomComboBox: TCustomComboBox; AList: TStrings; IsSorted: boolean); 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; end;
TWSCustomComboBoxClass = class of TWSCustomComboBox; TWSCustomComboBoxClass = class of TWSCustomComboBox;
@ -335,6 +338,15 @@ class procedure TWSCustomComboBox.Sort(const ACustomComboBox: TCustomComboBox;
begin begin
end; 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 } { TWSCustomEdit }
class function TWSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer; class function TWSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;