7,763
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Rem 常量声明区域
Public Const PI = 3.14159265354 '圆周率常量
Public Const SPI_GETWORKAREA As Long = 48&
Public Const GRADIENT_FILL_TRIANGLE As Long = &H2&
'public Const GRADIENT_FILL_RECT_H As Long = &H0&
Public Const GRADIENT_FILL_RECT_V As Long = &H1&
Public Const LWA_ALPHA As Long = &H2
Public Const GWL_EXSTYLE As Long = (-20)
Public Const WS_EX_LAYERED As Long = &H80000
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Rem 变量声明区域
Public m_iOSver As Byte '/* OS 1=Win98/ME; 2=Win2000/XP
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Rem 结构类型声明区域
Public Type Rect
Left As Long
top As Long
right As Long
bottom As Long
End Type
Public Type GRADIENT_TRIANGLE
Vertex1 As Long
Vertex2 As Long
Vertex3 As Long
End Type
Public Type GRADIENT_RECT
UpperLeft As Long '/* UNSIGNED Long
LowerRight As Long '/* UNSIGNED Long
End Type
Public Type TRIVERTEX
x As Long
y As Long
Red As Integer '/* Ushort value
Green As Integer '/* Ushort value
Blue As Integer '/* Ushort value
Alpha As Integer '/* Ushort value
End Type
'/* Operating system version information
Public Type OSVERSIONINFO
OSVSize As Long
dwVerMajor As Long
dwVerMinor As Long
dwBuildNumber As Long
PlatformID As Long
szCSDVersion As String * 128
End Type
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Rem API函数声明区域
Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
'/* Set window in the Z order
Public Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cX As Long, ByVal cY As Long, ByVal wFlags As Long) As Long
'/* GradientFill API - Requires Windows 2000 or later; Requires Windows 98 or later
Public Declare Function GradientFillTriangle Lib "msimg32" Alias "GradientFill" (ByVal hdc As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_TRIANGLE, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long
Public Declare Function GradientFillRect Lib "msimg32" Alias "GradientFill" (ByVal hdc As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_RECT, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long
'/* Transparancy API's - Requires Windows 2000 or later; Win9x/ME is not supported
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
'/* Used to draw the form's rounded border
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 EllipseWidth As Long, ByVal EllipseHeight As Long) As Long
'/* Used to make the rounded corners of the form transparent
Public Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
Public Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal RectX1 As Long, ByVal RectY1 As Long, ByVal RectX2 As Long, ByVal RectY2 As Long, ByVal EllipseWidth As Long, ByVal EllipseHeight As Long) As Long
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'过程功能:
'参数说明:
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Sub GradientFill(ByVal iBackcolor As Long, ByRef objP As PictureBox)
Dim TriVert(3) As TRIVERTEX
Dim gTRi(1) As GRADIENT_TRIANGLE
objP.AutoRedraw = True
objP.ScaleMode = vbPixels '/* Required but done in Sub DisplayMessage
'/* Top Left Trangle
TriVert(0).x = 0&
TriVert(0).y = 0&
Call GradientFillColor(TriVert(0), RGB(255, 255, 0))
'/* Top Right Trangle
TriVert(1).x = objP.ScaleWidth
TriVert(1).y = 0&
Call GradientFillColor(TriVert(1), RGB(255, 255, 0))
'/* Bottom Right Trangle
TriVert(2).x = objP.ScaleWidth
TriVert(2).y = objP.ScaleHeight
Call GradientFillColor(TriVert(2), iBackcolor)
'/* Bottom Left Trangle
TriVert(3).x = 0&
TriVert(3).y = objP.ScaleHeight
Call GradientFillColor(TriVert(3), RGB(255, 255, 0))
gTRi(0).Vertex1 = 0&
gTRi(0).Vertex2 = 1&
gTRi(0).Vertex3 = 2&
gTRi(1).Vertex1 = 0&
gTRi(1).Vertex2 = 2&
gTRi(1).Vertex3 = 3&
Call GradientFillTriangle(objP.hdc, TriVert(0), 4&, gTRi(0), 2&, GRADIENT_FILL_TRIANGLE)
End Sub
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'过程功能:构建点的填充色
'参数说明:tTV,给点赋值:RGB
' :iColor:顶点颜色
' :最深颜色
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Sub GradientFillColor(ByRef tTV As TRIVERTEX, ByVal iColor As Long)
Dim iRed As Long
Dim iGreen As Long
Dim iBlue As Long
'/* Separate color into RGB
iRed = (iColor And &HFF&) * &H100&
iGreen = (iColor And &HFF00&)
iBlue = (iColor And &HFF0000) \ &H100&
'/* Make Red color a UShort
If (iRed And &H8000&) = &H8000& Then
tTV.Red = (iRed And &H7F00&)
tTV.Red = tTV.Red Or &H8000
Else
tTV.Red = iRed
End If
'/* Make Green color a UShort
If (iGreen And &H8000&) = &H8000& Then
tTV.Green = (iGreen And &H7F00&)
tTV.Green = tTV.Green Or &H8000
Else
tTV.Green = iGreen
End If
'/* Make Blue color a UShort
If (iBlue And &H8000&) = &H8000& Then
tTV.Blue = (iBlue And &H7F00&)
tTV.Blue = tTV.Blue Or &H8000
Else
tTV.Blue = iBlue
End If
End Sub