Recent

Author Topic: LAMW: Change jComboEditText Dropdown font color/Background color  (Read 3177 times)

c4p

  • Full Member
  • ***
  • Posts: 158
LAMW: Change jComboEditText Dropdown font color/Background color
« on: September 17, 2017, 02:14:00 pm »
Is there a method to change the font color/background color on jComboEditText component?
Can't find one for it other than Font color/background for the edit box, not the dropdown font color/background color?

Thanks in advance.
« Last Edit: September 17, 2017, 03:03:13 pm by c4p »
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: LAMW: Change ComboEditText Dropdown font color/Background color
« Reply #1 on: September 17, 2017, 02:31:35 pm »
You can draw the items using the OwnerDraw mechanism: Set Combobox.Style to csOwnerDrawfixed or csOwnerDrawVariable - in the latter case you also can vary the item height by using OnMeasureItem - and write a handler for the OnDrawItem event, like this:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  2.   ARect: TRect; State: TOwnerDrawState);
  3. begin
  4.   with Control as TCombobox do begin
  5.     Canvas.FillRect(ARect);
  6.     if DroppedDown then
  7.       Canvas.Font.Color := clRed;
  8.     Canvas.TextOut(ARect.Left + 2, ARect.Top + 2, Items[Index]);
  9.   end;
  10. end;

c4p

  • Full Member
  • ***
  • Posts: 158
Re: LAMW: Change ComboEditText Dropdown font color/Background color
« Reply #2 on: September 17, 2017, 02:46:03 pm »
Will this work on the LAMW jComboEditText component?
« Last Edit: September 17, 2017, 02:49:27 pm by c4p »
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: LAMW: Change jComboEditText Dropdown font color/Background color
« Reply #3 on: September 17, 2017, 03:12:45 pm »
Sorry, I did not see the "j". But why don't you try?

c4p

  • Full Member
  • ***
  • Posts: 158
Re: LAMW: Change jComboEditText Dropdown font color/Background color
« Reply #4 on: September 17, 2017, 03:50:43 pm »
Already did, was just checking.  :(
Thanks anyway.
« Last Edit: September 17, 2017, 03:59:45 pm by c4p »
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: LAMW: Change jComboEditText Dropdown font color/Background color
« Reply #5 on: September 19, 2017, 03:06:11 am »

Hi c4p!

About:
Quote
dropdown font color/background color?

I will improve "jComboEditText" ...

Thank you!

Edited: Done!!!!
« Last Edit: September 19, 2017, 04:46:52 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 158
Re: LAMW: Change jComboEditText Dropdown font color/Background color
« Reply #6 on: September 19, 2017, 09:29:31 am »
Working perfect, thank you so much jmpessoa  :)
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

 

TinyPortal © 2005-2018