Weird Flickering [SOLVED]

Just starting out? Need help? Post your questions and find answers here.
daveb
User
User
Posts: 30
Joined: Tue Jun 07, 2022 6:12 pm

Weird Flickering [SOLVED]

Post by daveb »

I intended to use this code as part of a small Windows program I am writing.

Code: Select all

EnableExplicit
Define.i a, event
If OpenWindow(0, 0, 0, 500, 250, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	PanelGadget(1, 10, 10, 480, 230)
	For a = 1 To 5
		AddGadgetItem(1, -1, "Panel Tab " + Str(a), 0, 0)
	Next
	CloseGadgetList()
	SendMessage_(GadgetID(1), #TCM_SETCURSEL, 1, 0) ; Value of 1 selects tab 2
	Repeat
		event = WaitWindowEvent()
	Until event = #PB_Event_CloseWindow
EndIf
On first run tab 2 is selected, but selecting any tab except tab 1, the panels of tabs 2, 3, 4 & 5 flicker. The flickering only stops when tab 1 has been selected. Any thoughts about what might be causing this flicker?

TIA
Dave
Last edited by daveb on Fri Sep 30, 2022 4:33 pm, edited 1 time in total.
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: Weird Flickering

Post by BarryG »

Confirmed here. It seems that WaitWindowEvent() is still receiving triggering events, as shown by the below. Run the code, click tab 3 and then DON'T move the mouse or do anything for a few moments. The Debug Output keeps showing "n" getting incremented for some reason.

But, why are you using SendMessage instead of "SetGadgetState(1, 1)"? Then you don't get the flickering.

Code: Select all

EnableExplicit
Define.i a, event, n
If OpenWindow(0, 0, 0, 500, 250, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  PanelGadget(1, 10, 10, 480, 230)
  For a = 1 To 5
    AddGadgetItem(1, -1, "Panel Tab " + Str(a), 0, 0)
  Next
  CloseGadgetList()
  SendMessage_(GadgetID(1), #TCM_SETCURSEL, 1, 0) ; Value of 1 selects tab 2
  Repeat
    event = WaitWindowEvent()
    n + 1 : Debug n
  Until event = #PB_Event_CloseWindow
EndIf
Mesa
Enthusiast
Enthusiast
Posts: 345
Joined: Fri Feb 24, 2012 10:19 am

Re: Weird Flickering

Post by Mesa »

If Fred wants to debug this flickering: Everything is fine with windows xp 32b, no problem, no flickering, etc.

M.
Axolotl
Enthusiast
Enthusiast
Posts: 435
Joined: Wed Dec 31, 2008 3:36 pm

Re: Weired Flickering

Post by Axolotl »

Confirmed. I can see this flickering once after first click on Tab3 and wait.
With the help of that stuff (link below) you will see that there is WM_PAINT and some unknown messages received repeatedly.

Hint: Use one of these Identifiying Windows Events or these to see what is all about.

Changing this helps at my system:

Code: Select all

;SendMessage_(GadgetID(1), #TCM_SETCURSEL, 1, 0) ; Value of 1 selects tab 2
SetGadgetState(1, 1) ; Value of 1 selects tab 2
BTW: I always wonder about the fact that there are always WM_TIMER messages there, ...
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home
daveb
User
User
Posts: 30
Joined: Tue Jun 07, 2022 6:12 pm

Re: Weird Flickering [SOLVED]

Post by daveb »

Thanks Axolotl, that appears to be the solution.
I started out with the idea that maybe I could use SetGadgetItemState(), but that didn't work for a panel gadget item.
Thanks to everybody for your input.
Regards
Dave
Post Reply