VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

This module contains various api graphics operations from FlipBitmap to BFAlphaBlend to LoadBitmap

DiskJunky  (16 Submissions)   Graphics   VB 6.0   Unknown Difficulty   Tue 15th January 2002   Mon 8th February 2021

This module contains various api graphics operations from FlipBitmap to BFAlphaBlend to LoadBitmap to RotateBitmap etc. It can draw shapes,

API Declarations


'12/11/2001
'----------------------------------------------
' Author : Eric O'Sullivan
'----------------------------------------------
'Contact : [email protected]
'----------------------------------------------
'Comments :
'This module was made for using api graphics functions in your
'programs. With the following api calls and function and procedures
'written by me, you have to tools to do almost anything. The only api
'function listed here that is not directly used by any piece of code
'in this module is BitBlt. You have the tools to create and manipulate
'graphics, but it is still necessary to display them manually. The
'functions themselves mostly need hDc or a handle to work. You can
'find this hDc in both a forms and pictureboxs' properties. I have
'also set up a data type called BitmapStruc. For my programs, I have
'used this structure almost exclusivly for the graphics. The structure
'holds all the information needed to reference a bitmap created using
'this module (CreateNewBitmap, DeleteBitmap).
'Please keep in mind that any object (bitmap, brush, pen etc) needs to
'be deleted after use or else it will stay in memory until the program is
'finished. Not doing so will eventually cause your program to take up
'ALL your computers recources.
'Also for anyone using optional paramters, it is probably better to use
'a default parameter values to determine whether or not a parameter
'has been passed than the function IsMissing().
'
'Thank you,
'Eric
'----------------------------------------------


Option Explicit


'These functions are sorted alphabetically.
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 ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (ByRef wef As Any, ByVal i As Long) As Long
Public Declare Function CreateBrushIndirect Lib "gdi32" (lpLogBrush As LogBrush) As Long
Public Declare Function CreateColorSpace Lib "gdi32" Alias "CreateColorSpaceA" (lplogcolorspace As LogColorSpace) As Long
Public Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDc As Long) As Long
Public Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Public Declare Function CreateEllipticRgnIndirect Lib "gdi32" (EllRect As Rect) As Long
Public Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LogFont) As Long
Public Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Public Declare Function CreatePenIndirect Lib "gdi32" (lpLogPen As LogPen) As Long
Public Declare Function CreateRectRgn Lib "gdi32" (Left As Integer, Top As Integer, Right As Integer, Bottom As Integer) As Long
Public Declare Function CreateSolidBrush Lib "gdi32" (ColorRef As Long) As Long
Public Declare Function DeleteDC Lib "gdi32" (ByVal hDc As Long) As Long
Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Public Declare Function DrawAnimatedRects Lib "user32" (ByVal hwnd As Long, ByVal idAni As Long, lprcFrom As Rect, lprcTo As Rect) As Long
Public Declare Function DrawIconEx Lib "user32" (ByVal hDc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Public Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hDc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As Rect, ByVal wFormat As Long) As Long
Public Declare Function Ellipse Lib "gdi32" (ByVal hDc As Long, X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer) As Boolean
Public Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal A As Long, ByVal B As Long, wef As DEVMODE) As Boolean
Public Declare Function ExtCreatePen Lib "gdi32" (ByVal dwPenStyle As Long, ByVal dwWidth As Long, lplb As LogBrush, ByVal dwStyleCount As Long, lpStyle As Long) As Long
Public Declare Function FillRect Lib "user32" (ByVal hwnd As Long, Fill As Rect, hBrush As Long) As Integer
Public Declare Function FillRgn Lib "gdi32" (ByVal hDc As Long, ByVal HRgn As Long, hBrush As Long) As Boolean
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetActiveWindow Lib "user32" () As Long
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public Declare Function GetBitmapDimensionEx Lib "gdi32" (ByVal hBitmap As Long, lpDimension As SizeType) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As Rect) As Long
Public Declare Function GetCursor Lib "user32" () As Long
Public Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDc As Long, ByVal nIndex As Long) As Long
Public Declare Function GetLastError Lib "kernel32" () As Long
Public Declare Function GetObjectAPI Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Public Declare Function GetPixel Lib "gdi32" (ByVal hDc As Long, ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function GetTextMetrics Lib "gdi32" Alias "GetTextMetricsA" (ByVal hDc As Long, lpMetrics As TEXTMETRIC) As Long
Public Declare Function GetTickCount Lib "kernel32" () As Long 'very usefull timing function ;)
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As Rect) As Long
Public Declare Function InflateRect Lib "user32" (lpRect As Rect, ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function IntersectRect Lib "user32" (lpDestRect As Rect, lpSrc1Rect As Rect, lpSrc2Rect As Rect) As Long
Public Declare Function LineTo Lib "gdi32" (ByVal hDc As Long, XEnd As Integer, YEnd As Integer) As Boolean
Public Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Any) As Long
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 Function MoveToEx Lib "gdi32" (ByVal hDc As Long, X As Integer, Y As Integer, PointAPI) As Boolean
Public Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As Long
Public Declare Function OffsetRect Lib "user32" (lpRect As Rect, ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function PatBlt Lib "gdi32" (ByVal hDc As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long
Public Declare Function Polygon Lib "gdi32" (ByVal hDc As Long, lpPoint As PointAPI, ByVal nCount As Long) As Long
Public Declare Function Polyline Lib "gdi32" (ByVal hDc As Long, lpPoint As PointAPI, ByVal nCount As Long) As Long
Public Declare Function PolylineTo Lib "gdi32" (ByVal hDc As Long, lppt As PointAPI, ByVal cCount As Long) As Long
Public Declare Function Rectangle Lib "gdi32" (ByVal hwnd As Long, X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer) As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDc As Long) As Long
Public Declare Function RoundRect Lib "gdi32" (ByVal hDc As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Public Declare Function SelectObject Lib "gdi32" (ByVal hDc As Long, ByVal hObject As Long) As Long
Public Declare Function SetBkColor Lib "gdi32" (ByVal hDc As Long, ByVal crColor As Long) As Long
Public Declare Function SetBkMode Lib "gdi32" (ByVal hDc As Long, ByVal nBkMode As Long) As Long
Public Declare Function SetColorAdjustment Lib "gdi32" (ByVal hDc As Long, lpca As COLORADJUSTMENT) As Long
Public Declare Function SetColorSpace Lib "gdi32" (ByVal hDc As Long, ByVal hcolorspace As Long) As Long
Public Declare Function SetPixel Lib "gdi32" (ByVal hDc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Public Declare Function SetRect Lib "user32" (lpRect As Rect, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Public Declare Function SetTextColor Lib "gdi32" (ByVal hDc As Long, ByVal crColor As Long) As Long
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds 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


'--------------------------------------------------------------------------
'enumerator section
'--------------------------------------------------------------------------

'the direction of the gradient
Public Enum GradientTo
GradHorizontal = 0
GradVertical = 1
End Enum

'in twips or pixels
Public Enum Scaling
InTwips = 0
InPixels = 1
End Enum

'The key values of the mouse buttons
Public Enum MouseKeys
MouseLeft = 1
MouseRight = 2
MouseMiddle = 4
End Enum

'text alignment constants
Public Enum AlignText
vbLeftAlign = 1
vbCentreAlign = 2
vbRightAlign = 3
End Enum

'bitmap flip constants

Rate This module contains various api graphics operations from FlipBitmap to BFAlphaBlend to LoadBitmap (1(1 Vote))
This module contains various api graphics operations from FlipBitmap to BFAlphaBlend to LoadBitmap .bas

This module contains various api graphics operations from FlipBitmap to BFAlphaBlend to LoadBitmap Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters