请问在VB6.0中如何将窗体的形状变得像windows media player那样呢?有什么免费的控件可以做到吗?
1个回答
展开全部
具体指什么?是不规则窗体吗?你可以这样做:
先创建一个图片(作为装窗体的背景图片,要透明的地方用一个不常用的颜色代替(注意:不能使用柔话处理!)
然后窗体的样式设为0(就是不显示边框)
接下来窗体的picture设为你刚才的图片 然后复制以下代码:
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
Form1
Private Sub Form_Load()
Dim rtn As Long
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong Me.hWnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes Me.hWnd, rgb(透明部分的颜色的R),(颜色的G),(颜色的BLUE), 0, LWA_COLORKEY
End Sub
先创建一个图片(作为装窗体的背景图片,要透明的地方用一个不常用的颜色代替(注意:不能使用柔话处理!)
然后窗体的样式设为0(就是不显示边框)
接下来窗体的picture设为你刚才的图片 然后复制以下代码:
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
Form1
Private Sub Form_Load()
Dim rtn As Long
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong Me.hWnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes Me.hWnd, rgb(透明部分的颜色的R),(颜色的G),(颜色的BLUE), 0, LWA_COLORKEY
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询