求一个VB中API编程的例子!
发布网友
发布时间:2022-05-01 22:47
我来回答
共1个回答
热心网友
时间:2022-06-24 13:25
和楼上的东西差不多...不过透明度渐变,多用了一个Sleep函数..
如果是vista的话..下面有个华丽的..(AERO..)
Option
Explicit
Private
Declare
Function
SetLayeredWindowAttributes
Lib
"user32"
(ByVal
hwnd
As
Long,
ByVal
crKey
As
Long,
ByVal
bAlpha
As
Byte,
ByVal
dwFlags
As
Long)
As
Long
Private
Declare
Function
SetWindowLong
Lib
"user32"
Alias
"SetWindowLongA"
(ByVal
hwnd
As
Long,
ByVal
nIndex
As
Long,
ByVal
dwNewLong
As
Long)
As
Long
Private
Declare
Sub
Sleep
Lib
"kernel32"
(ByVal
dwMilliseconds
As
Long)
Const
GWL_EXSTYLE
=
(-20)
Const
WS_EX_LAYERED
=
&H80000
'窗口具有透眀属性(Win2000)以上
Private
Declare
Function
GetWindowLong
Lib
"user32"
Alias
"GetWindowLongA"
(ByVal
hwnd
As
Long,
ByVal
nIndex
As
Long)
As
Long
Const
LWA_ALPHA
=
&H2
Private
Sub
Form_Load()
Dim
r&
Show
r
=
GetWindowLong(hwnd,
GWL_EXSTYLE)
SetWindowLong
hwnd,
GWL_EXSTYLE,
r
Or
WS_EX_LAYERED
Dim
i
As
Integer,
w
As
Boolean
w
=
True
Do
Select
Case
w
Case
True
For
i
=
90
To
254
SetLayeredWindowAttributes
hwnd,
0,
i,
LWA_ALPHA
DoEvents
Sleep
10
Next
i
Case
False
i
=
254
For
i
=
254
To
90
Step
-1
SetLayeredWindowAttributes
hwnd,
0,
i,
LWA_ALPHA
DoEvents
Sleep
10
Next
i
End
Select
w
=
Not
w
Loop
End
Sub
Private
Sub
Form_Unload(Cancel
As
Integer)
End
End
Sub
'------------------------下面vista
only(home
basic不行的说)...
'------不同的一个程序
Option
Explicit
Private
Declare
Function
DwmIsCompositionEnabled
Lib
"dwmapi.dll"
(ByRef
enabledptr
As
Long)
As
Long
Private
Declare
Function
DwmExtendFrameIntoClientArea
Lib
"dwmapi.dll"
(ByVal
hwnd
As
Long,
margin
As
MARGINS)
As
Long
Private
Type
MARGINS
m_Left
As
Long
m_Right
As
Long
m_Top
As
Long
m_Bottom
As
Long
End
Type
Private
Declare
Function
DwmEnableBlurBehindWindow
Lib
"dwmapi"
(ByVal
hwnd
As
Long,
pBlurBehind
As
DWM_BLURBEHIND)
As
Long
Private
Declare
Function
DwmEnableComposition
Lib
"dwmapi"
(ByVal