Lazarus

Programming => General => Topic started by: Jvan on September 11, 2020, 11:07:27 pm

Title: Combobox with no borders?
Post by: Jvan on September 11, 2020, 11:07:27 pm
Is it possible?
By default it has "BorderStyle: bsNone", but it still has borders.
Title: Re: Combobox with no borders?
Post by: Blaazen on September 11, 2020, 11:37:00 pm
I don't understand why Lazarus has this property published because it seems Delphi doesn't have it.
Title: Re: Combobox with no borders?
Post by: jamie on September 11, 2020, 11:53:20 pm
Is it possible?
By default it has "BorderStyle: bsNone", but it still has borders.

Combo is a Interface/OS control and is draw mostly via the OS so some of those properties may not do much for you in a Win32 target. could be different elsewhere
Title: Re: Combobox with no borders?
Post by: winni on September 11, 2020, 11:53:59 pm
Hi!

As the ComboBox is a WinControl this is a decision of the widgetset:

Code: Pascal  [Select][+][-]
  1. procedure TWinControl.SetBorderStyle(NewStyle: TBorderStyle);
  2. begin
  3.   if FBorderStyle = NewStyle then Exit;
  4.   FBorderStyle := NewStyle;
  5.   if HandleAllocated then
  6.     TWSWinControlClass(WidgetSetClass).SetBorderStyle(Self, NewStyle);
  7. end;
  8.  

Winni
Title: Re: Combobox with no borders?
Post by: jamie on September 12, 2020, 01:34:30 am
Is it possible?
By default it has "BorderStyle: bsNone", but it still has borders.

Not the best solution because the drop down would also need to be calculated.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.    SetWindowRgn(ComboBox1.Handle, CreateRectRgn(2,2,ComboBox1.Width - 2,
  4.                 ComboBox1.Height - 2), True)
  5. end;                                                                      
  6.  
Title: Re: Combobox with no borders?
Post by: Gald on November 28, 2020, 05:40:22 am
I tried to report it on BugTracker (#38126), this was my first report on Bugtracker ever.  :-[

The dev asked me about Delphi. If Delphi can do it and it does! But with another property name (see related pic).
But seems that he need a new version of Delphi to see how it is coded.

Anyway, It can be done someway. Does anyone know the solution?
Title: Re: Combobox with no borders?
Post by: lucamar on November 28, 2020, 07:51:54 am
But seems that he need a new version of Delphi to see how it is coded.

Not, probably, to see how it's coded but to see how it works: what it does, what other properties affect it, etc.

We don't want Embarcadero starting again the old FUD of "look, Lazarus copies our code!", do we? ;D
Title: Re: Combobox with no borders?
Post by: Bart on November 28, 2020, 01:30:34 pm
The dev asked me about Delphi. If Delphi can do it and it does! But with another property name (see related pic).

I asked you about Delphi compatibilty, not once, but several times.
You refused to answer my questions there and insist that because Delphi implements a property name BevelEdges, that this would imply that in Lazarus the property BorderStyle should do the same.

I then asked you if something like
Code: Pascal  [Select][+][-]
  1. Combobox1.BorderStyle := bsNone;
would even compile in Delphi.
Again no answer from you.

So please don't lash out at me here.

My basic question was, and still is: does Delphi implement a borderstyle property for TCombobox?

Things I haven't been able to investigate yet: does setting BorderStyle have the expected effect in other widgetsets (GTK2, GTK3, QT4, QT5, Cocoa)?
If not, then a better action would be to not publish this property at all.

Bart
Title: Re: Combobox with no borders?
Post by: Bart on November 28, 2020, 01:33:01 pm
B.t.w. you might be able to achieve this in windows using GetWindowLong/SetWindowLong (query GWL_EXSTYLE and then change it to be borderless).

Warning: untested hypothesis.

Bart
Title: Re: Combobox with no borders?
Post by: PascalDragon on November 28, 2020, 03:46:07 pm
My basic question was, and still is: does Delphi implement a borderstyle property for TCombobox?

Tested with Delphi 10.2: no, it does not.
Title: Re: Combobox with no borders?
Post by: Bart on November 28, 2020, 04:58:24 pm
My basic question was, and still is: does Delphi implement a borderstyle property for TCombobox?

Tested with Delphi 10.2: no, it does not.

Thanks.

Bart
Title: Re: Combobox with no borders?
Post by: Gald on November 28, 2020, 06:44:27 pm
Solved.  :D

Thank you!
Title: Re: Combobox with no borders?
Post by: Bart on November 28, 2020, 11:18:27 pm
From your screenshot, do I have to infer that setting the font of the form somehow makes the combobox borderless?

How did you achieve a borderless Combobox exactly?

Bart
Title: Re: Combobox with no borders?
Post by: jamie on November 29, 2020, 07:40:29 pm
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.    SetWindowRgn(ComboBox1.Handle, CreateRectRgn(2,2,ComboBox1.Width - 2,
  4.                 ComboBox1.Height - 2), True)
  5. end;
  6.  
  7.  
This will remove the border, simply because it can't draw there.

As for the drop down, that can be done by removing the WS_BORDER from the Style property of the window using the SetwindowLong.

of course you need to use the GetComboBoxInfo to obtain the handle to the ListItem..

All of this works if you really want it bad enough.
Title: Re: Combobox with no borders?
Post by: Bart on December 01, 2020, 11:04:11 pm
I have resolved the issue in the bugtracker by documenting that this is not supported under Windows.
It will show up in the "Restricted" tab of the Object Inspector.
Some other widgetsets actually seem to support it, so no reason to remove this property.

Googling for "delphi borderless combobox" showed me 2 other possible solutions.
One is to sublclass TComboBox and override Paint.
The other is a combobox replacement by TMS Software (Delphi): https://www.tmssoftware.com/site/advcombo.asp

Bart
Title: Re: Combobox with no borders?
Post by: lainz on December 02, 2020, 02:40:17 am
There is as well bgracontrols combo box. But the only style it supports is drop down list. You can't search with it or type.
TinyPortal © 2005-2018