-------------------------------------------------------------------------------
Sample Name:  Cool Progress Bar

Description:  A simple sample that uses a nice progress bar filled with a gradient 
	      color transition.

	      This sample shows VB Migration Partner's capabilities to easily 
              migrate an user control which even uses the BltBit API function to
	      render its effects.

Download URL: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=11715&lngWId=1
-------------------------------------------------------------------------------

IMPORTANT NOTE
The first step to ensure that you can migrate the VB6 project to VB.NET is 
loading the original project in the Visual Basic 6 IDE, run it to ensure that 
it works fine, that all the required type libraries are installed, and that all 
file paths are correct. 
Regardless of whether you edited the source code in any way, you should save 
the VB6 project: this save operation ensures that the .vbp file includes  
the correct path and version of referenced type libraries. 
After saving the project, it's usually a good idea to compile the VB6 project
to an executable, to detect any VB6 compilation errors that would appear under 
VB.NET as well. 
(If you don't recompile the project VB Migration Partner will display a warning 
when you later load the project.)


VB Migration Partner migrates correctly after adding just a few pragmas.


VB6 code allows to unload the main form and show a new one without closing 
entire application.
In VB.NET this behavior is not allowed; therefore we need to insert the following
pragmas in frmMain.frm file to invert the order of instructions in migrated app:

At the end of tmrTimer_Timer sub:
    
    ...
    If cpbProgress.Value = 200 Then
        '## InsertStatement frmSecondary.Show()
        Unload Me
        '## ParseMode Remarks, 1
        frmSecondary.Show
    End If
  End Sub

as in

Private Sub lblX_Click()
    'Skip "loading"
        '## InsertStatement frmSecondary.Show()
        Unload Me
        '## ParseMode Remarks, 1
        frmSecondary.Show
End Sub

in frmSecondary.frm file:

Private Sub lblX_Click()
    'Hide this form and display the message box
    '## InsertStatement frmMsgbox.Show()
    Unload Me
    '## ParseMode Remarks, 1
    frmMsgbox.Show
End Sub

and finally we need to enable the Application Framework setting, which permits to close 
the application when the last form closes, by adding the following pragma at the top of frmMain:

    '## EnableAppFramework frmMain, "", True, 1

Besides, in CoolProgressBar user control file, the UserControl_Paint and DrawGrad methods
use the hDC property of the picBackbuffer picturebox to draw the gradient content of 
progressbar; VB Migration Partner supports the hDC property, but requires that you later 
invoke the control's ReleaseHDc method to release the handle to the device context. 
Here's how to insert the pragma:

At the end of Paint method:

        ...
        'Clear the control and copy the grad to it, according to
        'the new width of the bar
        Cls
        BitBlt hdc, 0, TempSize, ScaleWidth, ScaleHeight - TempSize, picBackbuffer.hdc, 0, TempSize, vbSrcCopy
    End If

    '## InsertStatement picBackbuffer.ReleaseHdc()
  End Sub

and DrawGrad method:

        ...
        'Stretch the tiny line we have drawn to fit the
        'control
        StretchBlt picBackbuffer.hdc, 0, 0, ScaleWidth, ScaleHeight, picBackbuffer.hdc, 0, 0, 1, 255, vbSrcCopy
    End If
        '## InsertStatement picBackbuffer.ReleaseHdc()
    
    'Grad done
    GradDone = True
End Sub
