Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleThe let user drag an image in VB .NET
Keywordsimage, drag, transparent
CategoriesGraphics, Multimedia
 
Save the form's background image in a Bitmap. Save the image to be dragged in another Bitmap. Call the Bitmap's MakeTransparent to "erase" its background.

The ShowBone method displays the picture in its new location. It draws the bacground image onto the form to erase the previous picture. Then it draws the dragged image on top.

 
Private m_DogBitmap As Bitmap
Private m_BoneBitmap As Bitmap
Private m_Dragging As Boolean

Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
    e As System.EventArgs) Handles MyBase.Load
    ' Save the dog image.
    m_DogBitmap = New Bitmap(Me.BackgroundImage)

    ' Save the bone image.
    m_BoneBitmap = picBone.Image
    m_BoneBitmap.MakeTransparent(Color.Red)
End Sub

' Display the bone.
Private Sub ShowBone(ByVal X As Integer, ByVal Y As Integer)
    Dim gr As Graphics = Me.CreateGraphics()

    gr.DrawImageUnscaled(m_DogBitmap, 0, 0)
    gr.DrawImageUnscaled(m_BoneBitmap, X, Y)
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated