Recent

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

wp

  • Hero Member
  • *****
  • Posts: 7525
Re: How to size a csSimple ComboBox at design time.?
« Reply #30 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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

jamie

  • Hero Member
  • *****
  • Posts: 3520
Re: How to size a csSimple ComboBox at design time.?
« Reply #31 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
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 3520
Re: How to size a csSimple ComboBox at design time.?
« Reply #32 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 ?
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 7525
Re: How to size a csSimple ComboBox at design time.?
« Reply #33 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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

jamie

  • Hero Member
  • *****
  • Posts: 3520
Re: How to size a csSimple ComboBox at design time.?
« Reply #34 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 ?
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 7525
Re: How to size a csSimple ComboBox at design time.?
« Reply #35 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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

jamie

  • Hero Member
  • *****
  • Posts: 3520
Re: How to size a csSimple ComboBox at design time.?
« Reply #36 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..
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 7525
Re: How to size a csSimple ComboBox at design time.?
« Reply #37 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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

jamie

  • Hero Member
  • *****
  • Posts: 3520
Re: How to size a csSimple ComboBox at design time.?
« Reply #38 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.  
« Last Edit: May 28, 2020, 06:07:56 pm by jamie »
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 3520
Re: How to size a csSimple ComboBox at design time.?
« Reply #39 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.  
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 7525
Re: How to size a csSimple ComboBox at design time.?
« Reply #40 on: May 29, 2020, 12:26:27 am »
Let's continue the discussion in the bug tracker - that's where it belongs to.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

 

TinyPortal © 2005-2018