ProgressBarGadget on Vista bug?

Just starting out? Need help? Post your questions and find answers here.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

srod wrote:srod = daft twit!
Blame it on all that pretty gloss you stare at all day long :P :lol:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Sparkie wrote:
srod wrote:srod = daft twit!
Blame it on all that pretty gloss you stare at all day long :P :lol:
Can I help it if my make-up runs? :wink:
I may look like a mule, but I'm not a complete ass.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

srod wrote:srod = daft twit!
I did think that I could of worded it better but seeing as you're a daft twit I guess I'll leave as it is. :lol:
whertz
Enthusiast
Enthusiast
Posts: 124
Joined: Sat Jun 25, 2005 2:16 pm
Location: United Kingdom

Post by whertz »

Thanks for your code srod. Can anyone confirm if this code works on other operating systems?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome.

Just tested on XP and there is a slight problem. Rather than introduce another hack though, use the following code instead which works on both XP and Vista and represents a better solution :

Code: Select all

Global oldProc, progressFlag 

Procedure progressCallback(hWnd, uMsg, wParam, lParam) 
  Protected result = CallWindowProc_(oldProc, hWnd, uMsg, wParam, lParam) 
  Static count 
  Select uMsg 
    Case #WM_TIMER 
      If wParam = 100 ;This is our timer. 
        count+1  ;A count of the number of times this timer is called consecutively. 
      Else 
        count=0 
      EndIf 
      If count = 10 ;Should be enough to determine that the 'other' timer has completed.  Increase this value if you get problems. 
        KillTimer_(hWnd, 100) 
        count = 0 
        HideGadget(0,1) 
        HideGadget(1,0) 
      EndIf 
  EndSelect 

  ProcedureReturn result 
EndProcedure 

Procedure addtolist() 
  For n2=0 To 150 
    AddGadgetItem(1,-1,Str(Random(10000))) 
  Next n2 
EndProcedure 

If OpenWindow(0, 0, 0, 600, 100, "ProgressBarGadget Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  ListIconGadget(1,10,10,580,80,"",100) 
  ProgressBarGadget(0,  10, 40, 580,  20, 0, 200)  
  oldProc = SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @progressCallback()) 
  HideGadget(1,1) 
  For n=0 To 200 
    addtolist() 
    SetGadgetState(0,n) 
  Next n 
  ;Create a timer to monitor the 'other' timer which may be running on Vista to finish rendering the progressbar etc. 
    SetTimer_(GadgetID(0), 100, 10, 0) 
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf
I may look like a mule, but I'm not a complete ass.
Post Reply