Window Title Progress

Just starting out? Need help? Post your questions and find answers here.
Nubcake
Enthusiast
Enthusiast
Posts: 195
Joined: Thu Feb 03, 2011 7:44 pm

Window Title Progress

Post by Nubcake »

Hey

Is there an api function to display the progress of something in the window ? I've seen it in Media Player Classic I just don't know if such a function exists

Image

Thanks
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Window Title Progress

Post by luis »

"Have you tried turning it off and on again ?"
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Window Title Progress

Post by charvista »

I don't understand how to do that.

Code: Select all

Win=OpenWindow(#PB_Any,100,100,800,600,"Progress Value")

Progbar=ProgressBarGadget(#PB_Any,20,20,300,25,0,100,#PB_ProgressBar_Smooth)
SetProgressState_(WindowID(Win),$00000002)

For i=0 To 100
    SetProgressValue_(WindowID(Win),i,100)
    SetGadgetState(Progbar,i)
    Delay(50)
Next
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Window Title Progress

Post by luis »

charvista wrote:I don't understand how to do that.
Those are not flat API calls.

It's for the minimized window in the taskbar, and requires the ITaskbarList3 interface, not defined in PB yet, which extends ITaskbarList2 (alread defined in PB).

Rescator already posted some sample code about how to use it (thanks).

http://www.purebasic.fr/english/viewtop ... 96#p313396
"Have you tried turning it off and on again ?"
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Window Title Progress

Post by charvista »

Very cool. Thanks Luis!
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Window Title Progress

Post by luis »

WIN 7 ONLY

This is the code I used in the past, very similar (actually I believe I copied the interfaces from Rescator's post).

Note the interface make many other methods available, just look at the docs.
In this quick example I show the SetThumbnailClip(). You can use a part of the client area of your choice as the thumbnail :shock:

Move the mouse to the minimized window in the taskbar to see the real time thumbnail.

Code: Select all

 EnableExplicit

; http://msdn.microsoft.com/en-us/library/windows/desktop/dd391692%28v=vs.85%29.aspx

Interface ITaskbarList3 Extends ITaskbarList2
 SetProgressValue.i (hWnd.i,ullCompleted.q,ullTotal.q)
 SetProgressState.i (hWnd.i,tbpFlags.l)
 RegisterTab.i (hWndTab.i,hWndMDI.i)
 UnregisterTab.i (hWndTab.i)
 SetTabOrder.i (hWndTab.i,hWndInsertBefore.i)
 SetTabActive.i (hWndTab.i,hWndMDI.i,tbatFlags.l)
 ThumbBarAddButtons.i (hWnd.i,cButtons.l,*pButton)
 ThumbBarUpdateButtons.i (hWnd.i,cButtons.l,*pButton)
 ThumbBarSetImageList.i (hWnd.i,himl.i)
 SetOverlayIcon.i (hWnd.i,hIcon.i,pszDescription$)
 SetThumbnailTooltip.i (hWnd.i,pszTip$)
 SetThumbnailClip.i (hWnd.i,*prcClip)
EndInterface

Interface ITaskbarList4 Extends ITaskbarList3
 SetTabProperties.i (hwndTab.i,stpFlags.l)
EndInterface

DataSection
 CLSID_TaskBarList:
  Data.l $56FDF344
  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

#TBPF_NOPROGRESS    = $0
#TBPF_INDETERMINATE = $1
#TBPF_NORMAL        = $2
#TBPF_ERROR         = $4
#TBPF_PAUSED        = $8

#CLSCTX_INPROC_SERVER            = $1
#CLSCTX_INPROC_HANDLER           = $2
#CLSCTX_LOCAL_SERVER             = $4
#CLSCTX_INPROC_SERVER16          = $8
#CLSCTX_REMOTE_SERVER            = $10
#CLSCTX_INPROC_HANDLER16         = $20
#CLSCTX_RESERVED1                = $40
#CLSCTX_RESERVED2                = $80
#CLSCTX_RESERVED3                = $100
#CLSCTX_RESERVED4                = $200
#CLSCTX_NO_CODE_DOWNLOAD         = $400
#CLSCTX_RESERVED5                = $800
#CLSCTX_NO_CUSTOM_MARSHAL        = $1000
#CLSCTX_ENABLE_CODE_DOWNLOAD     = $2000
#CLSCTX_NO_FAILURE_LOG           = $4000
#CLSCTX_DISABLE_AAA              = $8000
#CLSCTX_ENABLE_AAA               = $10000
#CLSCTX_FROM_DEFAULT_CONTEXT     = $20000
#CLSCTX_ACTIVATE_32_BIT_SERVER   = $40000
#CLSCTX_ACTIVATE_64_BIT_SERVER   = $80000
#CLSCTX_ENABLE_CLOAKING          = $100000
#CLSCTX_PS_DLL                   = $80000000

Procedure.i Create_TaskbarList3()
 Protected *tl3.ITaskbarList3
 CoInitialize_(#Null)
 CoCreateInstance_ (?CLSID_TaskBarList,#Null,#CLSCTX_INPROC_SERVER,?IID_ITaskBarList3,@*tl3)
 ProcedureReturn *tl3
EndProcedure

Procedure.i Destroy_TaskbarList3 (*tl3.ITaskbarList3)
 If *tl3
    *tl3\Release()
 EndIf
 CoUninitialize_()
EndProcedure

Enumeration
 #WIN_MAIN
EndEnumeration

Procedure Main()
 Protected iEvent, pct, rec.RECT
 Protected *tl3.ITaskbarList3
 
 If OpenWindow(#WIN_MAIN, 0, 0, 300, 150, "", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
   
    ProgressBarGadget(1, 10,10, 280, 130, 0, 100)
   
    *tl3 = Create_TaskbarList3()
    *tl3\HrInit()
    *tl3\SetProgressValue(WindowID(#WIN_MAIN),0,100)
    *tl3\SetProgressState(WindowID(#WIN_MAIN), #TBPF_NORMAL)
       
    ; move the mouse to the minimized window in the taskbar to see the real time thumbnail
    GetClientRect_(WindowID(#WIN_MAIN), @rec)
    rec\right / 2 ; only half of the client area :-]
    rec\bottom/ 2 ; only half of the client area :-]
    *tl3\SetThumbnailClip(WindowID(#WIN_MAIN), @rec)
 
    Repeat
        iEvent = WindowEvent()
       
        If iEvent = 0
            If pct = 101
                SetWindowTitle(#WIN_MAIN, "Red (ERROR)")
                *tl3\SetProgressState(WindowID(#WIN_MAIN), #TBPF_ERROR)
            Else                     
                SetWindowTitle(#WIN_MAIN, "1/" + Str(pct))
                SetGadgetState(1, pct)
                *tl3\SetProgressValue(WindowID(#WIN_MAIN),pct,100)   
                pct + 1
            EndIf
            Delay(100)
        EndIf       

    Until iEvent = #PB_Event_CloseWindow
   
 EndIf
 
 Destroy_TaskbarList3 (*tl3)
 
EndProcedure


Main()
Last edited by luis on Mon Mar 11, 2013 8:42 pm, edited 1 time in total.
"Have you tried turning it off and on again ?"
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Window Title Progress

Post by charvista »

@Luis
Move the mouse to the minimized window in the taskbar to see the real time thumbnail.
Super! it works like a charm!
I played around and I think that the clip is nicer that way, as it shows only the progressbar, without white border:

Code: Select all

        ; move the mouse to the minimized window in the taskbar to see the real time thumbnail
        GetClientRect_(WindowID(#WIN_MAIN), @rec)
        rec\left+10 ; exact region of the progressbar
        rec\top+10
        rec\right-20
        rec\bottom-20
        *tl3\SetThumbnailClip(WindowID(#WIN_MAIN), @rec)
     
:wink:
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: Window Title Progress

Post by BarryG »

luis wrote: Sun Mar 04, 2012 10:39 pmWIN 7 ONLY
Works fine on Win 10 for me. :)

Luis, is there a way to GET the progress state of a third-party window? So I can tell if that window is still "busy", like to know when Media Player Classic has finished playing a movie (as an example).
Post Reply