How to stop ListIconGadget from flickering on resize?

Just starting out? Need help? Post your questions and find answers here.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

How to stop ListIconGadget from flickering on resize?

Post 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
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post 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)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Pretty smooth here on XP and Vista. :)
I may look like a mule, but I'm not a complete ass.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

I have dual monitors and I get smooth results on the ATI side, with some flickering on the nVidia side.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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:
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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. :?
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post 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
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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.)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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. :(
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

My system is ancient then. :lol:
Proud registered Purebasic user.
Because programming should be fun.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post 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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post 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.
Last edited by Mistrel on Mon Sep 08, 2008 12:00 am, edited 1 time in total.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Mistrel wrote:Don't hijack my thread! :shock:
Please excuse us for trying to help you solve this problem.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post 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.
Post Reply