vb程序总在最前显示和窗口透明化
- 提问者网友:聂風
- 2021-08-22 12:01
- 五星知识达人网友:洒脱疯子
- 2021-08-22 12:59
'窗体置前代码
Private 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)
Private sub Form_Load()
myval = SetWindowPos(Form1.hWnd, -1, 0, 0, 0, 0, 3)
End Sub
'VB透明代码
'窗体Form1代码:
Private Sub Form_Load()
Me.BackColor = vbBlue
'Text1.BackColor = vbWhite
Dim rtn As Long
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, vbBlue, 190, LWA_COLORKEY
End Sub
'模块Module1代码:
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 Const WS_EX_LAYERED = &H80000
Public Const GWL_EXSTYLE = (-20)
Public Const LWA_ALPHA = &H2
Public Const LWA_COLORKEY = &H1
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
- 1楼网友:夜风逐马
- 2021-08-22 13:06
透明度
OPACITY =透明
在前
topmost = 在前