Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1529

[VB6] - Custom rendering window.

$
0
0

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

Viewing all articles
Browse latest Browse all 1529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>