Lazarus

Programming => LCL => Topic started by: jamie on May 21, 2020, 08:41:20 pm

Title: How to size a csSimple ComboBox at design time.?
Post by: jamie 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 ?

Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp 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.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie 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
 (https://docs.microsoft.com/en-us/windows/win32/controls/about-combo-boxes)
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp 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?
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie 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..
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie 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.


Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie 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..!

Title: Re: How to size a csSimple ComboBox at design time.?
Post by: winni on May 22, 2020, 03:40:10 pm
Hi!

Works only if

Odd(DayOfTheWeek(now)) = true

Winni
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie 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.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie 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  >:(
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 23, 2020, 05:42:42 pm
BTW, is AutoSize turned off on every mysterious day?
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie 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.

Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie 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..


 
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie 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... ;)

Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie 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 ;)
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: J-23 on May 24, 2020, 03:10:43 pm
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 ;)

Maybe it would be worth adding it to the Tracker bug - then over time it would end up in official sources
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 24, 2020, 04:09:47 pm
I tried to setup the snv patching system on my PC before but it ended in a total mess on my side.

I did report that code on the bug tracker but they are too busy putting out fires with the snv version.

I've patched the LCL code in several places and made a folder with all the updates and notes so when and if I down load the latest release I check and merge the fixes I have into it.

 Putting out fires tend to be a hard job when there are too many arsonist and not enough fire fighters to go around. ;)
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 24, 2020, 07:36:40 pm
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.
I think in order to get this accepted in the bug tracker you must put this code into the win32 widgetset, not in TCustomCombobox.CreateParams. The inventors of the LCL provided the widgetset architecture to keep the outermost units free from lots of IFDEFs like this. The TCombobox is implemented in unit StdCtrls, therefore you should  put your code into Win32WSStdCtrls.pp which resides in folder lcl/interfaces/win32 of your Lazarus installation. There is a class function TWin32WSCustomCombobox.CreateHandle which seems to be suitable for you code (I did not try it integrate it, though). Probably the same modification should be make with the corresponding file for the WinCE widgetset (in folder lcl/interfaces/wince).
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 24, 2020, 11:33:41 pm
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.
I think in order to get this accepted in the bug tracker you must put this code into the win32 widgetset, not in TCustomCombobox.CreateParams. The inventors of the LCL provided the widgetset architecture to keep the outermost units free from lots of IFDEFs like this. The TCombobox is implemented in unit StdCtrls, therefore you should  put your code into Win32WSStdCtrls.pp which resides in folder lcl/interfaces/win32 of your Lazarus installation. There is a class function TWin32WSCustomCombobox.CreateHandle which seems to be suitable for you code (I did not try it integrate it, though). Probably the same modification should be make with the corresponding file for the WinCE widgetset (in folder lcl/interfaces/wince).
Ok, I can do that and see what happens...

I think I attempted to do it that way before but it seems no matter what I was doing in that createhandle it appeared to be taking no effect on the final end..
 
 Its like the compile was still linking in the old Object code.

 But I can try again..
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 25, 2020, 12:29:19 am
@WP
 
 I can't get access to the fWinControlFlags in the Win32WSStdCtrls in the CreateHandle..

 but I was able to put the CBS_NOINTEGRALHEIGHT settings there.

 I only put a conditional statement here because I wasn't sure what gk2, qt would do with the CBS-
additions to the Style .. However, all other stuff is in the TWinControl which is the same across the board..
 So maybe I can just take the conditional compile out.

Code: Pascal  [Select][+][-]
  1.   end;
  2.   // create window
  3.  
  4.   If (CBS_SIMPLE and Params.flags)<>0 Then   { <<<< Added jp}
  5.    Params.Flags := Params.Flags or CBS_NOINTEGRALHEIGHT; {<<<< Added}
  6.  
  7.   FinishCreateWindow(AWinControl, Params, False, True);
  8.   Info.cbSize := SizeOf(Info);
  9.   Win32Extra.GetComboBoxInfo(Params.Window, @Info);                
  10.  

I can not get access to the FwincontrolFlags in there.
have any ideas ?
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 25, 2020, 01:10:46 am
Hmm... FWinControlFlags is protected in TWinControl. The WinControl affected is passed as a parameter to CreateHandle. Can you try the usual (ugly) type-cast hack?

Code: Pascal  [Select][+][-]
  1. type
  2.   TWinControlAccess = class(TWinControl);
  3. ...
  4.   Include(TWinControlAccess(AWinControl).FWinControlFlags, wcfEraseBackground);

The other widgetsets will not see any modification here.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 25, 2020, 02:38:36 am
class function TWin32WSCustomComboBox.CreateHandle(const AWinControl: TWinControl;   

Code: Pascal  [Select][+][-]
  1.  end;
  2.   // create window
  3.  
  4.   If (CBS_SIMPLE and Params.flags)<>0 Then   {Added jp csSimple comboboxes don't paint correctly otherwise.}
  5.   begin
  6.    Params.Flags := Params.Flags or CBS_NOINTEGRALHEIGHT;
  7.    Include(TWinControlAccess(AWinControl).FWinControlFlags, wcfEraseBackground);
  8.   end Else
  9.    Exclude(TWinControlAccess(AWinControl).FWinControlFlags, wcfEraseBackground);{Added jp}
  10.  
  11.   FinishCreateWindow(AWinControl, Params, False, True);                                  
  12.  

Done

Apparently there is already a class in there just for that purpose...

its strange you just happen to know about that one ;)

I removed all the added stuff in the CreateParams… its all here now...

now how to submit..

Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 25, 2020, 11:54:56 am
I added your code to the TWin32WSCustomCalendar.CreateHandle function of my local installation, and I see that it mostly solves the drawing issue due to the integral lineheight. However, there are issues left:

- When the bottom edge of the combobox is anchored to the bottom edge of the form the height of the combobox changes with the form. However, the bottom border line of the listbox is painted only for specific heights, in particular when the height is reduced. (see screenshot)

- When the height of the combobox is changed in an OnClick event of a button then it is not sufficient to simply apply a value to Combobox1.Height, it is also required to call Combobox1.Invalidate explicitly. Otherwise the listbox will be painted only partly.

- It is still not possible to see the listbox when the combobox height is changed at designtime (even when AutoSize is false).

Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 25, 2020, 12:42:41 pm
I have seen the bottom edge issue that you have described but only in my Windows 10 PRO, my Home edition of Windows 10 does not show that missing border line..

 I have also had others test it and it varies depending on the OS they are on, for example Win7 seems to work perfectly.

 When testing the height property values between the OS drawing its own list box verses the window that is created in the LCL as the parent window, there is 1 pixel difference in size. It looks like a rounding mismatch. One rounds up while the other trunks it.

 As for the invalidate issue. I'll see if I can do something about that. That is another one that does not happen on all of my WIn10 PC's 

  As for not being able to size the box initially when selecting the csSimple, I have concluded that is a bug in the IDE OI. Unrelated to this issue..

 If you drop a combobox on the form, set the style := csSimple, you can not size it. Save your project, reload the project and now you can size it..
  its being blocked some how because it is accepted if you reload your project with the property preset.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 25, 2020, 01:55:31 pm
I have seen the bottom edge issue that you have described but only in my Windows 10 PRO, my Home edition of Windows 10 does not show that missing border line..
Mysterious: I have Win10 Home, too.

If you drop a combobox on the form, set the style := csSimple, you can not size it. Save your project, reload the project and now you can size it..
Yes indeed. However, it does not resize smoothly, but in steps as if some kind of IntegralHeight would still be active.

BTW, there are three checks agains csSimple in win32wsstdctrls.pp. Are they really required? I have the feeling that the csSimple style was implemented with the understanding that the listbox should not appear (as was my initial opinion).
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 25, 2020, 03:29:21 pm
The designer most likely is causing the steps because its trying to stay with the grid on the form.

and yes I have seen the multiple hits in there blocking the csSimple but I think some of those checks are for the drop down mode.

 Currently the only issue I am seeing is the parent window isn't getting a repaint after changing the size in code land without the Invalidate. This reminds me of the old days where it was common to call invalidate always when changing sizes. but the issue here is it appears to be getting late drawing action because I can move my mouse over it and then it completes the draw.
 
 I am still looking for that ester egg ;)
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 26, 2020, 02:05:40 am
I've been working at this for a while now and finally came up with something...

You can not send a invalidate during any of the comment events that take place while the control is being sized, setup etc....

 Windows blocks a lot of control messages while doing panting and other jobs but I did comeup with the solution...

 I added a message trap in the Message Handler for WM_SIZE, at that point I then issue a InvalidateRect call which then caches up WM_ERASEBKGND and WM_PAINT messages that come later.
 In this message handler Finction..
Code: Pascal  [Select][+][-]
  1. function ComboBoxWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
  2.     LParam: Windows.LParam): LResult; stdcall;                                    
  3.  

Add this..
Code: Pascal  [Select][+][-]
  1.      end;
  2.     WM_SIZE:
  3.        begin
  4.           WindowInfo := GetWin32WindowInfo(Window);
  5.          If TCustomcombobox(WindowInfo^.WinControl).Style = csSimple Then
  6.          InvalidateRect(Window,Nil,true);
  7.        end;                                        
  8.  
  9.  

My other code, the last revision still remains in place, it needs to be there to fix those little items I originally found..
 
 This adding of the Message handler fixes the problem of sizing the box via code... etc..

 Let me know what you need.... please.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 27, 2020, 01:03:29 am
Yes, this fixes the missing bottom line. What's left, in my opinon, is the missing redraw after height changes by code, and the object inspector issue. I do not believe that this a bug of the OI, but a misplaced "(csDesigning in Component)" somewhere.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 27, 2020, 01:09:03 pm
The added message I showed you fixes the redraw when height changed by code..

Did you put that in the message loop?

Also I commented those sections that were testing for the csSimple as you pointed out..
and I made a change to the one of them because while in the designer mode it mess up the designer when trying to drag to a new position, the cursor gets off track for that control..

Code: Pascal  [Select][+][-]
  1. class procedure TWin32WSCustomComboBox.AdaptBounds(const AWinControl: TWinControl;
  2.   var Left, Top, Width, Height: integer; var SuppressMove: boolean);
  3. var
  4.   StringList: TWin32ComboBoxStringList;
  5. begin
  6.   {if TCustomComboBox(AWinControl).Style = csSimple Then Exit;}
  7.   StringList := GetStringList(TCustomComboBox(AWinControl));
  8.   if Assigned(StringList) then
  9.     Height := StringList.ComboHeight;
  10. end;                                    
  11.  
Code: Pascal  [Select][+][-]
  1. class procedure TWin32WSCustomComboBox.GetPreferredSize(
  2.   const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer;
  3.   WithThemeSpace: Boolean);
  4. begin
  5.   PreferredHeight := 0;
  6.   if (AWinControl.HandleAllocated)and
  7.   (Not(csDesigning in AWinControl.ComponentState)or(TCustomComboBox(AWinControl).Style <> csSimple)) then
  8.   { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ADDED}
  9.     PreferredHeight := AWinControl.Height;
  10. end;                                                              
  11.  
Code: Pascal  [Select][+][-]
  1.  
  2. class function TWin32WSCustomComboBox.GetStringList(
  3.   const ACustomComboBox: TCustomComboBox): TWin32ComboBoxStringList;
  4. begin
  5.   Result := nil;
  6.  { if ACustomComboBox.Style <> csSimple then}
  7.     Result := TWin32ComboBoxStringList(GetWin32WindowInfo(ACustomComboBox.Handle)^.List);
  8. end;                                                                                        
  9.  

I found that I had to uncomment those events to make things smoother for one of my PC's where as the other it didn't matter..
Btw, on my Win PRO 10 PC, I still have a 1 pixel calculation error at the base of the box while in Themes mode only. So I think the issue here is in the Themes drawing doing the calculations..
 The only other differences between the two pcs is version numbers of Lazarus..
WinPRO = 2.0.8 where as Home edition PC has 2.0.6 on it.. 64 bit for both.

 I have looked high and low, I can not find any reference in the Widget code or CustomCombo code that is causing the IDE issue..

If you would like I can forward you my copy of this complete widget file if you wish ?

Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 27, 2020, 01:57:28 pm
If you would like I can forward you my copy of this complete widget file if you wish ?
Yes please, I just was wanting to ask for it to make sure that I've got everything. Then I'll apply it to trunk. I also assigned your bug report to myself. On which Laz version will the modified file be based?

A tiny annoyance (besides the object inspector) is left: The AutoSize property is not working as I would expect, depending on what AutoSize is supposed to do. Well, when I change the font height and AutoSize is active, the combobox height increases, that's fine. But once it is possible to modify the height of the csSimple box with AutoSize=false it is possible to decrease the height of the control such that it becomes less than the height of the edit box. When I activate AutoSize now I would expect that the height jumps back to the height of the default edit box.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 27, 2020, 04:07:11 pm
AutoSize usually gets the "autosize" values from GetPreferredSize, and when I borrow code from TWin32WSCustomEdit the AutoSize described in the previous post works this way:
Code: Pascal  [Select][+][-]
  1. class procedure TWin32WSCustomComboBox.GetPreferredSize(
  2.   const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer;
  3.   WithThemeSpace: Boolean);
  4. begin
  5.   PreferredHeight := 0;
  6.   if (AWinControl.HandleAllocated) then
  7.   begin
  8.     if MeasureText(AWinControl, 'Fj', PreferredWidth, PreferredHeight) then
  9.     begin
  10.       PreferredWidth := 0;
  11.       Inc(PreferredHeight, 8);
  12.     end;
  13.   end;
  14. end;  
I am a bit in doubt though because I do not understand why the old combobox AutoSize worked at all.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 27, 2020, 07:31:52 pm
That last one totally destroyed it ! it shrunk the box down to the size of a normal EDIT box..

 As talk about before...

I uncommented(unblocked) the areas where csSimple was being ignored.

And the GetPreferred Size I have it the way I posted here..

Let me see if I can figure out how to send this to you via mail
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 27, 2020, 07:38:31 pm
Seems I can't sent it to you via this network with a message because it exceeds the size..

I think you have my personal email , send me a mail and I will reply back or if you want I can drop it here ?
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 27, 2020, 11:38:13 pm
I don't understand: win32wsstdctrls.pp is only 73 kB, and when you zip it it will be even smaller.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 28, 2020, 12:56:14 am
I guess you didn't understand..

 Attempted to message you via this forum but It was too large of a file for that..

 Do you want me to drop it here  for public consumption, that is my question ?
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 28, 2020, 01:01:23 pm
Now you completely lost me. I am interested in the win32wsstdctrls.pp file with your changes to make the csSimple style work as discussed in this thread. A zipped version is only a few kB which nicely fits into the upload limit. And the file is available to every Lazarus user. So why shouldn't it be wrong "to drop it for public consumption"? If you think that the forum is not the right place - yes, probably, it should be an attachment of your bugtracker report, where - by the way - the entire discussion of this topic should have occured. Normally only diff files should be submitted to bugtracker so that the reviewer can see what has been changed. But if you tell me on which Lazarus version the full file is based I can find out the diffs myself.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 28, 2020, 03:21:06 pm
This file is from my 2.0.4 cut..

The other PC is not near me atm but that has 2.0.8 and the file seems to be the same so there is no different that I can see.

 If you really want that file I can get It for you but I think this is enough..
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 28, 2020, 05:35:57 pm
Thanks. I created a patch from the differences to the trunk file and uploaded it to the bugtracker report. I also uploaded a demo. It shows me that the repaint issue after setting the csSimple combobox height by code is not yet solved.

While I normally use trunk I played with the demo with Laz 2.08 to have an unmodified system and to see the original painting bug again. Are you sure that disabling the integral height feature of the listbox really is the solution? I get the feeing that it simply hides the original repainting issue of the stationary listbox. Wouldn't it be better to find the handle of the stationary listbox and send a redraw message (or similar, of course)? Did you ever play with the handle of that listbox? I think it is accessible via the TComboboxInfo (TComboboxInfo.hwndList) - see ComboboxWndProc():  Win32Extra.GetComboBoxInfo(Window, @Info)

Another rather elemental problem: I don't know about the strategy what the LCL does with a control that has extended possibilities in one widgetset compared to others. Does it implement the full feature set in that widgetset and leave the fissing feature unimplemented in the others? Or does it implement only the "common denominator", i.e. only what is common to all, so that the control behaves the same in all widgetsets? I think I'll have to ask the other developers about it.
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 28, 2020, 06:04:33 pm
I will look at it again, I don't know why you still see this drawing after the changes. With the old 2.0.4
on WIn10 home it look perfect. with the Pro10 there is an initial problem where the themes isn't drawing the border properly but its one of those things that once you size it or even change the size of it using the modified code I then see the border..

 I could be wrong but I believe the handle (WIndow) is the handle to the actual combobox control in windows because if I use that handle to send messages to the combobox directly it response …

I'll Look a little deeper.. maybe I missed something...
Code: Pascal  [Select][+][-]
  1.       end;
  2.     WM_SIZE: {JP added for csSimple border painting with the list in view}
  3.        begin
  4.           WindowInfo := GetWin32WindowInfo(Window);
  5.          If TCustomcombobox(WindowInfo^.WinControl).Style = csSimple Then
  6.          Begin
  7.           InvalidateRect(Window,Nil,true);
  8.          end;
  9.        end; {/jp}            
  10.  
  11. Did you put that change in the Message handler ?
  12.                                
  13.  
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: jamie on May 28, 2020, 07:29:12 pm
The "GetPreferredSize" Needs to be put back to the original state..

What is happening it I get a limited amount of Height resizes at runtime, after which changing the height values do not change anything in the control, in otherwords you can't resize the controls at runtime after about 50 or more Height changes..

Code: Pascal  [Select][+][-]
  1. class procedure TWin32WSCustomComboBox.GetPreferredSize(
  2.   const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer;
  3.   WithThemeSpace: Boolean);
  4. begin
  5.   PreferredHeight := 0;    {JP Don't allow csSimple to query this, otherwise it will have limited size change counts}
  6.   if (AWinControl.HandleAllocated)and (TCustomComboBox(AWinControl).Style <> csSimple) then
  7.     PreferredHeight := AWinControl.Height;
  8. end;                                                                                              
  9.  
Title: Re: How to size a csSimple ComboBox at design time.?
Post by: wp on May 29, 2020, 12:26:27 am
Let's continue the discussion in the bug tracker - that's where it belongs to.
TinyPortal © 2005-2018