 |

04-26-2002, 03:54 PM
|
|
|
When i move code to Module it no longer works?
|
I have this code that moves a head using SRCCOPY, SRCAND, And SRCPAINT.
you know for Sprites. now i made the code and made it a public function and called the function using case select (thanks to this Forum) But when i move the code to a .BAS module it no longer works and it gives me a sub or function not defined error. Is this move not possible.
|
|

04-26-2002, 03:56 PM
|
|
|
|
You're either not calling your function properly or naming it improperly.
|
|

04-26-2002, 03:56 PM
|
 |
Keeper of foo
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
|
|
|
It's more than possible. Why not post the code and maybe we can tell what you messed up in the move.
|
|

04-26-2002, 04:04 PM
|
|
|
This is the Sprite Function It uses an array. When it's in the form in works but when i move it to it's own mod it don't.
Code:
Public Function jackNod()
Dim lResult As Long
Dim picOldBack As StdPicture
Dim StartTimer As Single
Dim sngInterval As Single
Dim iCounter As Integer
Dim iNumFrames As Integer
'We'll first make a copy of the background where the animation
'will play. This is so we can restore it after the animation
'does play
lResult = BitBlt(picDisplay.hDC, 0, 0, imgSprite(1).Width, imgSprite(1).Height, Me.hDC, 0, 0, SRCCOPY)
Set picOldBack = picDisplay.Image
'Lets set our delay interval and number of frames
sngInterval = 0.1
StartTimer = Timer
iNumFrames = 4
'No we will loop through the Frames.
For iCounter = 0 To iNumFrames - 1
'Now we will cut out the area of the background to make room
'for the sprite. We do this by using BitBlt to paint the Mask
'Using the SRCAND. This will cut out only the black areas
'of the mask
Set picDisplay.Picture = imgMask(iCounter).Picture
lResult = BitBlt(Me.hDC, 0, 0, imgSprite(iCounter).Width, imgSprite(iCounter).Height, picDisplay.hDC, 0, 0, SRCAND)
'Now we will paint the sprite in the hole we cut out of the
'background with the mask using SRCPAINT
Set picDisplay.Picture = imgSprite(iCounter).Picture
lResult = BitBlt(Me.hDC, 0, 0, imgSprite(iCounter).Width, imgSprite(iCounter).Height, picDisplay.hDC, 0, 0, SRCPAINT)
Me.Refresh
StartTimer = Timer
Do While Timer < StartTimer + sngInterval
DoEvents
Loop
'Refresh the background
Set picDisplay.Picture = picOldBack
lResult = BitBlt(Me.hDC, 0, 0, imgSprite(iCounter).Width, imgSprite(iCounter).Height, picDisplay.hDC, 0, 0, SRCCOPY)
Next
'Now lets loop it backwards
For iCounter = iNumFrames - 1 To 0 Step -1
'Cut out the mask
Set picDisplay.Picture = imgMask(iCounter).Picture
lResult = BitBlt(Me.hDC, 0, 0, imgSprite(iCounter).Width, imgSprite(iCounter).Height, picDisplay.hDC, 0, 0, SRCAND)
'SRCPAINT the Sprite
Set picDisplay.Picture = imgSprite(iCounter).Picture
lResult = BitBlt(Me.hDC, 0, 0, imgSprite(iCounter).Width, imgSprite(iCounter).Height, picDisplay.hDC, 0, 0, SRCPAINT)
Me.Refresh
StartTimer = Timer
Do While Timer < StartTimer + sngInterval
DoEvents
Loop
'Refresh the background
Set picDisplay.Picture = picOldBack
lResult = BitBlt(Me.hDC, 0, 0, imgSprite(iCounter).Width, imgSprite(iCounter).Height, picDisplay.hDC, 0, 0, SRCCOPY)
Next
Me.Refresh
End Function
This is How i call the function in the form
Private Sub cmdMove_Click()
Select Case True
Case txtControl.Text = "Nod"
Call jackNod
Case Else
End Select
End Sub
And this is the Sprite stuff in it's own Mod
Option Explicit
Public Const SRCAND = &H8800C6
Public Const SRCPAINT = &HEE0086
Public Const SRCCOPY = &HCC0020
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
|
Last edited by dcl3500; 04-27-2002 at 12:36 AM.
|

04-26-2002, 04:07 PM
|
 |
Keeper of foo
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
|
|
|
picDisplay <--
That's one problem, if not THE problem. Your module doesn't know your form. Either pass the form to the function, or name the control explicitly. i.e.
Formname.picDisplay
|
|

04-26-2002, 04:07 PM
|
|
|
|
'picDisplay' is not known in the module. You'll have to prefix it with the form name on which it resides.
So use Form1.picDisplay ...
|
|

04-26-2002, 04:09 PM
|
 |
Keeper of foo
Retired Moderator * Guru *
|
|
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
|
|
|
*reboot wonders if rive works for Thinker, Inc.
|
|

04-26-2002, 04:09 PM
|
|
|
Like vultures circling around a dying animal 
|
|

04-26-2002, 04:17 PM
|
|
|
|
You Guys are the Thanks Alot
You helped a young mind out
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|