VBfx / Tile tutorial / Step 3


Here we go on to the coding part. As before we need to set up the counter variable to -1 and as said the initialization function takes a window reference as parameter. This may sound difficult, in fact it's quite easy:

Public Sub Initialize( iWindow as Form )
    'Setup counter
    BitmapCount = -1
    'Apply main window
    Set MainWindow = iWindow
    MainWindow.ScaleMode = vbPixels
End Sub

Note that we change the window's ScaleMode property in the last line, this is just for security - you should always set the ScaleMode to vbPixels just after starting a new VB-project and everytime you add a new Form!


The Reset function is getting a little longer than initializing, this is because we have to free all resources here. The corresponding UnloadBitmap function we'll write later, so don't care about it yet.

Public Sub Reset()
    Dim A as Long
    'Release all pictures
    For A = 0 To BitmapCount
        UnloadBitmap Bitmap( A )
    'Release memory and reset counter
    BitmapCount = -1
    Erase Bitmap
End Sub