Resized Event Listbox

Hello,
is there a way to trigger resized event of a listbox?

thanks

Resize the window ?

Refresh, RefreshRect, Invalidate, …

I do not saw any event with that name here.

I mean resized listbox event, I’m writing a listbox class with extra functions, so I need to know when a listbox has been resized

You could check if Width and Height have changed at the start of the CellBackroundPaint event.

On Open event I wrote:

cHeigh = me.Height
Open()

On CellBackroundPaint event I wrote:

if cHeigh <> me.Height then
cHeigh = me.Height
Resized()
end if
CellBackroundPaint()

cHeigh is a property

but in this way I get the event “Resizing”

Put it in a container control?

Here is how :

  • Add a container control to your project as a class
  • Add to it properties that keeps the current width and height, for instance oldw and oldh that you initialise in the Lisbox Open event

Sub Open() oldw = me.width oldh = me.height End Sub

  • Create a method in your class called Resize
  • Add a timer with a period of 100 with the following code :

Sub Action() if oldw <> Listbox1.width or oldh <> ListBox1.Height then Resize oldw = Listbox1.width oldh = ListBox1.Height end if End Sub

Lock the container control on the 4 sides, and the same for the listbox.

Now drag the class over a window. Lock its 4 sides. Whenever the window is resized, the Resize method is called. The event shows up in the events you can add to your instance.

The timer period of 100 checks every 1/10th of a second the size of the Listbox. Should be short enough to detect resize while the window is resized.

You will need to make sure the ListBox properties and events are ‘echoed’ by your class properties and events; use the timer to copy changes in values, and use methods to reproduce and trigger the listbox events the same way the resize event was added.

[quote=87444:@Michel Bujardet]Here is how :

  • Add a container control to your project as a class
  • Add to it properties that keeps the current width and height, for instance oldw and oldh that you initialise in the Lisbox Open event

Sub Open() oldw = me.width oldh = me.height End Sub

  • Create a method in your class called Resize
  • Add a timer with a period of 100 with the following code :

Sub Action() if oldw <> Listbox1.width or oldh <> ListBox1.Height then Resize oldw = Listbox1.width oldh = ListBox1.Height end if End Sub

Lock the container control on the 4 sides, and the same for the listbox.

Now drag the class over a window. Lock its 4 sides. Whenever the window is resized, the Resize method is called. The event shows up in the events you can add to your instance.

The timer period of 100 checks every 1/10th of a second the size of the Listbox. Should be short enough to detect resize while the window is resized.

You will need to make sure the ListBox properties and events are ‘echoed’ by your class properties and events; use the timer to copy changes in values, and use methods to reproduce and trigger the listbox events the same way the resize event was added.[/quote]
Michel

It might be better to just subclass a Listbox and utilise your code in that new subclass. Then you don’t have to export all the listbox functions to the Container.

[quote=87461:@Simon Berridge]Michel

It might be better to just subclass a Listbox and utilise your code in that new subclass. Then you don’t have to export all the listbox functions to the Container.[/quote]

Yes, you are right.