' 大致就是这么个意思。 ' 主要是那个公式。Option ExplicitPrivate Declare Function GetDC Lib "user32.dll" (ByVal hwnd As Long) As Long Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As Long, ByVal hdc As Long) As Long Private Declare Function FrameRect Lib "user32.dll" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long Private Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End TypePrivate Sub Form_Load() Dim rct As RECT Dim i As Long Dim hBrush As Long
hBrush = CreateSolidBrush(vbBlack)
For i = (Screen.Width / Screen.TwipsPerPixelX - 200) / 2 To (Screen.Width / Screen.TwipsPerPixelX - 200) / 2 + 200 Step 3 With rct .Left = i .Right = (Screen.Width / Screen.TwipsPerPixelX - 200) / 2 + 200 - (i - (Screen.Width / Screen.TwipsPerPixelX - 200) / 2) .Top = i .Bottom = (Screen.Width / Screen.TwipsPerPixelX - 200) / 2 + 200 - (i - (Screen.Width / Screen.TwipsPerPixelX - 200) / 2) End With FrameRect GetDC(0), rct, hBrush Sleep (1) Next i
试试这个(win95不行)。此为未优化版本。 技术不是大问题,主要还是算法。VERSION 5.00 Begin VB.Form Form1 BorderStyle = 3 'Fixed Dialog Caption = "Form Fade" ClientHeight = 1215 ClientLeft = 2325 ClientTop = 2790 ClientWidth = 3480 LinkTopic = "Form1" LockControls = -1 'True MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 1215 ScaleWidth = 3480 ShowInTaskbar = 0 'False StartUpPosition = 3 'Windows Default Begin VB.CommandButton Command2 Caption = "关闭窗口的效果" Height = 810 Left = 1815 TabIndex = 1 Top = 180 Width = 1515 End Begin VB.CommandButton Command1 Caption = "打开窗口的效果" Height = 810 Left = 150 TabIndex = 0 Top = 180 Width = 1515 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False ''''''''''''''''''''''''''''''' ' Written by James (James0001 on CSDN) ' 由 James (CSDN: James0001) 编写 ' Option Explicit Private Type POINTAPI x As Long y As Long End Type Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type LARGE_INTEGER lowpart As Long highpart As Long End Type Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Declare Function SetROP2 Lib "gdi32" (ByVal hdc As Long, ByVal nDrawMode As Long) As Long Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long Private Declare Function PolyPolygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As Long) As Long Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long Private Declare Function GetDCEx Lib "user32" (ByVal hwnd As Long, ByVal hrgnclip As Long, ByVal fdwOptions As Long) As Long Private Const DCX_CACHE = &H2& Private Const DCX_LOCKWINDOWUPDATE = &H400& Private Const R2_NOT = 6 ' Dn Private Const INFINITE = &HFFFF& ' Infinite timeout Private Declare Function MsgWaitForMultipleObjects Lib "user32" (ByVal nCount As Long, ByVal pHandles As Long, ByVal fWaitAll As Long, ByVal dwMilliseconds As Long, ByVal dwWakeMask As Long) As Long Private Declare Function CreateWaitableTimerA Lib "kernel32" (ByVal lpTimerAttributes As Long, ByVal bManualReset As Long, ByVal lpTimerName As Long) As Long Private Declare Function CreateWaitableTimerW Lib "kernel32" (ByVal lpTimerAttributes As Long, ByVal bManualReset As Long, ByVal lpTimerName As Long) As Long Private Declare Function SetWaitableTimer Lib "kernel32" (ByVal hTimer As Long, pDueTime As LARGE_INTEGER, ByVal lPeriod As Long, ByVal pfnCompletionRoutine As Long, ByVal lpArgToCompletionRoutine As Long, ByVal fResume As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private Type WINDOWPLACEMENT Length As Long flags As Long showCmd As Long ptMinPosition As POINTAPI ptMaxPosition As POINTAPI rcNormalPosition As RECT End Type Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long Private Const BLACK_PEN = 7 Private Const BLACK_BRUSH = 4 Private Const NULL_BRUSH = 5 Private Const NULL_PEN = 8 Private Const QS_MOUSEMOVE = &H2 Private Const QS_MOUSEBUTTON = &H4 Private Const QS_KEY = &H1 Private Const QS_POSTMESSAGE = &H8 Private Const QS_TIMER = &H10 Private Const QS_PAINT = &H20 Private Const QS_HOTKEY = &H80 Private Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON) Private Const QS_INPUT = (QS_MOUSE Or QS_KEY) Private Const QS_ALLEVENTS = (QS_INPUT Or QS_POSTMESSAGE Or QS_TIMER Or QS_PAINT Or QS_HOTKEY) Private Const WAIT_FAILED = &HFFFFFFFF Private Const STATUS_WAIT_0 = &H0& Private Const WAIT_OBJECT_0 = (STATUS_WAIT_0) + 0&Private Const MICROSEC_PER_HECTONANOSEC As Long = 10& Private Const PI As Double = 3.14159265358979 Private Const PI2 As Double = 6.28318530717958 Private Const PI_2 As Double = 1.5707963267949 Private Const DEG As Double = 1.74532925199433E-02
'接着发 Private Sub FormFade(ByVal hwnd As Long, wndRect As RECT, ByVal bFadeIn As Boolean) Const FADEINSTEP As Long = 10000& '帧与帧之间的间隔(单位:微秒) '最大值为214748364(微秒)等于3分34秒 Const POLYCOUNT As Long = 10& '每帧最大多边形的数量 Const POLYVERTCOUNT As Long = 4& '多边形的顶点数量(暂定为4 = 四边形) Const FADEINROTANGLE As Double = 17# * DEG '每一帧多边形旋转的角度 Const FADEINDIASTEP As Double = 1# / 30# '每一帧多边形顶点与中心距离的增量 Const FADEINDIAMIN As Double = 0 '起始顶点与中心距离 Const FADEININITDIAM As Double = FADEINDIAMIN + (POLYCOUNT * FADEINDIASTEP)
On Error GoTo formfade_error_exit
Dim i As Long, l As Long, diam As Double, rotang As Double, _ tdbl1 As Double, tdbl2 As Double, tdbl3 As Double, tdbl4 As Double, _ tdbl5 As Double, tdbl6 As Double, tdbl7 As Double, tdbl8 As Double, _ dblSins(POLYVERTCOUNT - 1&) As Double, dblCoss(POLYVERTCOUNT - 1&) As Double Dim scrDC As Long, blckPen As Long, nullBrush As Long Dim diams(POLYVERTCOUNT - 1&) As Double, rotCent As POINTAPI, initDiam As Double Dim polies(POLYVERTCOUNT - 1&, POLYCOUNT - 1&) As POINTAPI Dim tmrWait As Long, tmrDue As LARGE_INTEGER, dblForMin As Double, dblForMax As Double Dim waitRetval As Long, dblForStep As Double
SetWaitableTimer tmrWait, tmrDue, 0&, 0&, 0&, 0& Do If waitRetval = (WAIT_OBJECT_0 + 1&) Then DoEvents waitRetval = MsgWaitForMultipleObjects(1&, VarPtr(tmrWait), 0&, INFINITE, QS_ALLEVENTS) Loop Until waitRetval = WAIT_OBJECT_0 scrDC = GetDCEx(0&, 0&, DCX_CACHE Or DCX_LOCKWINDOWUPDATE) If scrDC Then SelectObject scrDC, blckPen SelectObject scrDC, nullBrush SetROP2 scrDC, R2_NOT
If ((bFadeIn = True) And (diam > 1#)) Or _ ((bFadeIn = False) And (diam < FADEINDIAMIN)) Then Polygon scrDC, polies(0&, POLYCOUNT - 1&), POLYVERTCOUNT CopyMemory polies(0&, 1&), polies(0&, 0&), LenB(polies(0&, 0&)) * _ (POLYVERTCOUNT * (POLYCOUNT - 1&)) Else If ((bFadeIn = True) And (diam >= FADEININITDIAM)) Or _ ((bFadeIn = False) And (diam <= 1#)) Then Polygon scrDC, polies(0&, POLYCOUNT - 1&), POLYVERTCOUNT End If CopyMemory polies(0&, 1&), polies(0&, 0&), LenB(polies(0&, 0&)) * _ (POLYVERTCOUNT * (POLYCOUNT - 1&)) For i = 0& To POLYVERTCOUNT - 1& polies(i, 0&).x = CLng(dblCoss(i) * diam * diams(i)) + rotCent.x polies(i, 0&).y = CLng(dblSins(i) * diam * diams(i)) + rotCent.y Next Polygon scrDC, polies(0&, 0&), POLYVERTCOUNT End If
'If bFadeIn Then For i = 0& To POLYVERTCOUNT - 1& tdbl3 = dblSins(i) 'sin(A + B) = sin(A) * cos(B) + cos(A) * sin(B) dblSins(i) = dblSins(i) * tdbl2 + dblCoss(i) * tdbl1 'cos(A + B) = cos(A) * cos(B) - sin(A) * sin(B) dblCoss(i) = dblCoss(i) * tdbl2 - tdbl3 * tdbl1 Next rotang = rotang + FADEINROTANGLE 'Else ' For i = 0& To POLYVERTCOUNT - 1& ' tdbl3 = dblSins(i) ' dblSins(i) = dblSins(i) * tdbl2 - dblCoss(i) * tdbl1 ' dblCoss(i) = dblCoss(i) * tdbl2 + tdbl3 * tdbl1 ' Next ' rotang = rotang - FADEINROTANGLE 'End If
ReleaseDC 0&, scrDC End If Next
CloseHandle tmrWait LockWindowUpdate 0&
Exit Sub formfade_error_exit: If scrDC Then ReleaseDC 0&, scrDC If tmrWait Then CloseHandle tmrWait LockWindowUpdate 0& End SubPrivate Sub Command1_Click() Me.Hide Dim lwndRect As RECT GetWindowRect hwnd, lwndRect FormFade Me.hwnd, lwndRect, True Me.Show Me.Refresh End SubPrivate Sub Command2_Click() Me.Hide Dim lwndRect As RECT GetWindowRect hwnd, lwndRect FormFade Me.hwnd, lwndRect, False Me.Show Me.Refresh End SubPrivate Sub Form_Load() Dim lwndRect As RECT GetWindowRect hwnd, lwndRect FormFade Me.hwnd, lwndRect, True End SubPrivate Sub Form_Unload(Cancel As Integer) Me.Hide Dim lwndRect As RECT GetWindowRect hwnd, lwndRect FormFade Me.hwnd, lwndRect, False End Sub
主要是图形,应该有个公式。 :)
' 主要是那个公式。Option ExplicitPrivate Declare Function GetDC Lib "user32.dll" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32.dll" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function FrameRect Lib "user32.dll" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePrivate Sub Form_Load()
Dim rct As RECT
Dim i As Long
Dim hBrush As Long
hBrush = CreateSolidBrush(vbBlack)
For i = (Screen.Width / Screen.TwipsPerPixelX - 200) / 2 To (Screen.Width / Screen.TwipsPerPixelX - 200) / 2 + 200 Step 3
With rct
.Left = i
.Right = (Screen.Width / Screen.TwipsPerPixelX - 200) / 2 + 200 - (i - (Screen.Width / Screen.TwipsPerPixelX - 200) / 2)
.Top = i
.Bottom = (Screen.Width / Screen.TwipsPerPixelX - 200) / 2 + 200 - (i - (Screen.Width / Screen.TwipsPerPixelX - 200) / 2)
End With
FrameRect GetDC(0), rct, hBrush
Sleep (1)
Next i
DeleteObject hBrush
ReleaseDC 0, GetDC(0)
End Sub
技术不是大问题,主要还是算法。VERSION 5.00
Begin VB.Form Form1
BorderStyle = 3 'Fixed Dialog
Caption = "Form Fade"
ClientHeight = 1215
ClientLeft = 2325
ClientTop = 2790
ClientWidth = 3480
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1215
ScaleWidth = 3480
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command2
Caption = "关闭窗口的效果"
Height = 810
Left = 1815
TabIndex = 1
Top = 180
Width = 1515
End
Begin VB.CommandButton Command1
Caption = "打开窗口的效果"
Height = 810
Left = 150
TabIndex = 0
Top = 180
Width = 1515
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'''''''''''''''''''''''''''''''
' Written by James (James0001 on CSDN)
' 由 James (CSDN: James0001) 编写
'
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type LARGE_INTEGER
lowpart As Long
highpart As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function SetROP2 Lib "gdi32" (ByVal hdc As Long, ByVal nDrawMode As Long) As Long
Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function PolyPolygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Declare Function GetDCEx Lib "user32" (ByVal hwnd As Long, ByVal hrgnclip As Long, ByVal fdwOptions As Long) As Long
Private Const DCX_CACHE = &H2&
Private Const DCX_LOCKWINDOWUPDATE = &H400&
Private Const R2_NOT = 6 ' Dn
Private Const INFINITE = &HFFFF& ' Infinite timeout
Private Declare Function MsgWaitForMultipleObjects Lib "user32" (ByVal nCount As Long, ByVal pHandles As Long, ByVal fWaitAll As Long, ByVal dwMilliseconds As Long, ByVal dwWakeMask As Long) As Long
Private Declare Function CreateWaitableTimerA Lib "kernel32" (ByVal lpTimerAttributes As Long, ByVal bManualReset As Long, ByVal lpTimerName As Long) As Long
Private Declare Function CreateWaitableTimerW Lib "kernel32" (ByVal lpTimerAttributes As Long, ByVal bManualReset As Long, ByVal lpTimerName As Long) As Long
Private Declare Function SetWaitableTimer Lib "kernel32" (ByVal hTimer As Long, pDueTime As LARGE_INTEGER, ByVal lPeriod As Long, ByVal pfnCompletionRoutine As Long, ByVal lpArgToCompletionRoutine As Long, ByVal fResume As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Const BLACK_PEN = 7
Private Const BLACK_BRUSH = 4
Private Const NULL_BRUSH = 5
Private Const NULL_PEN = 8
Private Const QS_MOUSEMOVE = &H2
Private Const QS_MOUSEBUTTON = &H4
Private Const QS_KEY = &H1
Private Const QS_POSTMESSAGE = &H8
Private Const QS_TIMER = &H10
Private Const QS_PAINT = &H20
Private Const QS_HOTKEY = &H80
Private Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON)
Private Const QS_INPUT = (QS_MOUSE Or QS_KEY)
Private Const QS_ALLEVENTS = (QS_INPUT Or QS_POSTMESSAGE Or QS_TIMER Or QS_PAINT Or QS_HOTKEY)
Private Const WAIT_FAILED = &HFFFFFFFF
Private Const STATUS_WAIT_0 = &H0&
Private Const WAIT_OBJECT_0 = (STATUS_WAIT_0) + 0&Private Const MICROSEC_PER_HECTONANOSEC As Long = 10&
Private Const PI As Double = 3.14159265358979
Private Const PI2 As Double = 6.28318530717958
Private Const PI_2 As Double = 1.5707963267949
Private Const DEG As Double = 1.74532925199433E-02
Private Sub FormFade(ByVal hwnd As Long, wndRect As RECT, ByVal bFadeIn As Boolean)
Const FADEINSTEP As Long = 10000& '帧与帧之间的间隔(单位:微秒)
'最大值为214748364(微秒)等于3分34秒
Const POLYCOUNT As Long = 10& '每帧最大多边形的数量
Const POLYVERTCOUNT As Long = 4& '多边形的顶点数量(暂定为4 = 四边形)
Const FADEINROTANGLE As Double = 17# * DEG '每一帧多边形旋转的角度
Const FADEINDIASTEP As Double = 1# / 30# '每一帧多边形顶点与中心距离的增量
Const FADEINDIAMIN As Double = 0 '起始顶点与中心距离
Const FADEININITDIAM As Double = FADEINDIAMIN + (POLYCOUNT * FADEINDIASTEP)
On Error GoTo formfade_error_exit
Dim i As Long, l As Long, diam As Double, rotang As Double, _
tdbl1 As Double, tdbl2 As Double, tdbl3 As Double, tdbl4 As Double, _
tdbl5 As Double, tdbl6 As Double, tdbl7 As Double, tdbl8 As Double, _
dblSins(POLYVERTCOUNT - 1&) As Double, dblCoss(POLYVERTCOUNT - 1&) As Double
Dim scrDC As Long, blckPen As Long, nullBrush As Long
Dim diams(POLYVERTCOUNT - 1&) As Double, rotCent As POINTAPI, initDiam As Double
Dim polies(POLYVERTCOUNT - 1&, POLYCOUNT - 1&) As POINTAPI
Dim tmrWait As Long, tmrDue As LARGE_INTEGER, dblForMin As Double, dblForMax As Double
Dim waitRetval As Long, dblForStep As Double
rotCent.x = (wndRect.Left + wndRect.Right) \ 2&
rotCent.y = (wndRect.Top + wndRect.Bottom) \ 2&
blckPen = GetStockObject(BLACK_PEN)
nullBrush = GetStockObject(NULL_BRUSH)
LockWindowUpdate hwnd
tmrWait = CreateWaitableTimerA(0&, 0&, 0&)
With tmrDue
.lowpart = -(FADEINSTEP * MICROSEC_PER_HECTONANOSEC)
.highpart = &HFFFFFFFF
End With
tdbl1 = CDbl(wndRect.Top - rotCent.y): tdbl5 = tdbl1 * tdbl1
tdbl2 = CDbl(wndRect.Left - rotCent.x): tdbl6 = tdbl2 * tdbl2
tdbl3 = CDbl(wndRect.Bottom - rotCent.y): tdbl7 = tdbl3 * tdbl3
tdbl4 = CDbl(wndRect.Right - rotCent.x): tdbl8 = tdbl4 * tdbl4
diams(0&) = Sqr(tdbl5 + tdbl6): diams(1&) = Sqr(tdbl5 + tdbl8)
diams(3&) = Sqr(tdbl7 + tdbl6): diams(2&) = Sqr(tdbl7 + tdbl8)
dblSins(0&) = Sin(Atn(tdbl1 / diams(0&))): dblCoss(0&) = Cos(Atn(tdbl2 / diams(0&)) + PI)
dblSins(1&) = Sin(Atn(tdbl1 / diams(1&))): dblCoss(1&) = Cos(Atn(tdbl4 / diams(1&)))
dblSins(2&) = Sin(Atn(tdbl3 / diams(2&))): dblCoss(2&) = Cos(Atn(tdbl4 / diams(2&)))
dblSins(3&) = Sin(Atn(tdbl3 / diams(3&))): dblCoss(3&) = Cos(Atn(tdbl2 / diams(3&)) + PI)
tdbl1 = Sin(FADEINROTANGLE): tdbl2 = Cos(FADEINROTANGLE)
If bFadeIn Then
dblForMin = FADEINDIAMIN
dblForMax = 1# + ((POLYCOUNT + 1) * FADEINDIASTEP)
dblForStep = FADEINDIASTEP
Else
dblForMin = 1#
dblForMax = FADEINDIAMIN - ((POLYCOUNT) * FADEINDIASTEP)
dblForStep = -FADEINDIASTEP
End If
For diam = dblForMin To dblForMax Step dblForStep
SetWaitableTimer tmrWait, tmrDue, 0&, 0&, 0&, 0&
Do
If waitRetval = (WAIT_OBJECT_0 + 1&) Then DoEvents
waitRetval = MsgWaitForMultipleObjects(1&, VarPtr(tmrWait), 0&, INFINITE, QS_ALLEVENTS)
Loop Until waitRetval = WAIT_OBJECT_0
scrDC = GetDCEx(0&, 0&, DCX_CACHE Or DCX_LOCKWINDOWUPDATE)
If scrDC Then
SelectObject scrDC, blckPen
SelectObject scrDC, nullBrush
SetROP2 scrDC, R2_NOT
If ((bFadeIn = True) And (diam > 1#)) Or _
((bFadeIn = False) And (diam < FADEINDIAMIN)) Then
Polygon scrDC, polies(0&, POLYCOUNT - 1&), POLYVERTCOUNT
CopyMemory polies(0&, 1&), polies(0&, 0&), LenB(polies(0&, 0&)) * _
(POLYVERTCOUNT * (POLYCOUNT - 1&))
Else
If ((bFadeIn = True) And (diam >= FADEININITDIAM)) Or _
((bFadeIn = False) And (diam <= 1#)) Then
Polygon scrDC, polies(0&, POLYCOUNT - 1&), POLYVERTCOUNT
End If
CopyMemory polies(0&, 1&), polies(0&, 0&), LenB(polies(0&, 0&)) * _
(POLYVERTCOUNT * (POLYCOUNT - 1&))
For i = 0& To POLYVERTCOUNT - 1&
polies(i, 0&).x = CLng(dblCoss(i) * diam * diams(i)) + rotCent.x
polies(i, 0&).y = CLng(dblSins(i) * diam * diams(i)) + rotCent.y
Next
Polygon scrDC, polies(0&, 0&), POLYVERTCOUNT
End If
'If bFadeIn Then
For i = 0& To POLYVERTCOUNT - 1&
tdbl3 = dblSins(i)
'sin(A + B) = sin(A) * cos(B) + cos(A) * sin(B)
dblSins(i) = dblSins(i) * tdbl2 + dblCoss(i) * tdbl1
'cos(A + B) = cos(A) * cos(B) - sin(A) * sin(B)
dblCoss(i) = dblCoss(i) * tdbl2 - tdbl3 * tdbl1
Next
rotang = rotang + FADEINROTANGLE
'Else
' For i = 0& To POLYVERTCOUNT - 1&
' tdbl3 = dblSins(i)
' dblSins(i) = dblSins(i) * tdbl2 - dblCoss(i) * tdbl1
' dblCoss(i) = dblCoss(i) * tdbl2 + tdbl3 * tdbl1
' Next
' rotang = rotang - FADEINROTANGLE
'End If
ReleaseDC 0&, scrDC
End If
Next
CloseHandle tmrWait
LockWindowUpdate 0&
Exit Sub
formfade_error_exit:
If scrDC Then ReleaseDC 0&, scrDC
If tmrWait Then CloseHandle tmrWait
LockWindowUpdate 0&
End SubPrivate Sub Command1_Click()
Me.Hide
Dim lwndRect As RECT
GetWindowRect hwnd, lwndRect
FormFade Me.hwnd, lwndRect, True
Me.Show
Me.Refresh
End SubPrivate Sub Command2_Click()
Me.Hide
Dim lwndRect As RECT
GetWindowRect hwnd, lwndRect
FormFade Me.hwnd, lwndRect, False
Me.Show
Me.Refresh
End SubPrivate Sub Form_Load()
Dim lwndRect As RECT
GetWindowRect hwnd, lwndRect
FormFade Me.hwnd, lwndRect, True
End SubPrivate Sub Form_Unload(Cancel As Integer)
Me.Hide
Dim lwndRect As RECT
GetWindowRect hwnd, lwndRect
FormFade Me.hwnd, lwndRect, False
End Sub
这个软件应该是用DELPHI写的
不过它启动的时候会不断地修改前台窗体的Caption
变相的做广告, 有点讨厌
具体代码就不贴了,今天比较晚。资料很好查,相信很好找到。
高手!