Page 1 of 2

How to stop ListIconGadget from flickering on resize?

Posted: Mon Sep 01, 2008 10:12 pm
by Mistrel
Is there any way to prevent the ListIconGadget from flickering on resize?

Code: Select all

#Gadget1=0 
#Gadget2=1
#Splitter=2

Procedure WinCallback(hWnd, uMsg, wParam, lParam)
	Result=#PB_ProcessPureBasicEvents
	Select uMsg
		Case #WM_SIZE
			ResizeGadget(#Splitter,0,0,WindowWidth(0),WindowHeight(0))
	EndSelect
	ProcedureReturn Result
EndProcedure

If OpenWindow(0,0,0,230,180,"SplitterGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
	If CreateGadgetList(WindowID(0))

		ListIconGadget(#Gadget1,0,0,220,60,"",50)
		ListIconGadget(#Gadget2,0,0,0,0,"",50)
		SplitterGadget(#Splitter,0,0,230,180,#Gadget1,#Gadget2)
		
		SmartWindowRefresh(0,1)
		
		SetWindowCallback(@WinCallback())
		
		Repeat
		Until WaitWindowEvent()=#PB_Event_CloseWindow
	EndIf
EndIf

Posted: Mon Sep 01, 2008 10:20 pm
by Mistrel
This helps some:

Code: Select all

hWnd=GadgetID(#Gadget1)
SetWindowLong_(hWnd,#GWL_STYLE,GetWindowLong_(hWnd,#GWL_STYLE)|#WS_CLIPCHILDREN)
hWnd=GadgetID(#Gadget2)
SetWindowLong_(hWnd,#GWL_STYLE,GetWindowLong_(hWnd,#GWL_STYLE)|#WS_CLIPCHILDREN)
hWnd=GadgetID(#Splitter)
SetWindowLong_(hWnd,#GWL_STYLE,GetWindowLong_(hWnd,#GWL_STYLE)|#WS_CLIPCHILDREN)

Posted: Mon Sep 01, 2008 10:52 pm
by srod
Pretty smooth here on XP and Vista. :)

Posted: Mon Sep 01, 2008 11:21 pm
by Sparkie
I have dual monitors and I get smooth results on the ATI side, with some flickering on the nVidia side.

Posted: Mon Sep 01, 2008 11:46 pm
by Fred
Sparkie wrote:I have dual monitors and I get smooth results on the ATI side, with some flickering on the nVidia side.
:shock:

Posted: Tue Sep 02, 2008 12:03 am
by Sparkie
My current system is ~7-8 years old and the graphics cards are not high end cards, but I too was a little surprised by the difference in flickering. :?

Posted: Tue Sep 02, 2008 12:08 am
by Mistrel
Working with some code from elsewhere on the forum, RedrawWindow_ has solved the resize flickering. But I can't figure out how to stop the flickering when the splitter is moved.

Code: Select all

Enumeration
  #Main
EndEnumeration

Enumeration
  #Main_Web
  #Main_Combo
  #Main_List
  #Main_Container
  #Main_Splitter
EndEnumeration

Global OldContainerWndProc

Procedure WinCallback(hWnd, uMsg, wParam, lParam)
	Select uMsg
		Case #WM_SIZE
	    ResizeGadget(#Main_Splitter,#PB_Ignore,#PB_Ignore,WindowWidth(#Main)-10,WindowHeight(#Main)-10)
	    ResizeGadget(#Main_Combo,#PB_Ignore,#PB_Ignore,GadgetWidth(#Main_Container),#PB_Ignore)
	    ResizeGadget(#Main_List,#PB_Ignore,#PB_Ignore,GadgetWidth(#Main_Container),GadgetHeight(#Main_Container)-25)
			RedrawWindow_(WindowID(#Main),0,0,#RDW_UPDATENOW)
	EndSelect
	ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

Procedure ContainerCallback(hWnd, uMsg, wParam, lParam)
	Select uMsg
		Case #WM_SIZE
			Debug 1
	EndSelect
	Result=CallFunctionFast(OldContainerWndProc, hWnd, uMsg, wParam, lParam)
	ProcedureReturn Result
EndProcedure

If OpenWindow(#Main,#False,#False,420,235,"Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget) And CreateGadgetList(WindowID(#Main))
  SmartWindowRefresh(#Main,#True)
  WebGadget(#Main_Web,0,0,0,0,"")
  ContainerGadget(#Main_Container,0,0,0,0)
    ComboBoxGadget(#Main_Combo,0,0,160,200)
    ListIconGadget(#Main_List,0,25,160,200,"Test",70,#PB_ListIcon_FullRowSelect|#PB_ListIcon_HeaderDragDrop)
    AddGadgetColumn(#Main_List,1,"Test2",160)
    AddGadgetColumn(#Main_List,2,"Test3",60)
    For i=0 To 100
      AddGadgetItem(#Main_List,-1,"HelloHello"+#LF$+"HelloHelloHelloHello"+#LF$+"Hello")
    Next
  CloseGadgetList()
  SplitterGadget(#Main_Splitter,5,5,410,225,#Main_Web,#Main_Container,#PB_Splitter_Vertical|#PB_Splitter_Separator)
  ResizeGadget(#Main_Splitter,#PB_Ignore,#PB_Ignore,WindowWidth(#Main)-10,WindowHeight(#Main)-10)
  ResizeGadget(#Main_Combo,#PB_Ignore,#PB_Ignore,GadgetWidth(#Main_Container),#PB_Ignore)
  ResizeGadget(#Main_List,#PB_Ignore,#PB_Ignore,GadgetWidth(#Main_Container),GadgetHeight(#Main_Container)-25)
Else
  MessageRequester("Warning!","Error opening window!",#MB_ICONWARNING)
  End
EndIf

hWnd=GadgetID(#Main_Container)
SetWindowLong_(hWnd,#GWL_STYLE,GetWindowLong_(hWnd,#GWL_STYLE)|#WS_CLIPCHILDREN)

SetWindowCallback(@WinCallback(),#Main)

OldContainerWndProc=SetWindowLong_(GadgetID(#Main_Container),#GWL_WNDPROC,@ContainerCallback())

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver

Posted: Tue Sep 02, 2008 7:18 am
by blueznl
Sparkie wrote: I have dual monitors and I get smooth results on the ATI side, with some flickering on the nVidia side.
Sparkie, could you tell me if the same effect still applies if you swap primary and secondary monitor? (in Windows, of course, not swapping the cables :-))

Also, as you have two cards, are both PCI, or is one AGP and the other PCI?

I've seen similar behaviour as well, even with two cards of the same brand (though different models) where flickering on one screen was different from the other, but even worse: dragging a window left some remains now and again.

Never managed to fix all of the flickering, though changing one of the drivers for an older version took away part of the problem.

(In my case It was an AGP GeForce 4 Ti in combination with a PCI GeForce 2 MX.)

Posted: Wed Sep 03, 2008 1:33 am
by Sparkie
I switched monitor#1 (ATI AGP) to #2 and monitor #2 (nVidia PCI) to #1 and there was no difference. Seems to be flickerfree on both monitors when I have minimal amount of apps open.

It now makes sense to me as there must have been some extra cpu usage from another app while I was testing Mistrel's code.

As I mentioned before, my system is getting up there in years and she ain't got the zipity-do-da she had when she was younger. :(

Posted: Wed Sep 03, 2008 2:34 am
by byo
My system is ancient then. :lol:

Posted: Sun Sep 07, 2008 10:22 pm
by Mistrel
Don't hijack my thread! :shock:

Is there any way to prevent the list icon gadget from flickering when the splitter gadget is expanded?

I think the issue has something to do with the container gadget.

Posted: Sun Sep 07, 2008 10:25 pm
by PB
> I can't figure out how to stop the flickering when the splitter is moved

I hate to say it, but it looks like a video driver issue, because when I run your
code on my old PC, I get no noticeable flickering at all, on any part of the window.

Posted: Sun Sep 07, 2008 10:29 pm
by Mistrel
Resize the window so that it's large. Bring the splitter to the far right and then drag it to the left. It only happens when the splitter moves from right to left and it's most prominent when the window is large.

Posted: Sun Sep 07, 2008 10:44 pm
by Sparkie
Mistrel wrote:Don't hijack my thread! :shock:
Please excuse us for trying to help you solve this problem.

Posted: Sun Sep 07, 2008 11:25 pm
by Mistrel
Sparkie wrote:
Mistrel wrote:Don't hijack my thread! :shock:
Please excuse us for trying to help you solve this problem.
I felt that the thread was beginning shift away from the topic. Action words an an expressive emoticon were in high order.