Progression de lecture

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
SPH
Messages : 4942
Inscription : mer. 09/nov./2005 9:53

Progression de lecture

Message par SPH »

Salut,

il y a des applications qui "affichent" leur progression dans la barre de lancement rapide de windows.
Regardez ça :
http://xmas.free.fr/pourcentage.jpg

Ici, il y a AIMP (un lecteur de MP3) qui affiche la progression de la lecture (ici, environ 10%)
Cela est il possible dans PB ?

Thx 😘

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Avatar de l’utilisateur
GallyHC
Messages : 1708
Inscription : lun. 17/déc./2007 12:44

Re: Progression de lecture

Message par GallyHC »

Bonjour SPH,

Oui cela est possible :

Code : Tout sélectionner

DisableASM
CompilerIf #PB_Compiler_EnableExplicit
  EnableExplicit
CompilerEndIf

DeclareModule Windows
  
  Declare TaskBarProgressInit         (hWnd.i, State.i)
  Declare TaskBarProgressValue        (hWnd.i, Value.q, Total.q)
  
  #tbpf_noprogress                    = $0
  #tbpf_indeterminate                 = $1
  #tbpf_normal                        = $2
  #tbpf_error                         = $4
  #tbpf_paused                        = $8
  
EndDeclareModule 

Module Windows 

  DisableASM
  CompilerIf #PB_Compiler_EnableExplicit
    EnableExplicit
  CompilerEndIf

  Procedure TaskBarProgressInit(hWnd.i, State.i)
    
    Interface ITaskbarList3 Extends ITaskbarList2 
      SetProgressValue      (hWnd, ullCompleted.q, ullTotal.q) 
      SetProgressState      (hWnd, tbpFlags.l) 
      RegisterTab           (hWndTab, hWndMDI) 
      UnregisterTab         (hWndTab) 
      SetTabOrder           (hWndTab, hWndInsertBefore) 
      SetTabActive          (hWndTab, hWndMDI, dwreserved.l) 
      ThumbBarAddButtons    (hWnd, cButtons.l, *pButton ) 
      ThumbBarUpdateButtons (hWnd, cButtons.l, *pButton) 
      ThumbBarSetImageList  (hWnd, himl) 
      SetOverlayIcon        (hWnd, hIcon, pszDescription.p-bstr) 
      SetThumbnailTooltip   (hWnd, pszTip.p-bstr) 
      SetThumbnailClip      (hWnd, *prcClip.RECT) 
    EndInterface 
    
    Protected TBL.ITaskbarList3
    If OSVersion() >= #PB_OS_Windows_7
      CoInitialize_(0)
      If CoCreateInstance_(?CLSID_TaskBarList, 0, 1, ?IID_ITaskBarList3, @TBL) = #S_OK
        TBL\HrInit()
        TBL\SetProgressState(hWnd, State)
        TBL\Release()
      EndIf
      CoUninitialize_()
    EndIf
  
  EndProcedure
  
  Procedure TaskBarProgressValue(hWnd.i, Value.q, Total.q)
    
    Protected TBL.ITaskbarList3
    If OSVersion() >= #PB_OS_Windows_7
      CoInitialize_(0)
      If CoCreateInstance_(?CLSID_TaskBarList, 0, 1, ?IID_ITaskBarList3, @TBL) = #S_OK
        TBL\HrInit()
        TBL\SetProgressValue(hWnd, Value, Total)
        TBL\Release()
      EndIf
      CoUninitialize_()
    EndIf
  
  EndProcedure
  
  DataSection
    CLSID_TaskBarList:
    Data.l $56FDF344
    Data.w $FD6D, $11D0
    Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
    IID_ITaskBarList:
    Data.l $56FDF342
    Data.w $FD6D, $11D0
    Data.b $95, $8A, $00, $60, $97, $C9, $A0, $90
    IID_ITaskBarList3:
    Data.l $EA1AFB91
    Data.w $9E28, $4B86
    Data.b $90, $E9, $9E, $9F, $8A, $5E, $EF, $AF
  EndDataSection

EndModule 



CompilerIf #PB_Compiler_IsMainFile 
  
  OpenWindow   (0, 0, 0, 800, 600, "Progress TaskBar", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  Define.i event, i, j = 1
  Windows::TaskBarProgressInit(WindowID(0), Windows::#tbpf_normal)
  Repeat
    event = WaitWindowEvent(10)
    i + j
    If i < 1
      j = 1
    EndIf
    If i > 99
      j = -1
    EndIf
    Windows::TaskBarProgressValue(WindowID(0), i, 100)
  Until event = #PB_Event_CloseWindow

CompilerEndIf 

Cordialement,
GallyHC
Configuration : Tower: Windows 10 (Processeur: i7 "x64") (Mémoire: 16Go) (GeForce GTX 760 - 2Go) - PureBasic 5.72 (x86 et x64)
Avatar de l’utilisateur
SPH
Messages : 4942
Inscription : mer. 09/nov./2005 9:53

Re: Progression de lecture

Message par SPH »

Merci Gally ! 8) 8)

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Répondre