win32 interfaces: implemented changing ComboBox.DropDownCount after window creation (bug #11294)

git-svn-id: trunk@15129 -
This commit is contained in:
vincents 2008-05-14 07:11:16 +00:00
parent 791e885180
commit 4a64a58cce
3 changed files with 32 additions and 8 deletions

View File

@ -366,6 +366,12 @@ begin
inherited Assign(Source);
end;
procedure TWin32ComboBoxStringList.SetDropDownCount(const AValue: integer);
begin
FDropDownCount:=AValue;
UpdateComboHeight;
end;
function TWin32ComboBoxStringList.GetComboHeight: integer;
begin
if (FSender is TCustomComboBox) and (TCustomComboBox(FSender).Style = csSimple) then

View File

@ -82,6 +82,7 @@ Type
FEditHeight: Integer;
FItemHeight: Integer;
FDropDownCount: Integer;
procedure SetDropDownCount(const AValue: integer);
protected
function GetComboHeight: integer;
procedure InitFlags; override;
@ -93,6 +94,7 @@ Type
procedure Insert(Index: integer; const S: string); override;
property ComboHeight: integer read GetComboHeight;
property DropDownCount: integer read FDropDownCount write SetDropDownCount;
end;
PWin32CheckListBoxItemRecord = ^TWin32CheckListBoxItemRecord;

View File

@ -79,6 +79,7 @@ type
TWin32WSCustomComboBox = class(TWSCustomComboBox)
private
class function GetStringList(const ACustomComboBox: TCustomComboBox): TWin32ComboBoxStringList;
protected
public
class function CreateHandle(const AWinControl: TWinControl;
@ -95,6 +96,7 @@ type
class procedure SetArrowKeysTraverseList(const ACustomComboBox: TCustomComboBox;
NewTraverseList: boolean); override;
class procedure SetDropDownCount(const ACustomComboBox: TCustomComboBox; NewCount: Integer); override;
class procedure SetSelStart(const ACustomComboBox: TCustomComboBox; NewStart: integer); override;
class procedure SetSelLength(const ACustomComboBox: TCustomComboBox; NewLength: integer); override;
class procedure SetItemIndex(const ACustomComboBox: TCustomComboBox; NewIndex: integer); override;
@ -753,6 +755,14 @@ begin
Result := Result or ComboBoxReadOnlyStyles[AComboBox.ReadOnly];
end;
class function TWin32WSCustomComboBox.GetStringList(
const ACustomComboBox: TCustomComboBox): TWin32ComboBoxStringList;
begin
Result := nil;
if ACustomComboBox.Style <> csSimple then
Result := TWin32ComboBoxStringList(GetWindowInfo(ACustomComboBox.Handle)^.List);
end;
class function TWin32WSCustomComboBox.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
@ -805,16 +815,11 @@ end;
class procedure TWin32WSCustomComboBox.AdaptBounds(const AWinControl: TWinControl;
var Left, Top, Width, Height: integer; var SuppressMove: boolean);
var
WinHandle: HWND;
StringList: TWin32ComboBoxStringList;
begin
WinHandle := AWinControl.Handle;
if TCustomComboBox(AWinControl).Style <> csSimple then
begin
StringList := TWin32ComboBoxStringList(GetWindowInfo(WinHandle)^.List);
if StringList <> nil then
Height := StringList.ComboHeight;
end;
StringList := GetStringList(TCustomComboBox(AWinControl));
if StringList <> nil then
Height := StringList.ComboHeight;
end;
class procedure TWin32WSCustomComboBox.GetPreferredSize(
@ -881,6 +886,17 @@ begin
// TODO: implement me?
end;
class procedure TWin32WSCustomComboBox.SetDropDownCount(
const ACustomComboBox: TCustomComboBox; NewCount: Integer);
var
WinHandle: HWND;
StringList: TWin32ComboBoxStringList;
begin
StringList := GetStringList(ACustomComboBox);
if StringList <> nil then
StringList.DropDownCount := NewCount;
end;
class procedure TWin32WSCustomComboBox.SetSelStart(const ACustomComboBox: TCustomComboBox; NewStart: integer);
begin
SendMessage(ACustomComboBox.Handle, CB_SETEDITSEL, 0, MakeLParam(NewStart, NewStart));