Recent

Author Topic: How to size a csSimple ComboBox at design time.?  (Read 6641 times)

jamie

  • Hero Member
  • *****
  • Posts: 6090
How to size a csSimple ComboBox at design time.?
« on: May 21, 2020, 08:41:20 pm »

 Recently working with the CustomCombo box I have experience some issues with sizing the box on the form while the style := csSimple in designer state (IDE editing)

  At first I thought it was me with the code I was doing which is inherited from a CustomCombobox but then the designer started allowing it to be sizeable on the form for no apparent reason.

 As some may not know with csSimple, its a fixed drop down so you need to size the drop down by dragging it with the gripping square at design time or runtime..

 I tried with the latest release 2.0.8 and it does not work there either.

 This seems to be random because it will work depending on what the day of the week is or if its rainy outside, at least that is what it appears...

Drop a Tcombobox on the form,. set the style := csSimple, put some items in it, and then tried to size the height of it to force the dropdown to show via mouse operation.

 Can someone shed some light on the subject ?

The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: How to size a csSimple ComboBox at design time.?
« Reply #1 on: May 21, 2020, 10:08:14 pm »
I think you are misunderstanding the csSimple combobox style. csSimple results only in an edit box where you can type some text. There is no dropdown at all. The items exist only in the background, and you can use the UP/DOWN arrow key to navigate through the items and bring the currently selected item into the edit box. By no means you can increase the height of the edit box to show the dropdown as if it were a Listbox.

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to size a csSimple ComboBox at design time.?
« Reply #2 on: May 21, 2020, 10:24:55 pm »
absolutely not true..

it is suppose to drag down and show the list box as a static box at design time.

It has worked randomly and it works at run time .. There is a problem at design time and its random.

Please populate the list and at run time change the height and you will see that it shows a static list box that you can travers on or even select from...

 My old Delphi behaves correctly ., it Sizes the box at design time and shows it as sized at runtime. it works as documented.

  It did work one day while I was working on some code, the IDE sized it with no issues, today I can not get it to work.

 I have tried with 3 different versions of Lazarus including the current release version and today they refuse to size. The other day they worked correctly.


 In Delphi 10. it sizes on the form while  you work on it but it shows an issue at runtime so I am not counting that for the time being..


https://docs.microsoft.com/en-us/windows/win32/controls/about-combo-boxes
« Last Edit: May 21, 2020, 10:27:43 pm by jamie »
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: How to size a csSimple ComboBox at design time.?
« Reply #3 on: May 21, 2020, 11:17:35 pm »
OK, I've never seen it like that, but I tried with Delphi and it works like you describe. Why don't you combine a TEdit and a TListbox?

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to size a csSimple ComboBox at design time.?
« Reply #4 on: May 22, 2020, 01:45:23 am »
over fixing it?

 I am trying to correct an already failed component that inherits from the Tcombobox and one of the active modes is the csSimple..

 I file a bug report because this is an error and it does work sometimes in the designer, there is something strange happening..
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to size a csSimple ComboBox at design time.?
« Reply #5 on: May 22, 2020, 03:51:45 am »
While playing with this, dropping the list at runtime I've also found another issue, the size of the window is longer than the actual list at times, depending of the overall size of the window.
 For example I have 4 items in the list, I need to set the height of the ComboBox to 87 so that the list will be fully viewed without any scrollbar.

 If the drop down is not at the correct multiple value the window for the control is actually taller than the list.. so what happens is if you size your form to cover this control then enlarge the form to make it show there is a black band at the bottom of the list because it belongs to the Combobo but never gets painted.
   
  If you implement the OnMouseDown event and place a test beep in there, you can click on this black band and it receives messages. so it is part of the combobox but the list it self is not fully covering it.

 I've also seen this with the other styles of the combobox, the list has a background more than the list itself.. it causes exclusions on the parent control.

 Just drop a combo on the form, set it to csSimple, and place a button on the form so that you can size the box tall at runtime, you'll see the box listed .. Now shrink the form to cover the list box and then expand the form to reshow the list box. You should now see the blank band at the bottom of the list box...

 Experimenting with the Height property I can find the correct multiple that fixes it. but I should not need to do this and since this is also effecting the other styles of combobox I think this issue needs to be addressed.


The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to size a csSimple ComboBox at design time.?
« Reply #6 on: May 22, 2020, 02:15:13 pm »
I am telling you guys, this issue with the abilitiy of dragging the CSSimple box open on the form is on a timer, date or there is some junk variable flooding around in the environment
dealing with the this control

 Because this morning I start Lazarus, grab the grippers on the csSimple combo box and it works, I can now size it from the Designer..

  you tell me? uninitialized variables or what ?
 
  Today its a good day outside so it can't be rainy weather so maybe it's Friday for me and that is the day it works... Who knows, it behaves like its on a schedule, its own and not mine..!

The only true wisdom is knowing you know nothing

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: How to size a csSimple ComboBox at design time.?
« Reply #7 on: May 22, 2020, 03:40:10 pm »
Hi!

Works only if

Odd(DayOfTheWeek(now)) = true

Winni

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to size a csSimple ComboBox at design time.?
« Reply #8 on: May 22, 2020, 04:20:19 pm »
LOL, really...

I started laz on one of my other PC's and that one still fails to control the size of the csSimple at design time so I can discount dates   :o

 I guess its time to file a report because also the issue with what appears to be a parent window hosting the OS combo box which is taller than the OS combobox, and this is allowing GUI space on the screen that does not get painted after you cover it up and reshow it.
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to size a csSimple ComboBox at design time.?
« Reply #9 on: May 23, 2020, 04:16:52 pm »
I was able to get the csSimple to work without the unpainted garbage at the bottom of the list but it appears the be OS specific..

  Windows at some point is putting the list into "Integral-Size" mode, meaning it will not partially show an item at the end if the user has the list box not set at the correct multiple size.

 To fix this issue I added CBS_NOINTEGRALHEIGHT to the Style property as I override the CreateParms method to do so..
 
  I haven't done  this generally to the over all Combobox code but just to the TComboBoxEx for csSimple mode and it works. It paints correctly and I am sure when I recompile the IDE it will also size in the IDE..

 btw, Today is Friday, I started Lazarus, and guess what? I can't size the csSimple combobox in the IDE..

 I guess I can add this find to the Bug report at the Bug reporting center  >:(
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: How to size a csSimple ComboBox at design time.?
« Reply #10 on: May 23, 2020, 05:42:42 pm »
BTW, is AutoSize turned off on every mysterious day?

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to size a csSimple ComboBox at design time.?
« Reply #11 on: May 23, 2020, 06:28:25 pm »
LOL, I've tried all of that .. its dicey. It works when it wants to and when it does it will work until I reload Lazarus..

 There has to been sloppy variable in there for that case..

 I recompiled the IDE with the changes I made to the TComboEx just to see if the sizing was corrected but it is not. Although the TcomboboxEx works with no garbage at the bottom I still can not size it in the designer.. 

 I need to look deeper to see why that is taking place.

 as for the CBS_NOINTREGALHEIGHT options, I think that is best setting that only for csSimple mode comboboxes.. otherwise it will effect the dropdown listings too.


EDIT:

 I just tried the sizing again and now all my test combo's in csSimple are sizing...

 there is some scrap variable running around.

« Last Edit: May 23, 2020, 06:31:33 pm by jamie »
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to size a csSimple ComboBox at design time.?
« Reply #12 on: May 23, 2020, 06:51:26 pm »
I figured out the sizing issue.. it is a problem in the IDE designer and I can make It work ..

Create a simple app.

 Drop a Tcombobox on it...

 Set the Style to csSimple

 you won't be able to size it at this time.

 Save the project and close it..

 Reload the project. the Style settings is still csSimple, don't change it..

 Now you can resize it.

 This has something to do with getting the properties read in at load time but at design time its being rejected..


 
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to size a csSimple ComboBox at design time.?
« Reply #13 on: May 24, 2020, 01:05:37 am »
I come up with a proper fix for the unpainted areas for the csSimple combobox.. I have it so it's only acting on a csSimple…

For now, Open your "CustomComboBox.inc" file in the Lazarus source files at the "CreateParams" method add this at the bottom..
Code: Pascal  [Select][+][-]
  1. {$IFDEF Windows}
  2.   if (Params.Style and CBS_SIMPLE)<>0 Then Include(FWinControlFlags, wcfEraseBackground) Else
  3.    Exclude(FWinControlFlags, wcfEraseBackground);
  4.  {$IFEND}                                            
  5.  

Compile, this will rebuild your LCL files...
you can experiment on a test form..
if you like it you can then rebuild your IDE... ;)

The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to size a csSimple ComboBox at design time.?
« Reply #14 on: May 24, 2020, 03:07:58 am »
had to add a little to that last one, it seems windows does not properly draw its highlighted box around it, it maybe its in the LCL and I haven't yet found that ?
but in any case, this code will fix that for the time being..
Code: Pascal  [Select][+][-]
  1.  {$IFDEF Windows}
  2.   if (Params.Style and CBS_SIMPLE)<>0 Then
  3.    Begin
  4.     Include(FWinControlFlags, wcfEraseBackground);
  5.     Params.Style:= Params.Style or $400; //CBS_NOINTEGRALHEIGHT
  6.    End
  7.   Else
  8.    Exclude(FWinControlFlags, wcfEraseBackground);
  9.  {$IFEND}                                              
  10.  
Put that in the CustomComBoBox.CreateParams…. in the CustomCombobox.inc file..
place it at the bottom.

 Of course If you want broken down csSimple combo boxes you can keep it as is ;)
« Last Edit: May 24, 2020, 04:01:51 am by jamie »
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018