PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Listbox control refresh  (Read 612 times)

Bumblebee

  • Junior Member
  • **
  • Posts: 50
Listbox control refresh
« on: May 21, 2020, 04:21:35 AM »

Is it normal for a listbox control to not update its contents during a loop?
In the attached demo, only the scroll bars get updated. No items are shown during operation of the loop.

If it is normal, I will set the TopIndex or Refresh properties as needed.
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9313
  • Windows 10
    • PlanetSquires Software
Re: Listbox control refresh
« Reply #1 on: May 21, 2020, 08:24:53 AM »

The listbox should update after every addition to the list. I downloaded your sample and, yes, it does not appear to be refreshing. I will look at the code for that to ensure that the display is updated after every add. Thanks for the report.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9313
  • Windows 10
    • PlanetSquires Software
Re: Listbox control refresh
« Reply #2 on: May 21, 2020, 08:39:39 AM »

Can you please unzip the attached archive and overwrite the existing files in this folder:

\WinFBE_Suite\FreeBASIC-1.07.1-gcc-5.2\inc\WinFormsX

Please let me know if the refresh issue is corrected.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Bumblebee

  • Junior Member
  • **
  • Posts: 50
Re: Listbox control refresh
« Reply #3 on: May 21, 2020, 06:23:50 PM »

I still have the refresh issue.
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9313
  • Windows 10
    • PlanetSquires Software
Re: Listbox control refresh
« Reply #4 on: May 21, 2020, 06:44:22 PM »

Thanks - I figured that you might. I will add an explicit refresh in the library to ensure that the WM_DRAWITEM message gets generated by Windows.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Bumblebee

  • Junior Member
  • **
  • Posts: 50
Re: Listbox control refresh
« Reply #5 on: May 21, 2020, 06:48:37 PM »

If it causes flickering when items are added rapidly, then it might not be worth it..?
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9313
  • Windows 10
    • PlanetSquires Software
Re: Listbox control refresh
« Reply #6 on: May 21, 2020, 07:41:18 PM »

I could add functionality similar to the Listview where when adding a bulk number of items you can call BeginUpdate and when finished adding you call EndUpdate. The Listbox implementation already uses double buffering with offscreen bitmaps so the amount of flicker should be low. I will do some tests to see if adding the refresh produces enough flicker to warrant adding the BeginUpdate/EndUpdate syntax.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Wilko Verweij

  • Junior Member
  • **
  • Posts: 166
  • PB10 - FF3.7 User; Win 10
    • CHEAQS
Re: Listbox control refresh
« Reply #7 on: May 22, 2020, 09:54:41 AM »

I believe the default behavior of a listbox is that it refreshes after each addition. For adding large numbers of items, you could apply the LBS_NOREDRAW message combined with manual updating afterwards (WM_SetRedraw). Maybe this helps
Logged

Bumblebee

  • Junior Member
  • **
  • Posts: 50
Re: Listbox control refresh
« Reply #8 on: August 03, 2020, 10:38:53 AM »

Another small issue that I'm observing in Windows 7...
When an item is selected near the bottom of a listbox and some items are removed programmatically, a gap is left at the bottom.

In the demo, click on Populate.
When the process is complete, a listbox item will be selected.
Click on Remove to see if the gap appears in your version of Windows.
Logged

jermy

  • Junior Member
  • **
  • Posts: 60
Re: Listbox control refresh
« Reply #9 on: August 05, 2020, 07:37:22 PM »

in case no one noticed, the menu displays refresh twice
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9313
  • Windows 10
    • PlanetSquires Software
Re: Listbox control refresh
« Reply #10 on: August 07, 2020, 03:32:09 PM »

Thanks guys, I have added your issues to my to-do list.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer