vb 怎样制作全透明无边框的窗体,我是小白,希望能具体写下代码。
网上查到的所谓透明无边框的窗体边缘还是有条细线,我需要的是完全没有边框也没有标题栏,因为我在编译一个左面精灵的程序,不需要显示窗体,只想显示窗体上的flash控件,请大师...
网上查到的所谓透明无边框的窗体边缘还是有条细线,我需要的是完全没有边框也没有标题栏,因为我在编译一个左面精灵的程序,不需要显示窗体,只想显示窗体上的flash控件,请大师指点。
展开
3个回答
展开全部
首先,把窗体的BorderStyle属性设为0
然后,输入以下代码:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal HWnd As Long, ByVal nIndex 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 Function SetLayeredWindowAttributes Lib "user32" (ByVal HWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Private Sub Form_Load()
Me.AutoRedraw = True
Me.BackColor = &HFF0001
SetWindowLong Me.HWnd, GWL_EXSTYLE, GetWindowLong(Me.HWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.HWnd, &HFF0001, 0, LWA_COLORKEY
End Sub
运行后就是全透明无边框的窗体了
展开全部
不知道这种效果是否适合你,在窗体上打印出来的字都是透明的并且透明地方点击是不会点击到窗体的
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
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, _
ByVal crKey As Long, _
ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long
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) As Long
Public Sub transparence(ByVal Frm As Form)
Dim rtn As Long
rtn = GetWindowLong(Frm.hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong Frm.hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes Frm.hwnd, RGB(255, 255, 253), 0, LWA_COLORKEY
End Sub
'------------------------------↑↑↑↑↑↑↑↑↑↑↑↑模块↑↑↑↑↑↑↑↑↑↑↑↑----------------------
'------------------↓↓↓↓↓↓↓↓↓↓↓↓窗体并添加一个text1和command1↓↓↓↓↓↓↓↓↓↓↓----------------------
Private Sub Command1_Click()
Form1.ForeColor = RGB(255, 255, 253)
Print Text1.Text
transparence Me
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
首先,把窗体的BorderStyle属性设为0
然后,输入以下代码:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal HWnd As Long, ByVal nIndex 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 Function SetLayeredWindowAttributes Lib "user32" (ByVal HWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Private Sub Form_Load()
Me.AutoRedraw = True
Me.BackColor = &HFF0001
SetWindowLong Me.HWnd, GWL_EXSTYLE, GetWindowLong(Me.HWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.HWnd, &HFF0001, 0, LWA_COLORKEY
End Sub
运行后就是全透明无边框的窗体了
然后,输入以下代码:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal HWnd As Long, ByVal nIndex 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 Function SetLayeredWindowAttributes Lib "user32" (ByVal HWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Private Sub Form_Load()
Me.AutoRedraw = True
Me.BackColor = &HFF0001
SetWindowLong Me.HWnd, GWL_EXSTYLE, GetWindowLong(Me.HWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.HWnd, &HFF0001, 0, LWA_COLORKEY
End Sub
运行后就是全透明无边框的窗体了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询