Search Tools Links Login

A cool graphics and sound engine with examples, very cool.


Visual Basic 6, or VB Classic

A whole graphics engine and a sound engine with a full sample program. graphics engine has: Animatition with 1 picture, animation with array of pictures, bitblt, move sprite over background and Pixel manipulation; Sound engine has: Make a trackerbar from a picturebox 9that works), Play and stop wav file, Play and stop midi file, Play short wav file, Stop all sound and get Short File name. A midi and a wav file included for testing. The engines are in a seperate module each so you can make a copy of them and keep them seperate from the sample. the sample is fully commented but the engines are not.

Original Author: Coding Genius

API Declarations

'For sound engine
Option Explicit
'Sound and media functions
Public Declare Function mciGetErrorString Lib "winmm" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
Public Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Declare Function PlaySound Lib "winmm" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
'For file
Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
'PlaySound enumeration
Public Enum SNDPLAYSOUND
SND_ASYNC = &H1
SND_LOOP = &H8
SND_NODEFAULT = &H2
SND_NOSTOP = &H10
SND_NOWAIT = &H2000
SND_PURGE = &H40
SND_SYNC = &H0
End Enum
'The graphics engine
Option Explicit
'Collision detection
Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
'Graphics drawing functions
Public 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
Public Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
'Pixel manipulation functions
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
'Clipboard functions
Public Declare Function CloseClipboard Lib "user32" () As Long
Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Public Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Public Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Long) As Long
'Miscellaneous functions
Public Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'LoadImage Constants
Public Const LR_LOADFROMFILE = &H10
Public Const CF_BITMAP = 2
'Pixel manipulation constants
Public Const PIXELGET = 0
Public Const PIXELSET = 1
Public Const PIXELS = 3
'graphics drawing enumeration
Public Enum dwRop
WHITENESS = &HFF0062
BLACKNESS = &H42
SRCAND = &H8800C6
SRCCOPY = &HCC0020
SRCINVERT = &H660046
SRCERASE = &H440328
SRCPAINT = &HEE0086

End Enum
'LoadImage enumeration
Public Enum LoadImg
IMAGE_BITMAP = 0
IMAGE_ICON = 1
IMAGE_CURSOR = 2
IMAGE_ENHMETAFILE = 3

End Enum
'Graphics drawing types
Public Type POINTAPI
X As Long
Y As Long

End Type
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long

End Type
'graphics drawing variables
Public PointType As POINTAPI
Public rectangle As RECT

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 119 times

Categories

Visual Basic 6

Attachments

A cool gra232037212001.zip
Posted: 9/3/2020 3:45:00 PM
Size: 34,767 bytes


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.