Results 1 to 13 of 13

Thread: ITaskbarList No tlb?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    ITaskbarList No tlb?

    Hello I am trying to pass the calls of ITaskbarList meditating CoCreateInstance + DispCallFunc etc etc, a bit for learning a bit more to not use the tlb, but apparently I have not been able to start I try to make some calls but I only get errors.

    Will my statements be correct?
    Private Const SetProgressValue As Long = 1
    Private Const SetProgressState As Long = 2

    Code:
    Option Explicit
    Private Declare Function CLSIDFromString Lib "ole32" (ByVal str As Long, ID As Any) As Long
    Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
    Private Declare Function CoCreateInstance Lib "ole32" (ByVal rclsid As Long, ByVal pUnkOuter As Long, ByVal dwClsContext As Long, ByVal riid As Long, ByRef ppv As Long) As Long
    Private Declare Function DispCallFunc Lib "oleaut32" (ByVal pvInstance As Long, ByVal oVft As Long, ByVal lCc As Long, ByVal vtReturn As VbVarType, ByVal cActuals As Long, prgVt As Any, prgpVarg As Any, pvargResult As Variant) As Long
    
    Private Type GUID
        Data1 As Long
        Data2 As Integer
        Data3 As Integer
        Data4(0 To 7) As Byte
    End Type
    
    Private Const CLSID_TaskbarList As String = "{56FDF344-FD6D-11d0-958A-006097C9A090}"
    Private Const IID_ITaskbarList2 As String = "{602D4995-B13A-429b-A66E-1935E44F4317}"
    Private Const IID_ITaskbarList3 As String = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}"
    Private Const CLSID_TaskbarList3 As String = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}"
    Private Const CLSID_TaskbarList4 As String = "{C43DC798-95D1-4BEA-9030-BB99E2983A1A}"
    
    Private Const CLSCTX_INPROC_SERVER      As Long = 1
    Private Const CC_STDCALL As Long = &H4&
    Private Const SetProgressValue As Long = 1
    Private Const SetProgressState As Long = 2
    Private Const TBPF_NORMAL As Long = 2
    Private Const crProgressMax As Currency = 100
    Private crProgress As Currency
    
    
    Public Sub TEST()
        Dim IID As GUID
        Dim CLSID As GUID
        Dim rc As Long
        Dim iTaskBarVB2 As Long
        
        rc = CLSIDFromString(StrPtr(CLSID_TaskbarList), CLSID)
        rc = CLSIDFromString(StrPtr(CLSID_TaskbarList3), IID)
        rc = CoCreateInstance(VarPtr(CLSID), 0&, CLSCTX_INPROC_SERVER, VarPtr(IID), iTaskBarVB2)
        
        Call DispCallByVtbl(iTaskBarVB2, SetProgressState, Form1.hWnd, TBPF_NORMAL)
          
        crProgress = 50
        Call DispCallByVtbl(iTaskBarVB2, SetProgressValue, Form1.hWnd, crProgress, crProgressMax)
    End Sub
    
    Private Function DispCallByVtbl(pUnk As Long, ByVal lIndex As Long, ParamArray A() As Variant) As Variant
        Dim lIdx            As Long
        Dim vParam()        As Variant
        Dim vType(0 To 63)  As Integer
        Dim vPtr(0 To 63)   As Long
        Dim hResult         As Long
        
        vParam = A
        For lIdx = 0 To UBound(vParam)
            vType(lIdx) = VarType(vParam(lIdx))
            vPtr(lIdx) = VarPtr(vParam(lIdx))
        Next
        hResult = DispCallFunc(pUnk, lIndex * 4, CC_STDCALL, vbLong, lIdx, vType(0), vPtr(0), DispCallByVtbl)
        If hResult < 0 Then
            Err.Raise hResult, "DispCallFunc"
        End If
    End Function
    leandroascierto.com Visual Basic 6 projects

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,192

    Re: ITaskbarList No tlb?

    SetProgressValue and SetProgressState indexes are wrong. Here is the relevant IDL from ShObjIdl.idl so you can count yourself the methods before SetProgressValue.

    Code:
    [
        uuid(56FDF342-FD6D-11d0-958A-006097C9A090),
        object,
    ]
    interface ITaskbarList : IUnknown
    {
        HRESULT HrInit();
    
        HRESULT AddTab([in] HWND hwnd);
    
        HRESULT DeleteTab([in] HWND hwnd);
    
        HRESULT ActivateTab([in] HWND hwnd);
    
        HRESULT SetActiveAlt([in] HWND hwnd);
    }
    
    [
        uuid(602D4995-B13A-429b-A66E-1935E44F4317),
        object,
    ]
    interface ITaskbarList2 : ITaskbarList
    {
        HRESULT MarkFullscreenWindow(
            [in] HWND hwnd,
            [in] BOOL fFullscreen);
    }
    
    [
        uuid(ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf),
        object,
    ]
    interface ITaskbarList3 : ITaskbarList2
    {
        // Flags for Setting Taskbar Progress state
        typedef [v1_enum] enum TBPFLAG
        {
            TBPF_NOPROGRESS     = 0x00000000,
            TBPF_INDETERMINATE  = 0x00000001,
            TBPF_NORMAL         = 0x00000002,
            TBPF_ERROR          = 0x00000004,
            TBPF_PAUSED         = 0x00000008,
        } TBPFLAG;
        cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(TBPFLAG)")
    
        HRESULT SetProgressValue(
            [in] HWND hwnd,
            [in] ULONGLONG ullCompleted,
            [in] ULONGLONG ullTotal);
    
        HRESULT SetProgressState(
            [in] HWND hwnd,
            [in] TBPFLAG tbpFlags);
    
        HRESULT RegisterTab(
            [in] HWND hwndTab,
            [in] HWND hwndMDI);
    
        HRESULT UnregisterTab(
            [in] HWND hwndTab);
    
        HRESULT SetTabOrder(
            [in] HWND hwndTab,
            [in] HWND hwndInsertBefore);
    
        HRESULT SetTabActive(
            [in] HWND hwndTab,
            [in] HWND hwndMDI,
            [in] DWORD dwReserved);
    
        HRESULT ThumbBarAddButtons(
            [in] HWND hwnd,
            [in] UINT cButtons,
            [in, size_is(cButtons)] LPTHUMBBUTTON pButton);
    
        HRESULT ThumbBarUpdateButtons(
            [in] HWND hwnd,
            [in] UINT cButtons,
            [in, size_is(cButtons)] LPTHUMBBUTTON pButton);
    
        HRESULT ThumbBarSetImageList(
            [in] HWND hwnd,
            [in] HIMAGELIST himl);
    
        HRESULT SetOverlayIcon(
            [in] HWND hwnd,
            [in] HICON hIcon,
            [in, unique, string] LPCWSTR pszDescription);
    
        HRESULT SetThumbnailTooltip(
            [in] HWND hwnd,
            [in, unique, string] LPCWSTR pszTip);
    
        HRESULT SetThumbnailClip(
            [in] HWND hwnd,
            [in] RECT *prcClip);
    }
    
    [
        uuid(c43dc798-95d1-4bea-9030-bb99e2983a1a),
        object,
    ]
    interface ITaskbarList4 : ITaskbarList3
    {
        // Flags for Setting Tab Properties
        typedef [v1_enum] enum STPFLAG
        {
            STPF_NONE                       = 0x00000000,
            STPF_USEAPPTHUMBNAILALWAYS      = 0x00000001,
            STPF_USEAPPTHUMBNAILWHENACTIVE  = 0x00000002,
            STPF_USEAPPPEEKALWAYS           = 0x00000004,
            STPF_USEAPPPEEKWHENACTIVE       = 0x00000008,
        } STPFLAG;
        cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(STPFLAG)")
    
        HRESULT SetTabProperties(
            [in] HWND hwndTab,
            [in] STPFLAG stpFlags);
    }
    SetProgressValue must be index 9 in the vtable because there there are 3 methods in the grand-parent IUnknown interface (not shown here) and 6 methods before it in the chain of ITaskbarListXxx interfaces.

    cheers,
    </wqw>

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    Re: ITaskbarList No tlb?

    perfect!!, thank you very much, could you explain me better how I count, I always have that problem to find the ordinal

    this is the TaskBar.idl by the Trick
    Code:
    [
       uuid(683BF642-E9CA-4124-BE43-67065B2FA655),
       version(1.0),
    ]
    library TaskbarLib
    {
    [
            uuid(56FDF342-FD6D-11d0-958A-006097C9A090),
            object,
    ]
    interface ITaskbarList : IUnknown 
    {
            HRESULT _stdcall HrInit();
            
            HRESULT _stdcall AddTab([in] long hwnd);
            
            HRESULT _stdcall DeleteTab([in] long hwnd);
            
            HRESULT _stdcall ActivateTab([in] long hwnd);
            
            HRESULT _stdcall SetActivateAlt([in] long hwnd);
    };
    
    [
            uuid(602D4995-B13A-429b-A66E-1935E44F4317),
            object,
    ]
    interface ITaskbarList2 : ITaskbarList
    {
            HRESULT MarkFullscreenWindow(
                    [in] long hwnd,
                    [in] BOOL fFullscreen);
    }
    
    cpp_quote("#ifdef MIDL_PASS")
    typedef IUnknown* HIMAGELIST;
    typedef IUNknown* HICON;
    cpp_quote("#endif")
    
    cpp_quote("#include <pshpack8.h>")
    typedef struct tagTHUMBBUTTON
    {
            DWORD   dwMask;
            UINT    iId;
            UINT    iBitmap;
            HICON   hIcon;
            WCHAR   szTip[260];
            DWORD   dwFlags;
    } THUMBBUTTON, *LPTHUMBBUTTON;
    cpp_quote("#include <poppack.h>")
    
    [
            uuid(ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf),
            object,
    ]
    interface ITaskbarList3 : ITaskbarList2
    {
            // Flags for Setting Taskbar Progress state
            typedef [v1_enum] enum TBPFLAG
            {
                    TBPF_NOPROGRESS  = 0x00000000,
                    TBPF_INDETERMINATE  = 0x00000001,
                    TBPF_NORMAL              = 0x00000002,
                    TBPF_ERROR                = 0x00000004,
                    TBPF_PAUSED              = 0x00000008,
            } TBPFLAG;
    
            cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(TBPFLAG)")
    
            // Flags for SetTabActive
            typedef [v1_enum] enum TBATFLAG
            {
                    TBATF_USEMDITHUMBNAIL   = 0x00000001,
                    TBATF_USEMDILIVEPREVIEW = 0x00000002,
            } TBATFLAG;
    
            cpp_quote("DEFINE_ENUM_FLAG_OPERATORS(TBATFLAG)")
    
            HRESULT SetProgressValue(
                    [in] long hwnd,
                    [in] CURRENCY ullCompleted,
                    [in] CURRENCY ullTotal);
    
            HRESULT SetProgressState(
                    [in] long hwnd,
                    [in] TBPFLAG tbpFlags);
    
            HRESULT RegisterTab(
                    [in] long hwndTab,
                    [in] HWND hwndMDI);
    
            HRESULT UnregisterTab(
                    [in] long hwndTab);
    
            HRESULT SetTabOrder(
                    [in] long hwndTab,
                    [in] long hwndInsertBefore);
    
            HRESULT SetTabActive(
                    [in] long hwndTab,
                    [in] long hwndMDI,
                    [in] TBATFLAG tbatFlags);
    
            HRESULT ThumbBarAddButtons(
                    [in] long hwnd,
                    [in] UINT cButtons,
                    [in, size_is(cButtons)] LPTHUMBBUTTON pButton);
    
            HRESULT ThumbBarUpdateButtons(
                    [in] long hwnd,
                    [in] UINT cButtons,
                    [in, size_is(cButtons)] LPTHUMBBUTTON pButton);
    
            HRESULT ThumbBarSetImageList(
                    [in] long hwnd,
                    [in] HIMAGELIST himl);
    
            HRESULT SetOverlayIcon(
                    [in] long hwnd, 
                    [in] HICON hIcon,
                    [in, string] LPCWSTR pszDescription);
    
            HRESULT SetThumbnailTooltip(
                    [in] long hwnd, 
                    [in, string] LPCWSTR pszTip);
    
            HRESULT SetThumbnailClip(
                    [in] long hwnd, 
                    [in] RECT *prcClip);
    }
    
    [ uuid(56FDF344-FD6D-11d0-958A-006097C9A090) ] coclass TaskbarList { interface ITaskbarList3; }
    };
    leandroascierto.com Visual Basic 6 projects

  4. #4
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: ITaskbarList No tlb?

    All interfaces that originate from IUnknown, you start counting at 4.

    ITaskbarList.HrInit = 4

    Then you count in the order that they're listed in the original IDL/header file,

    AddTab = 5, DeleteTab = 6, etc

    If another interface inherits from that one, you just continue the count.

    ITaskbarList2.MarkFullScreenWindow = 7

    ITaskbarList3.SetTabActive = 8, .SetProgressValue = 9, SetProgressState = 10, etc

    ITaskbarList4.SetTabProperties = 21

  5. #5
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    609

    Re: ITaskbarList No tlb?

    Quote Originally Posted by fafalone View Post
    All interfaces that originate from IUnknown, you start counting at 4.

    ITaskbarList.HrInit = 4

    Then you count in the order that they're listed in the original IDL/header file,

    AddTab = 5, DeleteTab = 6, etc

    If another interface inherits from that one, you just continue the count.

    ITaskbarList2.MarkFullScreenWindow = 7

    ITaskbarList3.SetTabActive = 8, .SetProgressValue = 9, SetProgressState = 10, etc

    ITaskbarList4.SetTabProperties = 21
    Educate me Why ActivateTab and SetActivateAlt are not counting?

  6. #6
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,192

    Re: ITaskbarList No tlb?

    Quote Originally Posted by DaveDavis View Post
    Educate me Why ActivateTab and SetActivateAlt are not counting?
    They actually do but indexes in the vtable start from 0 for IUnknown:QI and continue the sequence for all inherited interfaces so we get

    - ITaskbarList::HrInit index is 3 as ITaskbarList inherits (continues) IUnknown

    - ITaskbarList2::MarkFullscreenWindow index is 8 as ITaskbarList2 inherits (continues) ITaskbarList

    - ITaskbarList3::SetProgressValue index is 9 as ITaskbarList3 inherits (continues) ITaskbarList2

    - ITaskbarList4::SetTabProperties index is 21 as ITaskbarList4 inherits (continues) ITaskbarList3

    cheers,
    </wqw>

  7. #7
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    609

    Re: ITaskbarList No tlb?

    Quote Originally Posted by wqweto View Post
    They actually do but indexes in the vtable start from 0 for IUnknown:QI and continue the sequence for all inherited interfaces so we get

    - ITaskbarList::HrInit index is 3 as ITaskbarList inherits (continues) IUnknown

    - ITaskbarList2::MarkFullscreenWindow index is 8 as ITaskbarList2 inherits (continues) ITaskbarList

    - ITaskbarList3::SetProgressValue index is 9 as ITaskbarList3 inherits (continues) ITaskbarList2

    - ITaskbarList4::SetTabProperties index is 21 as ITaskbarList4 inherits (continues) ITaskbarList3

    cheers,
    </wqw>
    Clean now. Thanks.

  8. #8
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: ITaskbarList No tlb?

    Oops my bad I'm used to using wrappers that subtract the 1 for you or VirtualProtect for swapping things where you use base 1. So yeah for DispCallFunc you start at 0.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    Re: ITaskbarList No tlb?

    Thank you very much wqweto thank you very much fafalone, well I was finally able to finish assembling the module, I stole many routines from the Fafalone project
    Attached Files Attached Files
    leandroascierto.com Visual Basic 6 projects

  10. #10
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    Re: ITaskbarList No tlb?

    Quote Originally Posted by LeandroA View Post
    Thank you very much wqweto thank you very much fafalone, well I was finally able to finish assembling the module, I stole many routines from the Fafalone project
    Nice work !

    I used a similar approach for excel :
    V2-MultipleFormsToTaskBar.xlsm
    Last edited by JAAFAR; Mar 18th, 2021 at 09:10 PM.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    Re: ITaskbarList No tlb?

    Yours very good job! I also like to program in excel, which excel forum do you frequent?
    leandroascierto.com Visual Basic 6 projects

  12. #12
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    Re: ITaskbarList No tlb?

    Quote Originally Posted by LeandroA View Post
    Yours very good job! I also like to program in excel, which excel forum do you frequent?
    I frequent forums such as www.mrexcel.com and www.ozgrid.com

  13. #13
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,541

    Re: ITaskbarList No tlb?

    Quote Originally Posted by JAAFAR View Post
    Nice work !

    I used a similar approach for excel :
    V2-MultipleFormsToTaskBar.xlsm
    V2-MultipleFormsToTaskBar.xlsm,can you upload or send me a email?thank you ,i can't open your site

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width