Page 2 of 2

Posted: Thu Aug 28, 2008 4:09 pm
by Sparkie
srod wrote:srod = daft twit!
Blame it on all that pretty gloss you stare at all day long :P :lol:

Posted: Thu Aug 28, 2008 4:10 pm
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:

Posted: Thu Aug 28, 2008 4:24 pm
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:

Posted: Fri Aug 29, 2008 7:48 pm
by whertz
Thanks for your code srod. Can anyone confirm if this code works on other operating systems?

Posted: Fri Aug 29, 2008 9:19 pm
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