Recent

Author Topic: [SOLVED] TComboBox and its Items[]  (Read 2921 times)

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
[SOLVED] TComboBox and its Items[]
« on: August 31, 2014, 07:46:08 pm »
Can someone point me where is TComboBox notified that its Items changed?

When I do
Code: [Select]
ComboBox1.Items[0]:='dfzuk'; how TComboBox knows that it has to repaint itself.
I'm looking to sources and I cannot find any event or so.

Thanks
« Last Edit: September 01, 2014, 11:13:40 am by Blaazen »
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: TComboBox and its Items[]
« Reply #1 on: August 31, 2014, 08:52:13 pm »
hello Blaazen
this is not an answer ... i'm not able to find it like you but found this
http://delphi.about.com/od/vclusing/a/drawincombobox.htm
and thought it might help
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: TComboBox and its Items[]
« Reply #2 on: August 31, 2014, 09:25:30 pm »
Can someone point me where is TComboBox notified that its Items changed?

When I do
Code: [Select]
ComboBox1.Items[0]:='dfzuk'; how TComboBox knows that it has to repaint itself.
I'm looking to sources and I cannot find any event or so.

Thanks

This is done in the WSCustomComboBox class for example in the QT widget set it has a TQtComboStrings class declared which overrides the put internal method calling the setItemIndex to force a refresh. Didn't looked close enough for the other widget sets but I suspect something similar is done there too.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TComboBox and its Items[]
« Reply #3 on: August 31, 2014, 09:33:55 pm »
As Taazz mentioned, it gets replaced with a ws related strings class:
Code: [Select]
procedure TCustomComboBox.InitializeWnd;
..
  // get the interface based item list
  NewStrings:= TWSCustomComboBoxClass(WidgetSetClass).GetItems(Self);
...

For Win32:
Code: [Select]
class function TWin32WSCustomComboBox.GetItems(const ACustomComboBox: TCustomComboBox): TStrings;
var
  winhandle: HWND;
begin
  winhandle := ACustomComboBox.Handle;
  Result := TWin32ComboBoxStringList.Create(winhandle, ACustomComboBox);
  GetWin32WindowInfo(winhandle)^.List := Result;
end;

Code: [Select]
  TWin32ComboBoxStringList = class(TWin32ListStringList)
...

Code: [Select]
  TWin32ListStringList = Class(TStrings)
...

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: TComboBox and its Items[]
« Reply #4 on: August 31, 2014, 09:50:24 pm »
And the TWin32ListStringList.Insert method includes a
Code: [Select]
   ...Windows.SendMessage{or SendMessageW}(..., FFlagAddString, ....);
where FFlagAddString is an alias for LB_ADDSTRING

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TComboBox and its Items[]
« Reply #5 on: September 01, 2014, 11:13:13 am »
Thanks, I'm designing TCheckComboBox, as proposed recently here, and I was looking where to hook.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: [SOLVED] TComboBox and its Items[]
« Reply #6 on: September 01, 2014, 11:29:02 am »
Check also the lb_change message might suit your case better.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018