[MAXGUI] Extreme flickering in Listboxes (Win32)
BlitzMax Forums/BlitzMax Programming/[MAXGUI] Extreme flickering in Listboxes (Win32)
| ||
| Hi! I have the problem that the listboxes flicker extremely on the screen. This goes for Listboxes with text only, only icons and text + icons. You can see this best when you resize a window. The Listbox is cleared and redrawn frequently, so you see a "white" Listbox inbetween, which is very annoying. I made up an example code with a larger icon listbox. It needs an image called "0.jpg". (any size will do) ![]() Try to reisize the window sidways. And you see it at its best.
' Listbox extreme (tm) flickering bug example by Grisu
Const MAXFOLGEN=131 ' Icons
Const ICONSIZE=96 'Pixels
Local style:Int = WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_CLIENTCOORDS | WINDOW_MENU '| WINDOW_HIDDEN'|WINDOW_STATUS
Global MyWindow:TGadget=CreateWindow("Resizing right <> left or scrolling", (GadgetWidth(Desktop ())-792)/2,(GadgetHeight(Desktop ())-400)/2,792,400,Null,style)
Global ClientW:Int=ClientWidth(MyWindow)
Global ClientH:Int=ClientHeight(MyWindow)
Global CanH:Int = (ClientH-401)/2
Global CanW:Int = (ClientW-792)/2
' Create the large iconstripfile if not present already
If FileType("iconstrip.png")=0 Then
Global Fullpixmap:TPixmap=CreatePixmap(((MAXFOLGEN)*ICONSIZE),ICONSIZE,PF_BGR888,1)
Local tmppixmap:TPixmap
For Local i:Int=0 To MAXFOLGEN-1
tmppixmap=LoadPixmap("0.jpg") '96x96 Pixel icon!
fullpixmap.paste(ResizePixmap(tmppixmap,ICONSIZE-2,ICONSIZE-2),1+i*ICONSIZE,1)
Next
SavePixmapPNG(fullpixmap, "iconstrip.png",9 )
EndIf
Local IconStrip:TIconStrip=LoadIconStrip(MaskPixmap(LoadPixmap("iconstrip.png"),-1,-1,-1))
' Create Listbox
Global ListBox:TGadget=CreateListBox(3,5,ICONSIZE+28,ClientH-10,MyWindow,0)
SetGadgetIconStrip(ListBox, IconStrip)
SetGadgetLayout (ListBox:TGadget, EDGE_ALIGNED,0,EDGE_ALIGNED,EDGE_ALIGNED)
SetGadgetIconStrip(ListBox, IconStrip)
' Adding some test icons
For Local j=0 To MAXFOLGEN-1
AddGadgetItem ListBox, "", GADGETITEM_NORMAL, j, "this is icon no. "+ j
Next
While True
WaitEvent
'Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE
End
End Select
Wend
Is there a workaround for this? I know Mark's team has a lot to fix, but please fix this as well. Will you? Grisu |
| ||
| Anyone? *bump* |
| ||
| Not a single person testing it at least... *sigh* |
| ||
| Sorry Grisu - tested it ages ago and I can confirm the bug. (I probably forgot to post with the results after I tested.). The only thing I could come up with getting around it it is through using EventHooks() to detect when the window is being resized, hiding the gadget and then showing the gadget once you have stopped resizing. Not very pretty, I know, but it's better than giving epiletic users the shock of their lives. :P Just a thought... |
| ||
| This is an issue with many windows controls and hence not a bug in MaxGui. If you google you will find references to double buffered forms , humungous memory usage, lots and lots of warnings etc. There may be a better workaround where a window resize sets GDI clipping to only ever update areas of the client that have just been revealed only... |
| ||
| Thanks to both of you for looking into this. @Skid: This bug (as it is one for me) is NOT ONLY when resizing. It also happens, when I select a gadgetitem. The whole listbox, be it icons, text or both is pain white for a second. If it were only a bug in windows. Other apps such as ms word or exel should have the problem as well. But there it looks fine. This flickering is also visible in the max ide. Just resize it a bit. The Toolbar and Treebox to the right are flickering as well. I would code the workaround you've mentioned myself, but I don't know C... :( If you only update the areas of window that really have been modified it should also give you a performance increase on larger Lists, Toolbars and Treeboxes. So such workaround could really improve bmx in many areas at the same time imho. |
