2012-01-09 29 views
1

我正在使用mciSendString來播放視頻,但我無法在視頻頂部放置任何標籤或按鈕等控件。如何在視頻之上添加另一個控件?如何將其他控件放在視頻之上?

下面是代碼:

公共類Form1中

私人聲明函數mciSendString庫 「WINMM.DLL」 別名 「mciSendStringA」(BYVAL lpstrCommand作爲字符串,BYVAL lpstrReturnString作爲字符串,BYVAL uReturnLength作爲整數,BYVAL hwndCallback作爲整數)作爲整數

昏暗的文件名作爲字符串

昏暗retVal的作爲整數

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 
    filename = Chr(34) & "D:\farm.wmv" & Chr(34) 
    retVal = mciSendString("open " & filename & " type mpegvideo alias movie parent " & Panel1.Handle.ToInt32 & " style child", 0, 0, 0) 

    retVal = mciSendString("put movie window at 0 0 201 127", 0, 0, 0) 
    retVal = mciSendString("play movie", 0, 0, 0) 
End Sub End Class 

前:(扣1可見)

enter image description here

後:(按鈕1不再可見)

enter image description here

+0

爲什麼你想讓控件位於視頻之上?您是否嘗試過['BringToFront'方法](http://msdn.microsoft.com/zh-cn/library/system.windows.forms.control.bringtofront.aspx)? – 2012-01-10 06:11:47

+0

@CodyGray我需要我的表單窗口爲200 x 150,因此我的視頻和按鈕空間更少,所以我需要它們位於視頻之上。用一個圖片框替換面板似乎解決了我的問題(在發佈問題後嘗試) – 2012-01-10 06:29:22

回答

0

在t中設置指定的子控件的索引他收集到指定的索引值。

Control.ControlCollection.SetChildIndex方法

例如,如果按鈕是內部圖片框控件,然後只設置:

PictureBox.Controls.Setchildindex(control,newIndex) 

這將做的工作。

相關問題