永发信息网

vb程序总在最前显示和窗口透明化

答案:2  悬赏:30  手机版
解决时间 2021-08-22 21:32
  • 提问者网友:聂風
  • 2021-08-22 12:01
Form1.show 1除外,透明化后让控仵也要触摸不到.谢了.
最佳答案
  • 五星知识达人网友:洒脱疯子
  • 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 = 在前

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