Results 1 to 9 of 9

Thread: [VB6] - Custom rendering window.

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,671

    [VB6] - Custom rendering window.


    In Windows 7, there was a remarkable thing - indication of progress on the taskbar button. To use this feature on VB6 (and any other language) you need to create an object TaskBarList, get ITaskBarList3 interface and use its methods - SetProgressState and SetProgressValue. In my module, I added the ability to set the state of the progress bar on the taskbar, and duplicated this indicator on the form itself + added ability to use animated icons in the form header (also supported by the usual icons). From this example, you can learn how to draw the non-client area of the window, make buttons that are highlighted when hovering. The example uses double buffering, so everything works smoothly and without flicker. This module can be connected to any project with any forms.
    Functions:
    SetNCSkin - set new style window;
    RemoveNCSkin - remove style from window;
    SetIcon - set animated (or simple) icon to window;
    PlayAnimation - enable playing icon animation;
    StopAnimation - stop animation playing;
    SetProgressState - set state of taskbar button;
    GetProgressState - get state of taskbar button;
    SetProgressValue - set value of progressbar in the taskbar button (0..1);
    GetProgressValue - same, only get a value.

    Example use:
    Code:
    Option Explicit
     
    ' Тестовая форма модуля пользовательской отрисовки окна
    ' © Кривоус Анатолий Анатольевич (The trick), 2014
     
    Dim Value As Single
     
    Private Sub cboIcon_Click()
        Select Case cboIcon.ListIndex
        Case 0: SetIcon Me, LoadResPicture("TRICKICON", vbResBitmap), 21
        Case 1: SetIcon Me, LoadResPicture("WAITICON", vbResBitmap), 20
        End Select
    End Sub
     
    Private Sub cmdDuplicate_Click()
        Dim frm As frmTest
        Set frm = New frmTest
        frm.Show
    End Sub
     
    Private Sub cmdHideProgress_Click()
        SetProgressState Me, TBPF_NOPROGRESS
    End Sub
     
    Private Sub cmdIcon_Click()
        PlayAnimation Me, 32, False
    End Sub
    Private Sub cmdIconLoop_Click()
        PlayAnimation Me, 32, True
    End Sub
    Private Sub cmdProgress_Click()
        tmrTimer.Enabled = True
        Value = 0
    End Sub
    Private Sub cmdShowProgress_Click()
        If optState(0).Value Then SetProgressState Me, TBPF_NORMAL
        If optState(1).Value Then SetProgressState Me, TBPF_PAUSED
        If optState(2).Value Then SetProgressState Me, TBPF_ERROR
    End Sub
    Private Sub cmdStopAnimation_Click()
        StopAnimation Me
    End Sub
    Private Sub cmdStopProgress_Click()
        tmrTimer.Enabled = False
    End Sub
    Private Sub Form_Load()
        SetNCSkin Me
        cboIcon.ListIndex = 0
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        RemoveNCSkin Me
    End Sub
    Private Sub optState_Click(Index As Integer)
        Call cmdShowProgress_Click
    End Sub
     
    Private Sub tmrTimer_Timer()
        Value = Value + 0.01
        SetProgressValue Me, Value
    End Sub
    Attached Files Attached Files

  2. #2
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    Re: [VB6] - Custom rendering window.

    Thanks for sharing this. I'm considering different ways to display progress in my app and this looks interesting!

  3. #3

  4. #4
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    Re: [VB6] - Custom rendering window.

    Thanks for the link to the working project - I'll definitely check that out too. Not only for the progress bar code but for the music generation portion. I'm a musician and have a side app I've been working with slowly over the years - I may be able to borrow some ideas from you in that area as well.

  5. #5
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    524

    Re: [VB6] - Custom rendering window.

    Problem getting it to work

    There is a reference to test.tlb.
    Test.tlb is not to find in the project folder.
    So I think I can select the Taskbar.tlb.

    It is checked in the references dialog.
    When I click OK, then this comes up:
    Microsoft Visual Basic - Error in loading DLL

    What do I miss?
    Thanks for a hint.

    (Win10/64, IDE manifested)
    Last edited by Karl77; Aug 7th, 2018 at 12:20 PM.

  6. #6
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    524

    Re: [VB6] - Custom rendering window.

    Solved.

    The tlb failed to create a reference also in a new, empty project.

    I used the MIDL compiler to create a new tlb from the idl.
    Interestingly it has another GUID than the original, only the very last number.

    This new tlb loads fine, and with Custom rendering window as well.

  7. #7
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    198

    Re: [VB6] - Custom rendering window.

    Hi The Trick, I found that Form_Resize is not being executed.
    I fixed changing WndProc with:

    Code:
        Case WM_SIZE
            WndProc = OnSize(hwnd, wParam, lParam And &HFFFF&, (lParam \ &H10000) And &HFFFF&)
            Call CallOldWndProc(hwnd, msg, wParam, lParam) ' <- Added line

  8. #8
    Lively Member
    Join Date
    Jan 2008
    Posts
    67

    Re: [VB6] - Custom rendering window.

    Impossible reference to Taskbar.tlb

    If I convert the idl also not working... Y use Win 10 32 Bits, is possible this code is for 64Bits Windows?

  9. #9

Tags for this Thread

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