2014-11-21 80 views
0

我有一個播放視頻的應用程序。我正在使用MCI播放視頻並將其附加到面板控制。我在主窗體和所有控件上點擊鼠標點擊,但是當我點擊播放MCI的視頻時,它沒有檢測到鼠標點擊。檢測鼠標點擊與MCI命令播放的視頻

如何檢測用MCI命令播放的視頻上的鼠標點擊?

+0

如果您將某些東西附加到面板控件上,那麼如何處理點擊? UI控件應該能夠處理點擊。 – techvice 2014-11-21 04:32:20

+0

由於某種原因,這不起作用。那是我嘗試的第一件事,將面板句柄傳遞給mci視頻,讓該面板捕獲鼠標點擊,並將其添加到主窗體控件中。鼠標點擊通過整個表單並單擊表單後面的任何內容。主窗體從不捕捉鼠標點擊 – iedoc 2014-11-21 05:09:10

回答

0

我終於通過創建一個無邊框形式,我傳遞給mci視頻的句柄來工作。我將TransparencyKey設置爲背景顏色。這樣,視頻仍顯示,但鼠標點擊通過主窗體。

我設置在主窗體的窗體的大小和位置,因爲某種原因,它不會從形式,我仍然試圖理解爲什麼

public VideoForm() 
    { 
     this.FormBorderStyle = FormBorderStyle.None; 
     this.TransparencyKey = Color.White; 
     this.TopMost = true; 
    } 

    public void PlayVideo(int width, int height, ScreenControl control) 
    { 
     string mciCommand = string.Format("open \"{0}\" Type mpegvideo alias {1} parent {2} style child", control.Location(), control.Name, this.Handle.ToString()); 
     int error = WinApi.mciSendString(mciCommand, null, 0, IntPtr.Zero); 

     mciCommand = string.Format("put {0} window at 0 0 {1} {2}", control.Name, width, height); 
     error = WinApi.mciSendString(mciCommand, null, 0, IntPtr.Zero); 

     mciCommand = string.Format("seek {0} to 0", control.Name); 
     error = WinApi.mciSendString(mciCommand, null, 0, IntPtr.Zero); 

     mciCommand = string.Format("play {0} repeat", control.Name); 
     error = WinApi.mciSendString(mciCommand, null, 0, IntPtr.Zero); 

     this.Show(); 
    } 
裏面設置他們的工作