首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

窗体透明后无法播放视频解决方案

2012-02-05 
窗体透明后无法播放视频[codeVB][/code]Private Declare Function GetWindowLong Lib user32 Alias Ge

窗体透明后无法播放视频
[code=VB][/code]
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 NoTwinkle(hwnd As Long)
  Dim rtn As Long
   
  rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
  rtn = rtn Or WS_EX_LAYERED
  SetWindowLong hwnd, GWL_EXSTYLE, rtn
  SetLayeredWindowAttributes hwnd, 0, 192, LWA_COLORKEY And LWA_ALPHA
End Sub




Private Sub Command1_Click()
MediaPlayer1.FileName = "D:\Downloads\电影\1.rmvb"
End Sub



Private Sub Form_Load()
NoTwinkle Me.hwnd
End Sub



程序运行以后播放视频无法显示其内容!

[解决办法]
那当然,因为播放视频的控件也跟着透明了嘛。
可以使用SetWindowRgn来代替这种透明方式。
[解决办法]
或许是因为播放的视屏是直接驱动写到屏幕的,就像PRINT Screen 无法复制视屏内容一个道理
如果要视屏透明就有点难度
[解决办法]
使用CreateRectRgn将你播放视频的区域连成一个GDI区域(查找创建异形窗口之类的代码,网上非常多),然后用SetWindowRgn设置此区域为窗口区域就行了。

热点排行