Results 1 to 6 of 6

Thread: Help... New to BitBlting.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    26

    Unhappy Help... New to BitBlting.

    I've searched the forums for over an hour and couldn't find an answer to my problem. Everytime I try to use .hDC on anything it says there isn't one. How do I go about fixing this? Here's my code:
    Code:
    Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, _
         ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
         ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, _
         ByVal ySrc As Long, ByVal dwRop As System.Int32) As Long
    
        Public Const SRCCOPY = &HCC0020
        Public Const SRCPAINT = &HEE0086
        Public Const SRCAND = &H8800C6
    
        Public RetVal As Long
    
    
        Private Sub form2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
    
        RetVal = BitBlt(Form1.hDC, 0, 0, 320, 200, Picture1.hDC, 0, 0, SRCCOPY))
    
        End Sub

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Just use the DrawImage function of the Graphics class. It has 30 overloaded new constructors, and I believe the one you're looking for is toward the end. The code below you could put in a button event, and Me references the current form (obviously). It grabs the picturebox's image and draws it on the form.

    VB Code:
    1. Me.CreateGraphics.DrawImage(PictureBox1.Image, Me.DisplayRectangle, 0, 0, _
    2.   PictureBox1.Image.Width, PictureBox1.Image.Height, GraphicsUnit.Pixel)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    26
    Thanks but in bitblting you can get rid of that annoying black background behind a sprite right? I found something that looks like it might do that:
    Code:
            e.Graphics.Clear(System.Drawing.Color.Black)
    But whenever I try to make it run this sub:
    Code:
           Private Sub Draw_Player(ByVal e As PaintEventArgs)
            e.Graphics.Clear(System.Drawing.Color.Black)
        End Sub
    It says: "Argument not specified for parameter 'e' of 'Private Sub Draw_Player(YadaYadaYada)'"

    Any ideas?

  4. #4
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668
    Try changing the Longs in your declaration to int32
    If wishes were fishes we'd all cast nets.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    26
    It didn't work. Still got the same problem. It says hDC is not a member of System.Forms

  6. #6
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Originally posted by Izzy545
    Thanks but in bitblting you can get rid of that annoying black background behind a sprite right? I found something that looks like it might do that:
    Code:
            e.Graphics.Clear(System.Drawing.Color.Black)
    But whenever I try to make it run this sub:
    Code:
           Private Sub Draw_Player(ByVal e As PaintEventArgs)
            e.Graphics.Clear(System.Drawing.Color.Black)
        End Sub
    It says: "Argument not specified for parameter 'e' of 'Private Sub Draw_Player(YadaYadaYada)'"

    Any ideas?
    When you say you TRY to make it run Draw_Player, if you're just calling your sub from somewhere in your code, you need to pass the sub a PaintEventArgs class. So just use
    VB Code:
    1. Draw_Player(New PaintEventArgs(Me.CreateGraphics, Me.DisplayRectangle)).

    That will your Draw_Player sub properly. Now, I'm passing in the form, you can pass whatever it is your drawing on.

    Personally, if you're trying to make some sort of game, you might be better off getting a book on game programming in .Net, and even better off learning DirectX.
    Last edited by nemaroller; Nov 15th, 2003 at 08:11 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width