PDA

Click to See Complete Forum and Search --> : How i create "Flying" objects ???


TalZ
Jun 18th, 2000, 06:01 PM
somebody know how i can create a flying object without the forms...
like the cat program with the little cat that runs after your mouse pointer, or the sheep that stops on opens windows...

????

Fox
Jun 18th, 2000, 10:56 PM
I think I know which programs you mean... What they do is draw on the screen directly (get the desktop DC and draw on it). To clean before drawing the next picture they backup the region, that's all...

TalZ
Jun 19th, 2000, 04:29 AM
could you be more specific please...
how do i get the desktop dc?
how do i draw on it?

thanks...

Fox
Jun 19th, 2000, 04:52 AM
Sure. You can work with the API, I'll show you some examples:


'Module
Public Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long
Public Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Long) As Long
Public 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 Long) As Long

'Code
Dim DC as Long

'Get the DC
DC = GetWindowDC( GetDesktopWindow )

'Draw picture1 on it
BitBlt DC, 10, 20, 100, 100, Picture1.hDC, 0, 0, vbSrcCopy


This will draw the picture loaded in Picture1 on the desktop. 10, 20 is the desired position on the destination dc, next 2 values are the size (Put in Picture1.Width, Picture1.Height to get size automatically). Picture1.hDC is the DC of the picture and the next 2 values are the position on the source DC where the picture is. And vbSrcCopy tells BitBlt to just copy the picture (So no transparency)

For any Qs you can also visit my homepage where I have some demo projects about BitBlt...

TalZ
Jun 19th, 2000, 02:46 PM
Thanks!