📄 modgraphics.bas
字号:
Attribute VB_Name = "ModGraphics"
'****************************************************************************
'人人为我,我为人人
'枕善居汉化收藏整理
'发布日期:2006/12/23
'描 述:非常专业的防火墙源代码
'网 站:http://www.Mndsoft.com/ (VB6源码博客)
'网 站:http://www.VbDnet.com/ (VB.NET源码博客,主要基于.NET2005)
'e-mail :Mndsoft@163.com
'e-mail :Mndsoft@126.com
'OICQ :88382850
' 如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************
Option Explicit
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
Private Declare Function CreateBrushIndirect Lib "gdi32" (lpLogBrush As LogBrush) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LogFont) As Long
Private Declare Function CreatePenIndirect Lib "gdi32" (lpLogPen As LogPen) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private 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
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Declare Function GetTextMetrics Lib "gdi32" Alias "GetTextMetricsA" (ByVal hdc As Long, lpMetrics As TEXTMETRIC) As Long
Private 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
Private Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Public Enum enBackStyle
TRANSPARENT = 1
OPAQUE = 2
End Enum
Public Enum AlignText
vbLeftAlign = 1
vbCentreAlign = 2
vbRightAlign = 3
End Enum
Public Enum GradientTo
GradHorizontal = 0
GradVertical = 1
End Enum
Public Enum Scaling
InTwips = 0
InPixels = 1
End Enum
Private Enum en_PS_CONSTANTS 'pen constants
PS_COSMETIC = &H0
PS_DASH = 1 ' -------
PS_DASHDOT = 3 ' _._._._
PS_DASHDOTDOT = 4 ' _.._.._
PS_DOT = 2 ' .......
PS_ENDCAP_ROUND = &H0
PS_ENDCAP_SQUARE = &H100
PS_ENDCAP_FLAT = &H200
PS_GEOMETRIC = &H10000
PS_INSIDEFRAME = 6
PS_JOIN_BEVEL = &H1000
PS_JOIN_MITER = &H2000
PS_JOIN_ROUND = &H0
PS_SOLID = 0
End Enum
Public Type FontStruc
Name As String
Alignment As AlignText
Bold As Boolean
Italic As Boolean
Underline As Boolean
StrikeThru As Boolean
PointSize As Byte
Colour As Long
End Type
Private Type LogPen
lopnStyle As Long
lopnWidth As POINTAPI
lopnColor As Long
End Type
Private Type LogBrush
lbStyle As Long
lbColor As Long
lbHatch As Long
End Type
Private Type RGBVal
Red As Single
Green As Single
Blue As Single
End Type
Public Type BitmapStruc
hDcMemory As Long
hDcBitmap As Long
hDcPointer As Long
Area As RECT
End Type
Private Type LogFont
'for the DrawText api call
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(1 To 32) As Byte
End Type
Private Type TEXTMETRIC
tmHeight As Long
tmAscent As Long
tmDescent As Long
tmInternalLeading As Long
tmExternalLeading As Long
tmAveCharWidth As Long
tmMaxCharWidth As Long
tmWeight As Long
tmOverhang As Long
tmDigitizedAspectX As Long
tmDigitizedAspectY As Long
tmFirstChar As Byte
tmLastChar As Byte
tmDefaultChar As Byte
tmBreakChar As Byte
tmItalic As Byte
tmUnderlined As Byte
tmStruckOut As Byte
tmPitchAndFamily As Byte
tmCharSet As Byte
End Type
Public Const SRCAND As Long = &H8800C6 ' (DWORD) dest = source AND dest
Public Const SRCCOPY As Long = &HCC0020 ' (DWORD) dest = source
Public Const SRCERASE As Long = &H440328 ' (DWORD) dest = source AND (NOT dest )
Public Const SRCINVERT As Long = &H660046 ' (DWORD) dest = source XOR dest
Public Const SRCPAINT As Long = &HEE0086 ' (DWORD) dest = source OR dest
Public Const MERGECOPY As Long = &HC000CA ' (DWORD) dest = (source AND pattern)
Public Const MERGEPAINT As Long = &HBB0226 ' (DWORD) dest = (NOT source) OR dest
Public Const NOTSRCCOPY As Long = &H330008 ' (DWORD) dest = (NOT source)
Public Const NOTSRCERASE As Long = &H1100A6 ' (DWORD) dest = (NOT src) AND (NOT dest)
Private Const BS_DIBPATTERN As Long = 5
Private Const BS_DIBPATTERN8X8 As Long = 8
Private Const BS_DIBPATTERNPT As Long = 6
Private Const BS_HATCHED As Long = 2
Private Const BS_HOLLOW As Long = 1
Private Const BS_NULL As Long = 1
Private Const BS_PATTERN As Long = 3
Private Const BS_PATTERN8X8 As Long = 7
Private Const BS_SOLID As Long = 0
Private Const HS_BDIAGONAL As Long = 3 ' /////
Private Const HS_CROSS As Long = 4 ' +++++
Private Const HS_DIAGCROSS As Long = 5 ' xxxxx
Private Const HS_FDIAGONAL As Long = 2 ' \\\\\
Private Const HS_HORIZONTAL As Long = 0 ' -----
Private Const HS_NOSHADE As Long = 17
Private Const HS_SOLID As Long = 8
Private Const HS_SOLIDBKCLR As Long = 23
Private Const HS_SOLIDCLR As Long = 19
Private Const HS_VERTICAL As Long = 1
Private Const LOGPIXELSY As Long = 90 ' Logical pixels/inch in Y
Private Const LF_FACESIZE As Long = 32
Private Const FW_BOLD As Long = 700
Private Const FW_DONTCARE As Long = 0
Private Const FW_EXTRABOLD As Long = 800
Private Const FW_EXTRALIGHT As Long = 200
Private Const FW_HEAVY As Long = 900
Private Const FW_LIGHT As Long = 300
Private Const FW_MEDIUM As Long = 500
Private Const FW_NORMAL As Long = 400
Private Const FW_SEMIBOLD As Long = 600
Private Const FW_THIN As Long = 100
Private Const DEFAULT_CHARSET As Long = 1
Private Const OUT_CHARACTER_PRECIS As Long = 2
Private Const OUT_DEFAULT_PRECIS As Long = 0
Private Const OUT_DEVICE_PRECIS As Long = 5
Private Const OUT_OUTLINE_PRECIS As Long = 8
Private Const OUT_RASTER_PRECIS As Long = 6
Private Const OUT_STRING_PRECIS As Long = 1
Private Const OUT_STROKE_PRECIS As Long = 3
Private Const OUT_TT_ONLY_PRECIS As Long = 7
Private Const OUT_TT_PRECIS As Long = 4
Private Const CLIP_CHARACTER_PRECIS As Long = 1
Private Const CLIP_DEFAULT_PRECIS As Long = 0
Private Const CLIP_EMBEDDED As Long = 128
Private Const CLIP_LH_ANGLES As Long = 16
Private Const CLIP_MASK As Long = &HF
Private Const CLIP_STROKE_PRECIS As Long = 2
Private Const CLIP_TT_ALWAYS As Long = 32
Private Const WM_SETFONT As Long = &H30
Private Const LF_FULLFACESIZE As Long = 64
Private Const DEFAULT_PITCH As Long = 0
Private Const DEFAULT_QUALITY As Long = 0
Private Const PROOF_QUALITY As Long = 2
Private Const DT_CENTER As Long = &H1
Private Const DT_BOTTOM As Long = &H8
Private Const DT_CALCRECT As Long = &H400
Private Const DT_EXPANDTABS As Long = &H40
Private Const DT_EXTERNALLEADING As Long = &H200
Private Const DT_LEFT As Long = &H0
Private Const DT_NOCLIP As Long = &H100
Private Const DT_NOPREFIX As Long = &H800
Private Const DT_RIGHT As Long = &H2
Private Const DT_SINGLELINE As Long = &H20
Private Const DT_TABSTOP As Long = &H80
Private Const DT_TOP As Long = &H0
Private Const DT_VCENTER As Long = &H4
Private Const DT_WORDBREAK As Long = &H10
Private Const PATCOPY As Long = &HF00021 ' (DWORD) dest = pattern
Private Const PATINVERT As Long = &H5A0049 ' (DWORD) dest = pattern XOR dest
Private Const PATPAINT As Long = &HFB0A09 ' (DWORD) dest = DPSnoo
Private Const DSTINVERT As Long = &H550009 ' (DWORD) dest = (NOT dest)
Private Const BLACKNESS As Long = &H42 ' (DWORD) dest = BLACK
Private Const WHITENESS As Long = &HFF0062 ' (DWORD) dest = WHITE
Public Function GetTextHeight(ByVal hdc As Long) As Integer
'This function will return the height of the text using the point size
Dim udtMetrics As TEXTMETRIC
Dim lngResult As Long
lngResult = GetTextMetrics(hdc, udtMetrics)
GetTextHeight = udtMetrics.tmHeight
End Function
Public Sub CreateNewBitmap(ByRef hDcMemory As Long, ByRef hDcBitmap As Long, ByRef hDcPointer As Long, ByRef BmpArea As RECT, ByVal CompatableWithhDc As Long, Optional ByVal lngBackColour As Long = 0, Optional ByVal udtMeasurement As Scaling = InPixels)
'This procedure will create a new bitmap compatable with a given
'form (you will also be able to then use this bitmap in a picturebox).
'The space specified in "Area" should be in "Twips" and will be
'converted into pixels in the following code.
Dim lngResult As Long
Dim Area As RECT
'scale the bitmap points if necessary
Area = BmpArea
If udtMeasurement = InTwips Then Call RectToPixels(Area)
'create the bitmap and its references
hDcMemory = CreateCompatibleDC(CompatableWithhDc)
hDcBitmap = CreateCompatibleBitmap(CompatableWithhDc, (Area.Right - Area.Left), (Area.Bottom - Area.Top))
hDcPointer = SelectObject(hDcMemory, hDcBitmap)
'set default colours and clear bitmap to selected colour
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -