Recent

Author Topic: Combobox: increase arrow size  (Read 869 times)

iversen

  • New member
  • *
  • Posts: 8
Combobox: increase arrow size
« on: May 25, 2024, 12:17:16 pm »
Good morning,
I have a combobox in a window that is used with a touch panel. I have increased the size of the combobox and the font without any problem, but the arrow that makes the combobox display the items remains very narrow, making it difficult to click on it to open the dropdown. How could I increase the width of this part?
Is there a function that allows by code to display all the items of a combobox?

thank you very much and have a good weekend

jamie

  • Hero Member
  • *****
  • Posts: 6314
Re: Combobox: increase arrow size
« Reply #1 on: May 25, 2024, 09:03:22 pm »
You may find this hard to believe, but doing so is not straight forward.

To give you an example of down sizing the EDIT box of the combox to make room for a window button.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. Var
  3.   CB:TCOMBOBOXINFO;
  4.   Winfo:TWINDOWINFO;
  5. begin
  6.    CB.cbSize := SizeOf(CB);
  7.    Winfo.cbSize := SizeOF(Winfo);
  8.    SendMessage(ComboBox1.Handle, CB_GetComboBoxInfo,0, PtrUint(@CB));
  9.    GetWindowInfo(CB.hwndItem,WInfo);
  10.    MoveWindow(CB.hwndItem,cb.rcItem.left,cb.rcItem.top,20,CB.rcItem.Height,True);
  11.    Caption := Winfo.rcClient.Width.ToString;
  12. end;                                                  

That is test code btw, but it will shrink the edit box portion to 20 pixels wide.

More code needed to create a larger button in the now unused area.

So I have a suggestion, place a TPanel on the form and place the TComboBox within it. Make the Edit box obey to the left and top sides of the panel and make the panel wider to accommodate for a larger push button area.

 Implement the panel's onClick and have it do the Combobox.DroppedDown := True;

 also, you can set the itemWidth in the Combobox the same as the Panel width.

 When all of this takes place, you will have an exposed area of the panel that will respond to your click and drop the combobox.

 I suppose and temp is available, I could make up a demo project if needed.

The only true wisdom is knowing you know nothing

iversen

  • New member
  • *
  • Posts: 8
Re: Combobox: increase arrow size
« Reply #2 on: May 27, 2024, 06:41:27 pm »
Thank you very much for the answer, I have seen the ideal solution that is more complex than I expected, but it has helped me to see what to do:

procedure TForm1.ComboBox1Click(Sender: TObject);
begin
 Combobox1.DroppedDown:=true;
end;

It now solves the problem I had (the operator had a hard time getting the arrow for the drop-down menu right).

Thanks once again!

jamie

  • Hero Member
  • *****
  • Posts: 6314
Re: Combobox: increase arrow size
« Reply #3 on: May 27, 2024, 08:36:41 pm »
Ok,
Many just place an additional button that is sizeable to the right or wherever to drop it.

Have a good day :o
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018