View Issue Details

IDProjectCategoryView StatusLast Update
0029149LazarusLCLpublic2015-12-31 12:44
ReporterSimon AmeisAssigned ToOndrej Pokorny 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformOSWindowsOS Version
Product Version1.4.4Product Build 
Target Version1.6Fixed in Version1.7 (SVN) 
Summary0029149: TCustomComboBox: Support Windows Message CB_SETDROPPEDWIDTH
DescriptionCurrently 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 InformationThe 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>
TagsTComboBox
Fixed in Revision51094
LazTarget1.6
WidgetsetWin32/Win64
Attached Files
  • TCustomComboBox.patch (1,080 bytes)
    Index: lcl/include/customcombobox.inc
    ===================================================================
    --- lcl/include/customcombobox.inc	(revision 51031)
    +++ lcl/include/customcombobox.inc	(working copy)
    @@ -250,7 +250,7 @@
     var
       Count, MinItemsWidth, MinItemsHeight: Integer;
     begin
    -  if (not HandleAllocated) or (not DroppedDown) then exit;
    +  if (not HandleAllocated) then exit;
       Count := Items.Count;
       if Count > DropDownCount then Count := DropDownCount;
       if Count < 1 then Count := 1;
    Index: lcl/interfaces/win32/win32winapi.inc
    ===================================================================
    --- lcl/interfaces/win32/win32winapi.inc	(revision 51035)
    +++ lcl/interfaces/win32/win32winapi.inc	(working copy)
    @@ -2982,6 +2982,7 @@
     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;
     
     {------------------------------------------------------------------------------
    
    TCustomComboBox.patch (1,080 bytes)

Activities

Ondrej Pokorny

2015-12-16 08:32

reporter   ~0087986

Could you please send a patch file?

Janusz Tomczak

2015-12-25 23:26

reporter  

TCustomComboBox.patch (1,080 bytes)
Index: lcl/include/customcombobox.inc
===================================================================
--- lcl/include/customcombobox.inc	(revision 51031)
+++ lcl/include/customcombobox.inc	(working copy)
@@ -250,7 +250,7 @@
 var
   Count, MinItemsWidth, MinItemsHeight: Integer;
 begin
-  if (not HandleAllocated) or (not DroppedDown) then exit;
+  if (not HandleAllocated) then exit;
   Count := Items.Count;
   if Count > DropDownCount then Count := DropDownCount;
   if Count < 1 then Count := 1;
Index: lcl/interfaces/win32/win32winapi.inc
===================================================================
--- lcl/interfaces/win32/win32winapi.inc	(revision 51035)
+++ lcl/interfaces/win32/win32winapi.inc	(working copy)
@@ -2982,6 +2982,7 @@
 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;
 
 {------------------------------------------------------------------------------
TCustomComboBox.patch (1,080 bytes)

Ondrej Pokorny

2015-12-31 11:07

reporter   ~0088455

Applied, thanks! (Sorry I missed the patch first.)

Issue History

Date Modified Username Field Change
2015-12-08 09:48 Simon Ameis New Issue
2015-12-08 09:49 Simon Ameis Tag Attached: TComboBox
2015-12-16 08:32 Ondrej Pokorny Note Added: 0087986
2015-12-16 08:32 Ondrej Pokorny Assigned To => Ondrej Pokorny
2015-12-16 08:32 Ondrej Pokorny Status new => assigned
2015-12-25 12:20 Ondrej Pokorny LazTarget => -
2015-12-25 12:20 Ondrej Pokorny Status assigned => feedback
2015-12-25 23:26 Janusz Tomczak File Added: TCustomComboBox.patch
2015-12-31 11:07 Ondrej Pokorny Fixed in Revision => 51094
2015-12-31 11:07 Ondrej Pokorny LazTarget - => 1.6
2015-12-31 11:07 Ondrej Pokorny Note Added: 0088455
2015-12-31 11:07 Ondrej Pokorny Status feedback => resolved
2015-12-31 11:07 Ondrej Pokorny Fixed in Version => 1.7 (SVN)
2015-12-31 11:07 Ondrej Pokorny Resolution open => fixed
2015-12-31 11:07 Ondrej Pokorny Target Version => 1.6