DroopyLib

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

I'll be back from holidays. 8)
Look @ this quickly :wink:
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post 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:
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

UserLibUnicodeThreadSafe you didnt fixed? and do not forget Break!

Image

:evil:
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: DroopyLib

Post 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.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post by Droopy »

Hello, try setting compiler options 'Create unicode executable'
Break is already added in GetPidProcess().
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post 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.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: DroopyLib

Post 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 :!:
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

thanks.
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: DroopyLib

Post 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 ;)
Last edited by Bisonte on Thu Aug 02, 2012 11:15 pm, edited 2 times in total.
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post 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
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: DroopyLib

Post by Bisonte »

Why you delete the Timer Procs ?

With AddWindowTimer() you can't add a callback ;)
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post 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 
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: DroopyLib

Post 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
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Re: DroopyLib

Post 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:
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: DroopyLib

Post 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)
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
Post Reply