|
-
Nov 19th, 2001, 04:12 PM
#1
Thread Starter
New Member
Simple BitBlt question
This may sound stupid but, why does my BitBlt call not work under any Sub or Function other than a Command Button??? I'm totally stumped!
If I put the code under the Command Button, the image will be blitted just fine, but under no other circumstances will it work.
-
Nov 19th, 2001, 08:13 PM
#2
Addicted Member
BitBlt should work from pretty much anywhere in the code. Where are you declaring it? If you are declaring it in the form module as private it can't be called out side the form. You can put the declaration into a code module and make it public. You should then be able to call it from anywhere.
If you have all of this covered then and say you want to blt from a code module to picBackGround.hdc make sure that you include the form that it is from. So as the destination (or source) you should use Form1.picBackGround.hdc. This will direct it to the proper place.
Does this help? If not I don't know what the problem is, sorry.
Drewski
I see said the blind man as he spat into the wind.
It all comes back to me now!
A.D.T.'s VB
-
Nov 19th, 2001, 08:30 PM
#3
Thread Starter
New Member
Code:
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 for my form. (This was just a test app, so there's not much in it.) The code for the command button will display the image in the picture box Front on the form. But the other code won't work. Even if I put the BitBlt call in my own Sub, it won't work unless that Sub is called from inside the Command Button Sub.
Last edited by FieroAddict; Nov 19th, 2001 at 09:45 PM.
-
Nov 19th, 2001, 08:48 PM
#4
is the KeyPreview property on the form set to = True?
-
Nov 19th, 2001, 09:44 PM
#5
Thread Starter
New Member
OK. I set the key preview to True and now the KeyDown works fine. But I still can't BitBlt from the Form routine or from my own Sub routines called from the Form_Load().
The other weird thing is: if I delete the Command button from the form, and just call the BitBlt from the Form_Load(), the entire form will disappear altogether.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|