dcsimg
Results 1 to 6 of 6

Thread: [VB6] - Custom rendering window.

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2015
    Posts
    1,364

    [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
    296

    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
    296

    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
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    454

    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
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    454

    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.

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
  •  



Featured


Click Here to Expand Forum to Full Width