VB.Net Tutorial/Windows/Media Player — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:40, 26 мая 2010
Windows Media Player control
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class UseMediaPlayer
public Shared Sub Main
Application.Run(New FrmMediaPlayer)
End Sub
End class
Public Class FrmMediaPlayer
Inherits System.Windows.Forms.Form
" action menus
Friend WithEvents applicationMenu As MainMenu
Friend WithEvents fileItem As MenuItem
Friend WithEvents openItem As MenuItem
Friend WithEvents exitItem As MenuItem
Friend WithEvents aboutItem As MenuItem
Friend WithEvents aboutMessageItem As MenuItem
" media player control
Friend WithEvents player As AxMediaPlayer.AxMediaPlayer
Friend WithEvents openMediaFileDialog As OpenFileDialog
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(FrmMediaPlayer))
Me.applicationMenu = New System.Windows.Forms.MainMenu()
Me.fileItem = New System.Windows.Forms.MenuItem()
Me.openItem = New System.Windows.Forms.MenuItem()
Me.exitItem = New System.Windows.Forms.MenuItem()
Me.aboutItem = New System.Windows.Forms.MenuItem()
Me.aboutMessageItem = New System.Windows.Forms.MenuItem()
Me.openMediaFileDialog = New System.Windows.Forms.OpenFileDialog()
Me.player = New AxMediaPlayer.AxMediaPlayer()
CType(Me.player, System.ruponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
"
"applicationMenu
"
Me.applicationMenu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.fileItem, Me.aboutItem})
"
"fileItem
"
Me.fileItem.Index = 0
Me.fileItem.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.openItem, Me.exitItem})
Me.fileItem.Text = "File"
"
"openItem
"
Me.openItem.Index = 0
Me.openItem.Text = "Open"
"
"exitItem
"
Me.exitItem.Index = 1
Me.exitItem.Text = "Exit"
"
"aboutItem
"
Me.aboutItem.Index = 1
Me.aboutItem.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.aboutMessageItem})
Me.aboutItem.Text = "About"
"
"aboutMessageItem
"
Me.aboutMessageItem.Index = 0
Me.aboutMessageItem.Text = "About Windows Media Player"
"
"player
"
Me.player.Name = "player"
Me.player.OcxState = CType(resources.GetObject("player.OcxState"), System.Windows.Forms.AxHost.State)
Me.player.Size = New System.Drawing.Size(312, 288)
Me.player.TabIndex = 0
"
"FrmMediaPlayer
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(312, 287)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.player})
Me.Menu = Me.applicationMenu
Me.Name = "FrmMediaPlayer"
Me.Text = "MediaPlayer"
CType(Me.player, System.ruponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub openItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles openItem.Click
openMediaFileDialog.ShowDialog()
player.FileName = openMediaFileDialog.FileName
player.Size = New Size(player.ImageSourceWidth, player.ImageSourceHeight)
Me.Size = New Size(player.Size.Width + 20,player.Size.Height + 60)
End Sub " openItem_Click
" exit application
Private Sub exitItem_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles exitItem.Click
Application.Exit()
End Sub " exitItem_Click
Private Sub aboutMessageItem_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles aboutMessageItem.Click
player.AboutBox()
End Sub
End Class