Page 6 of 13

Re: DroopyLib

Posted: Sat Jul 28, 2012 7:44 pm
by Droopy
I'll be back from holidays. 8)
Look @ this quickly :wink:

Re: DroopyLib

Posted: Mon Jul 30, 2012 3:05 pm
by Droopy
30/07/12 : Library 4.61.006
String2Unicode() added
Unicode2String() added
WMI() Unicode bug fixed by ABBKlaus
GuidAPI() Unicode bug fixed
NetUserEnum() Unicode bug fixed
NetLocalGroupEnum() NetLocalGroupEnum()
MozillaVersion() added
A special thansk to ABBKlaus :wink:

Re: DroopyLib

Posted: Mon Jul 30, 2012 10:50 pm
by SeregaZ
UserLibUnicodeThreadSafe you didnt fixed? and do not forget Break!

Image

:evil:

Re: DroopyLib

Posted: Mon Jul 30, 2012 10:59 pm
by ABBKlaus
SeregaZ wrote:UserLibUnicodeThreadSafe you didnt fixed? and do not forget Break!
:evil:
its compiled in multilib-mode, no need to specify a library subsystem.

Re: DroopyLib

Posted: Mon Jul 30, 2012 11:11 pm
by Droopy
Hello, try setting compiler options 'Create unicode executable'
Break is already added in GetPidProcess().

Re: DroopyLib

Posted: Wed Aug 01, 2012 1:00 am
by SeregaZ
ABBKlaus wrote: its compiled in multilib-mode, no need to specify a library subsystem.
are you sure? in old 4.30 with old droopy and another libraries this Library Subsystem field in options was necessary.

Re: DroopyLib

Posted: Wed Aug 01, 2012 6:14 am
by ABBKlaus
SeregaZ wrote:are you sure? in old 4.30 with old droopy and another libraries this Library Subsystem field in options was necessary.
Yes. Its not needed anymore, all four modes are now inside the lib in the Userlibraries folder. Thats why you have to delete the old droopy libs in the subsystem folder(s) otherwise the old libs get priority :!:

Re: DroopyLib

Posted: Wed Aug 01, 2012 10:16 am
by SeregaZ
thanks.

Re: DroopyLib

Posted: Wed Aug 01, 2012 11:59 am
by Bisonte
Hi Droopy, may here a little bugfix...

Code: Select all

; These procedures are wrong. You use a fixed Window...

ProcedureDLL Timer(TimerId,Delay,ProcedureAdress) ; Create a Timer which calls a Procedure
  ;// Delay is in Ms
  SetTimer_(WindowID(0),TimerId,Delay,ProcedureAdress)
EndProcedure

ProcedureDLL TimerKill(TimerId) ; Kill the Timer specified by Timerid
  KillTimer_(WindowID(0),TimerId)
EndProcedure

; This procedures have an extra parameter and a check if the window exists
; also its equal if 'Window' is a PB-Object No. or the OS-Handle
; and they return #True if they sucess

ProcedureDLL Timer(Window, TimerID, msDelay, ProcedureAdress)
  
  Protected Result = #False
  Protected hWnd = #False
  
  If IsWindow_(Window)
    hWnd = Window
  Else
    hWnd = WindowID(Window)
  EndIf
  
  If hWnd
    SetTimer_(hWnd, TimerID, msDelay, ProcedureAdress)
    Result = #True  
  EndIf
  
  ProcedureReturn Result
  
EndProcedure
ProcedureDLL KillTimer(Window, TimerID)
  
  Protected Result = #False
  Protected hWnd = #False
  
  If IsWindow_(Window)
    hWnd = Window
  Else
    hWnd = WindowID(Window)
  EndIf
  
  If hWnd
    KillTimer_(hWnd,TimerID)
    Result = #True  
  EndIf
  
  ProcedureReturn Result
  
EndProcedure
Edit : Replaced : If IsWindow(hWnd) to If hWnd ... my mistake ;)

Re: DroopyLib

Posted: Thu Aug 02, 2012 9:36 pm
by Droopy
Thanks Bisonte for helping debugging the library :wink:
02/08/12 : Library 4.61.007
Timer() deleted (replaced by PureBasic function AddWindowTimer())
TimerKill() deleted (replaced by PureBasic function RemoveWindowTimer())
SetProxy() added

Re: DroopyLib

Posted: Thu Aug 02, 2012 11:17 pm
by Bisonte
Why you delete the Timer Procs ?

With AddWindowTimer() you can't add a callback ;)

Re: DroopyLib

Posted: Fri Aug 03, 2012 8:07 am
by Droopy
I delete these functions because AddWindowTimer() could create timer easily.
Could you explain why SetTimer_ with callback is an advantage over AddWindowTimer() ?

Code: Select all

Enumeration
  #LabelListView
  #LabelListIcon
  #LabelEditor
  #ListView
  #ListIcon
  #Editor
EndEnumeration

OpenWindow(0,0,0,340,200,"PureBasic AutoScroll Gadget Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TextGadget(#LabelListView,10,10,100,20,"ListView")
TextGadget(#LabelListIcon,120,10,100,20,"ListIcon")
TextGadget(#LabelEditor,230,10,100,20,"Editor")
ListViewGadget(#ListView,10,30,100,150)
ListIconGadget(#ListIcon,120,30,100,150,"Test",70) 
EditorGadget(#Editor,230,30,100,150) 

AddWindowTimer(0,123,50)

Repeat 
  evt=WaitWindowEvent()  
  
  If evt= #PB_Event_Timer And EventTimer()=123
    AddGadgetItem(#ListView,-1,Str(Compteur))
    AddGadgetItem(#ListIcon,-1,Str(Compteur))
    AddGadgetItem(#Editor,-1,Str(Compteur))
    SetGadgetState(#ListView,CountGadgetItems(#ListView)-1)                                   ;/ ListView
    SendMessage_(GadgetID(#ListIcon),#LVM_ENSUREVISIBLE,CountGadgetItems(#ListIcon)-1,#True)  ;/ ListIcon
    SendMessage_(GadgetID(#Editor), #EM_SCROLLCARET, #False,#False)                           ;/ EditorGadget
    Compteur+1
  EndIf
Until evt=#PB_Event_CloseWindow 

Re: DroopyLib

Posted: Fri Aug 03, 2012 1:00 pm
by Bisonte
The advantage....

In your example... if you click on a slider, all stops, and continue if you release the mousebutton.
With callback, nothing stops...

and the code of an eventloop can look clearer ;)

Code: Select all

Enumeration
  #LabelListView
  #LabelListIcon
  #LabelEditor
  #ListView
  #ListIcon
  #Editor
EndEnumeration

Procedure TimerCallBack(hWnd, uMsg, TimerID, Elapsedms)
  
  Static Compteur
  
  If TimerID = 123
    AddGadgetItem(#ListView,-1,Str(Compteur))
    AddGadgetItem(#ListIcon,-1,Str(Compteur))
    AddGadgetItem(#Editor,-1,Str(Compteur))
    SetGadgetState(#ListView,CountGadgetItems(#ListView)-1)                                   ;/ ListView
    SendMessage_(GadgetID(#ListIcon),#LVM_ENSUREVISIBLE,CountGadgetItems(#ListIcon)-1,#True)  ;/ ListIcon
    SendMessage_(GadgetID(#Editor), #EM_SCROLLCARET, #False,#False)                           ;/ EditorGadget
    Compteur+1   
    If Compteur >= 100 ; Stops the Timer if it reached 100 times of execution
      KillTimer_(hWnd, TimerID)
    EndIf
  EndIf
  
EndProcedure

OpenWindow(0,0,0,340,200,"PureBasic AutoScroll Gadget Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TextGadget(#LabelListView,10,10,100,20,"ListView")
TextGadget(#LabelListIcon,120,10,100,20,"ListIcon")
TextGadget(#LabelEditor,230,10,100,20,"Editor")
ListViewGadget(#ListView,10,30,100,150)
ListIconGadget(#ListIcon,120,30,100,150,"Test",70)
EditorGadget(#Editor,230,30,100,150)

;AddWindowTimer(0,123,50)
SetTimer_(WindowID(0), 123, 50, @TimerCallBack())

Repeat
  evt=WaitWindowEvent() 
  
  ; No Code cause its in the Callback

Until evt=#PB_Event_CloseWindow

Re: DroopyLib

Posted: Fri Aug 03, 2012 3:47 pm
by Droopy
Hello Bisonte

What do you think about an example mixing callback and functions ?

Code: Select all

ProcedureDLL Timer(Window, TimerID, msDelay, ProcedureAdress)
  
  Protected Result = #False
  Protected hWnd = #False
  
  If IsWindow_(Window)
    hWnd = Window
  Else
    hWnd = WindowID(Window)
  EndIf
  
  If hWnd
    SetTimer_(hWnd, TimerID, msDelay, ProcedureAdress)
    Result = #True  
  EndIf
  
  ProcedureReturn Result
  
EndProcedure

ProcedureDLL TimerKill(Window, TimerID)
  
  Protected Result = #False
  Protected hWnd = #False
  
  If IsWindow_(Window)
    hWnd = Window
  Else
    hWnd = WindowID(Window)
  EndIf
  
  If hWnd
    KillTimer_(hWnd,TimerID)
    Result = #True  
  EndIf
  
  ProcedureReturn Result
  
EndProcedure

Procedure Timer1() ; First ProgressBarGadget
  SetGadgetState(0,GetGadgetState(0)+1)
  beep_(700,100)
EndProcedure

Procedure TimerCallBack(hWnd,uMsg,TimerID,Elapsedms)
  
  Static Compteur
  
  If TimerID = 2
    SetGadgetState(1,GetGadgetState(1)+1)
    beep_(1000,100)
  EndIf
  
EndProcedure

Procedure Timer3()
  SetGadgetText(2,"Timer 3 Kill Timer 1 and 2")
  TimerKill(0,1) ;/ Kill Timer #1
  TimerKill(0,2) ;/ Kill Timer #2
  beep_(1500,500)
  TimerKill(0,3)
EndProcedure

OpenWindow(0,0,0,230,120,"API Timers with Callback",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ProgressBarGadget(0,10,10,210,30,0,65,#PB_ProgressBar_Smooth)
ProgressBarGadget(1,10,45,210,30,0,9,#PB_ProgressBar_Smooth)
SetGadgetState(0,0)
SetGadgetState(1,0)
TextGadget(2,10,80,210,30,"Timer 1/2/3 Started",#PB_Text_Center)

;/ Starting Timers
Timer(0,1,150,@Timer1())   ; Timer #1 each 150 ms
Timer(0,2,1000,@TimerCallBack()) ; Timer managed in a callback
Timer(0,3,10000,@Timer3()) ; Timer #3 each 10 seconds

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
I don't understand Elapsedms parameter :oops:

Re: DroopyLib

Posted: Fri Aug 03, 2012 10:04 pm
by Bisonte
Droopy wrote:Hello Bisonte

What do you think about an example mixing callback and functions ?
So you think your "Timer" is necessary ;)
Droopy wrote:I don't understand Elapsedms parameter :oops:
see : http://msdn.microsoft.com/en-us/library ... 85%29.aspx

ok the right names for the parameters are :

TimerProc(hWnd, uMsg, idEvent, dwTime)

Additional you can make the "ProcedureAdress" Parameter optional with Timer(Window, TimerID, TimeOut, ProcedureAdress= #Null)