Option Explicit
Private Declare Function BitBlt Lib "gdi32" (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 Long) As Long
Private Sub Command1_Click()
BitBlt Front.hDC, 32, 32, 32, 32, LinkSprite.hDC, 32, 32, vbSrcCopy
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySpace Then
BitBlt Front.hDC, 32, 32, 32, 32, LinkSprite.hDC, 32, 32, vbSrcCopy
End If
End Sub
Private Sub Form_Load()
BitBlt Front.hDC, 32, 32, 32, 32, LinkSprite.hDC, 32, 32, vbSrcCopy
End Sub
This is the code from my test form. I'm just simply blitting a sprite from Zelda (hence the name of my PictureBox "LinkSprite"). The problem is that, the BitBlt code only works when called from a command button or a subroutine called from the command button routine. Any other time I try to call the BltBit function, it just does nothing. And if I delete the command button from my form and call BltBit from the Form_Load routine, the form disappears!
Any insight to my problem would be greatly appreciated.
Thanks.
Edited by - FieroAddict on November 19, 2001 9:00:44 PM
(VB) BltBlit woes...
Dude, put your code between source tags ([ source] and [ /source], but without the spaces). That was WAY too hard to read on this tiny monitor.
Sorry, my fault. I thought I had formatted it. It still won''t retain the spacing between the routines though. Is there a fix for that?
Hmm... I dunno, it seems to work for me.
I assumed that "Front" and "LinkSprite" are PictureBox controls, when I tried to emulate your program (or at least, this little part of it).
If this isn''t the case, I''ll need more details.
If it is, try this:
Make sure that you have the proper scalemodes set up for both boxes (3 - pixels).
Make sure you have "AutoRedraw" set to true for them both also.
I had to do those two things to get it to work.
I assumed that "Front" and "LinkSprite" are PictureBox controls, when I tried to emulate your program (or at least, this little part of it).
If this isn''t the case, I''ll need more details.
If it is, try this:
Make sure that you have the proper scalemodes set up for both boxes (3 - pixels).
Make sure you have "AutoRedraw" set to true for them both also.
I had to do those two things to get it to work.
*smacks self in head* I was forgeting the auto-redraw on the main picture box. (Front ) (Sorry I left out a couple details about the picture boxes.) Figures it was something easy.
Thank you.
Thank you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement