Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why isn't my custom control displaying an image?

Status
Not open for further replies.

T0AD

Programmer
Jun 4, 2003
73
GB
Here's the code for my control:

Code:
Option Strict On
Option Explicit On 

Public Class ucReel
    Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code 

    Private p_ReelImagePath As String = "E:\Reel.BMP"
    Private p_TotalImages As Int32 = 9
    Private p_ImageHeight As Int32 = 64
    Private p_ImageWidth As Int32 = 64
    Private p_ImagesInView As Int32 = 5
    Private p_StepDistance As Int32 = 4
    Private p_DelayBetweenSteps As Int32 = 1
    Private p_StepNo As Int32 = 0
    Private p_StepsPerCycle As Int32 = p_ImageHeight \ p_StepDistance
    Private p_CycleNo As Int32 = 0

    Dim rctfDestination As RectangleF = New RectangleF(0, 0, p_ImageWidth, p_ImageHeight * (p_ImagesInView - 1))
    Dim rctfSource As RectangleF

    Dim bmpReel As New Bitmap(p_ReelImagePath)
    Dim grpcSurface As Graphics

    Private Sub ucReel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        grpcSurface = CreateGraphics()

        With rctfSource
            .X = 0
            .Y = 0
            .Width = rctfDestination.Width
            .Height = .Height
        End With

        grpcSurface.DrawImage(bmpReel, rctfDestination, rctfSource, GraphicsUnit.Pixel)

    End Sub

End Class

Can anyone tell me why nothing is displayed on the contol? I've been trying for ages but can't get it to work!

Thanks,
Pete

 
NEVER MIND!

I figured it out... forgot to instantiate the RectangleF rctfSource.

fix:

Code:
rctfSource = New RectangleF(0, 0, 64, 256)

Hehe!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top