MaxGui: Clear Listbox still broken? (win32)

BlitzMax Forums/BlitzMax Programming/MaxGui: Clear Listbox still broken? (win32)

Grisu(Posted 2006) [#1]
ModuleInfo "History: 1.16 Release"
ModuleInfo "History: fixed Win32ListBox::clear() to also remove tooltips"

I still get the same bug with the tooltips explained here...
http://www.blitzbasic.com/Community/posts.php?topic=60517

Strict 

Local window:TGadget
Local button:TGadget
Global Listbox:TGadget

Local combobox:TGadget
Local dfa_mode:Int = 0

Const MAXKIDSFOLGEN=29
Const MAXFOLGEN=130

window=CreateWindow("My Window",30,20,200,200)
button=CreateButton("Change Listbox",4,100,100,24,window,BUTTON_OK)

Listbox=CreateListBox(4,4,120,80,window)
Create_Listbox(dfa_mode)


While WaitEvent()
	Select EventID()
		Case EVENT_GADGETACTION
			Print "eventdata="+EventData()
		Case EVENT_WINDOWCLOSE
			End
	End Select

	Select EventSource() 		 
		Case Button 
          dfa_mode=Not dfa_mode
          Create_Listbox(dfa_mode)
	End Select
Wend


Function Create_Listbox(cfg_dfamode:Int)
' Create a fresh Listbox according to dfamode

ClearGadgetItems Listbox ' clean all mess up

Select cfg_dfamode
Case 0
   For Local i:Int=0 To MAXFOLGEN-1
     AddGadgetItem ListBox, "MODE 1 - Item "+i, GADGETITEM_NORMAL, 0, "MODE1 Helptext "+i
   Next 

Case 1
   For Local j:Int=0 To MAXKIDSFOLGEN-1
     AddGadgetItem ListBox, "MODE 2 - Item "+j, GADGETITEM_NORMAL, 0, "MODE2 Helptext "+j
   Next 
End Select 

End Function



SebHoll(Posted 2006) [#2]
Skid, looks like the bug is still there. If you scroll down when you have switched items and hover your mouse over the items, the final part of the tip is broken (e.g. variable j) even though the start (i.e. MODE1/MODE 2) is OK.

Weird....


Mark Tiffany(Posted 2006) [#3]
I have a feeling that for some reason this wasn't going to arrive until a full update, rather than just a syncmods? (No idea why though...)


Grisu(Posted 2006) [#4]
Mark, it's in the release notes. ELSE I would not have posted this again.


Ziltch(Posted 2006) [#5]
Looking at the Win32 C++ code it appears that the tooltips for listboxs need more work before they are usable.

The main problem is that the item index+1 is used for the toolinfo id. This means inserting items can overwrite an existing id.

The clear listbox is not working as the loop removes item zero each time. As the gadget index is used for the tips it just removes tip 0 many times. The Win32ListBox remove function also is calculating the tip id from index not index+1 as is done in the other functions.

I have also noticed after insert items that the tips can get out of sync after the listbox slider is used.


Grisu(Posted 2006) [#6]
I deadly need a fix for this.

This was reported a month ago and I hoped it would be easy to fix with my example code provided.

As I don't know C++, I feel kind of helpless. :(


Ziltch(Posted 2006) [#7]
I have made some test changes to win32listbox.cpp. They seem to fix the problems. I still have one bug to hunt down, and some more testing to do.
I will finish this off in the Morning as it is 2:44AM.

I need this to work as well, but it is not a simple fix as it may seem! All the tips need to be moved if inserting or removing them.


Grisu(Posted 2006) [#8]
Thanks a lot for looking into this!!!


skidracer(Posted 2006) [#9]
Hopefully fixed, try a syncmods for fix.


Ziltch(Posted 2006) [#10]
Skidracer:
Thanks for the updates!

Your fix uses lParam in the LVITEM structure to store the tip id.
As windows uses lParam for sorting lists, this will stop any Windows API sort on the list items from working. This is a shame as I had just got functions to sort listboxs working.

The fix to this I have written keeps the tips insync with the listbox items when an item is inserted or removed. It does not need lParam.
Do you want me to email a copy to you?


skidracer(Posted 2006) [#11]
just post here Ziltch, thanks


Ziltch(Posted 2006) [#12]
Here are the modified functions



It looks the indents have got messed up a bit! : Edit fixed code indents

If you use this I can post the sorting code I have worked on.

Thanks


Grisu(Posted 2006) [#13]
Tooltips are working correctly now. (after sync)

Don't know for the sorting issue though...

Thanks again everyone!


skidracer(Posted 2006) [#14]
Ziltch, I do intend to incorporate your fix and will bump this thread soon to discuss sorting. Hopefully current fix will suffice for now.