永发信息网

VB解释下这个代码

答案:1  悬赏:70  手机版
解决时间 2021-07-18 05:18
  • 提问者网友:流星是天使的眼泪
  • 2021-07-17 06:44

这是一个半透明窗体的代码解释下这个代码吧!

格式:Msgbox" 小伊伊" ' 弹出提示窗口

----------------------------------------------------

Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) _
As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long) _
As Long

Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA As Long = &H2
Private Const WS_EX_LAYERED As Long = &H80000

Private Declare Function SetLayeredWindowAttributes Lib "user32" _
(ByVal hwnd As Long, _
ByVal crKey As Long, _
ByVal bAlpha As Long, _
ByVal dwFlags As Long) _
As Long

Private Sub Form_Load()
Dim p As Long
p = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, p Or WS_EX_LAYERED)
Call SetLayeredWindowAttributes(Me.hwnd, 0, 127, LWA_ALPHA)
End Sub

最佳答案
  • 五星知识达人网友:一秋
  • 2021-07-17 07:27

p = GetWindowLong(Me.hwnd, GWL_EXSTYLE) 得到当前的扩展的窗口风格
Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, p Or WS_EX_LAYERED) 设置当前窗口的具有透明效果的扩展风格
Call SetLayeredWindowAttributes(Me.hwnd, 0, 127, LWA_ALPHA) 设置当前窗口的透明度127这个数值越小越透明....


---------------------------------------------


在前面那些东西都是声明dll里的函数,都是user32.dll里的,属于windows的dll

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯