TCustomComboBox: Support Windows Message CB_SETDROPPEDWIDTH
Original Reporter info from Mantis: Simon Ameis @SAmeis
-
Reporter name: Simon Ameis
Original Reporter info from Mantis: Simon Ameis @SAmeis
- Reporter name: Simon Ameis
Description:
Currently the property TCustomComboBox.ItemWidth is ignored on Windows. This may be changed by sending a CB_SETDROPPEDWIDTH message to the combobox's handle.
https://msdn.microsoft.com/en-us/library/windows/desktop/bb775901%28v=vs.85%29.aspx
Additional information:
The correct place where to put this SendMessage could be TWin32WidgetSet.SetComboMinDropDownSize() which may be changed to
<code>function TWin32WidgetSet.SetComboMinDropDownSize(Handle: HWND; MinItemsWidth,
MinItemsHeight, MinItemCount: integer): boolean;
begin
Result:= ThemeServices.ThemesEnabled and
boolean(Windows.SendMessage(Handle, CB_SETMINVISIBLE, MinItemCount, 0));
Result := Result and boolean(Windows.SendMessage(Handle, CB_SETDROPPEDWIDTH, MinItemsWidth, 0));
end;</code>
But this method is never called during application startup; this may be an error in TCustomComboBox.AdjustDropDown:
<code>procedure TCustomComboBox.AdjustDropDown;
var
Count, MinItemsWidth, MinItemsHeight: Integer;
begin
if (not HandleAllocated) or (not DroppedDown) then exit;
Count := Items.Count;
if Count > DropDownCount then Count := DropDownCount;
if Count < 1 then Count := 1;
MinItemsWidth := ItemWidth;
MinItemsHeight := Count * ItemHeight;
SetComboMinDropDownSize(Handle, MinItemsWidth, MinItemsHeight, Count);
end;</code>
may need to be changed to
<code>procedure TCustomComboBox.AdjustDropDown;
var
Count, MinItemsWidth, MinItemsHeight: Integer;
begin
if (not HandleAllocated) then exit;
Count := Items.Count;
if Count > DropDownCount then Count := DropDownCount;
if Count < 1 then Count := 1;
MinItemsWidth := ItemWidth;
MinItemsHeight := Count * ItemHeight;
SetComboMinDropDownSize(Handle, MinItemsWidth, MinItemsHeight, Count);
end;</code>
Mantis conversion info:
- Mantis ID: 29149
- OS: Windows
- Version: 1.4.4
- Fixed in version: 1.7 (SVN)
- Fixed in revision: 51094 (#9effa4e6)
- Target version: 1.6