Fill a ScrollAreaGadget without flickering?

Just starting out? Need help? Post your questions and find answers here.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Fill a ScrollAreaGadget without flickering?

Post by srod »

In which case Lebostein should just replace the text rather than repopulating every time.

Code: Select all

Procedure Rebuild()
  hWnd = GetParent_(GadgetID(#start_combo))
  SendMessage_(hWnd,#WM_SETREDRAW,#False,0)          ; <======================
  For line = 0 To #maxline
    SendMessage_(GadgetID(#start_combo + line),#WM_SETREDRAW,#False,0)
      For item = 0 To #max_item
        SetGadgetItemText(#start_combo + line, item, "Blablablup " + Str(item))
      Next
    SendMessage_(GadgetID(#start_combo + line),#WM_SETREDRAW,#True,0)           ; <##########################
    SetGadgetState(#start_combo + line, Random(#max_item))
  Next  

SendMessage_(hWnd,#WM_SETREDRAW,#True,0)                   ; <======================
RedrawWindow_(hWnd,#Null,#Null,#RDW_INVALIDATE)            ; <======================
EndProcedure

If OpenWindow(0, 0, 0, 405, 470, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ScrollAreaGadget(0, 10, 10, 390,420, 575, 555, 30)
    For line = 0 To #maxline
      ComboBoxGadget(#start_combo + line, 10, 10 + line * 25, 230, 22)
      For item = 0 To #max_item
        AddGadgetItem(#start_combo + line, item, "Blablablup " + Str(item))
      Next
      StringGadget(#start_string + line, 250, 10 + line * 25, 80, 22, "")
    Next
  CloseGadgetList()
  ButtonGadget(1, 10, 430, 390,30, "Refresh")

   Repeat
      Select WaitWindowEvent()
         Case  #PB_Event_CloseWindow
            End
         Case  #PB_Event_Gadget
            Select EventGadget()
               Case 1: Rebuild()
            EndSelect
      EndSelect
   ForEver
EndIf
I may look like a mule, but I'm not a complete ass.
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: Fill a ScrollAreaGadget without flickering?

Post by PureLust »

@Lebostein: I've changed your original code to use [ComboBoxEx] from Thorsten1867 and ended up with ~19-20 ms.

So ... maybe worth to give it a try?
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Re: Fill a ScrollAreaGadget without flickering?

Post by Lebostein »

PureLust wrote:@Lebostein: I've changed your original code to use [ComboBoxEx] from Thorsten1867 and ended up with ~19-20 ms.

So ... maybe worth to give it a try?
Sounds interesting. Thanks.
SeregaZ
Enthusiast
Enthusiast
Posts: 617
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: Fill a ScrollAreaGadget without flickering?

Post by SeregaZ »

i have a question - how to correct use UseGadgetList() ?

i have some gadgets, and when i select them - it selected by paint FrameGadget over it. it some kind of select. so i have not enough space and start to think use ScrollArea gadget. i paint that ScrollArea with all gadgets, what it need, then i want to by some events - remove old select and paint new one. but that UseGadgetList() not work :( new FrameGadget paint under ScrollArea, but not over it.

Code: Select all

Enumeration
  #Window
  #ScrollArea
  #FrameSelect
  #Button
EndEnumeration

If OpenWindow(#Window, 100, 100, 300, 400, "TEST", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
  
  ScrollAreaGadget(#ScrollArea, 10, 10, 280, 300, 260, 740)
    FrameGadget(#FrameSelect, 10, 10, 236, 24, "", #PB_Frame_Flat)
    CloseGadgetList()
    
  ButtonGadget(#Button, 10, 350, 50, 20, "add")
  
  ;SmartWindowRefresh(#Window, 1) 
  
  Repeat
    Select WaitWindowEvent()
        
      Case #PB_Event_Gadget
        If EventGadget() = #Button
          UseGadgetList(GadgetID(#ScrollArea))
          If IsGadget(#FrameSelect)
            FreeGadget(#FrameSelect)
          EndIf
          FrameGadget(#FrameSelect, 10, 50, 236, 24, "", #PB_Frame_Flat)
        EndIf

       Case #PB_Event_CloseWindow
         qiut = 1
   
     EndSelect
   Until qiut = 1

EndIf

End
User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Fill a ScrollAreaGadget without flickering?

Post by ChrisR »

It works without problems with Open(Close)GadgetList
Although I don't understand why you delete the Frame and then recreate it (ResizeGadget)!

Code: Select all

Enumeration
  #Window
  #ScrollArea
  #FrameSelect
  #Button
EndEnumeration

If OpenWindow(#Window, 100, 100, 300, 400, "TEST", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
  
  ScrollAreaGadget(#ScrollArea, 10, 10, 280, 300, 260, 740)
    FrameGadget(#FrameSelect, 10, 10, 236, 24, "", #PB_Frame_Flat)
    CloseGadgetList()
    
  ButtonGadget(#Button, 10, 350, 50, 20, "add")
  
  ;SmartWindowRefresh(#Window, 1) 
  
  Repeat
    Select WaitWindowEvent()
        
      Case #PB_Event_Gadget
        If EventGadget() = #Button
          Y = GadgetY(#FrameSelect)
          OpenGadgetList(#ScrollArea)   ;UseGadgetList(GadgetID(#ScrollArea))
          If IsGadget(#FrameSelect)
            FreeGadget(#FrameSelect)
          EndIf
          FrameGadget(#FrameSelect, 10, Y+20, 236, 24, "", #PB_Frame_Flat)
          CloseGadgetList()
        EndIf

       Case #PB_Event_CloseWindow
         quit = 1
   
     EndSelect
   Until quit = 1

EndIf

End
SeregaZ
Enthusiast
Enthusiast
Posts: 617
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: Fill a ScrollAreaGadget without flickering?

Post by SeregaZ »

it is select. when i click on some gadget of the window - that frame is appear, to show select. so old one is need to delete. that is why i remove old and paint new select over gadget, that i select. thanks a lot.
Post Reply