
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
/*****************************************************/
/*★ マウスのクリックで Wave を演奏する 前田 稔 ★*/
/*****************************************************/
using System;
using System.Drawing;
using System.Windows.Forms;
public class MyForm : Form
{
System.Media.SoundPlayer player;
public MyForm()
{
this.Text = "Wave Play";
player = new System.Media.SoundPlayer(@"c:\data\test\chimes.wav");
//player = new System.Media.SoundPlayer(@"c:\data\test\ringin.wav");
}
// Destructor は無くても良い
~MyForm()
{
player.Dispose();
}
protected override void OnMouseDown(MouseEventArgs e)
{
this.Text = "Mouse Down";
player.Play();
//player.PlaySync();
this.Text = "Exit";
}
}
class form01
{
public static void Main()
{
MyForm mf = new MyForm();
Application.Run(mf);
}
}
|
System.Media.SoundPlayer player;
player = new System.Media.SoundPlayer(@"c:\data\test\chimes.wav");
//player = new System.Media.SoundPlayer(@"c:\data\test\ringin.wav");
|
player.Play();
//player.PlaySync();
|
// Destructor は無くても良い
~MyForm()
{
player.Dispose();
}
|
![]()
/*********************************************/
/*★ 左クリックで開始、右で停止 前田 稔 ★*/
/*********************************************/
using System;
using System.Drawing;
using System.Windows.Forms;
public class MyForm : Form
{
System.Media.SoundPlayer player;
public MyForm()
{
this.Text = "Wave Play";
player = new System.Media.SoundPlayer(@"C:\DATA\Test\Chimes.wav");
//player = new System.Media.SoundPlayer(@"C:\DATA\Test\ringin.wav");
}
/*
// Destructor は無くても良い
~MyForm()
{
player.Dispose();
}
*/
protected override void OnMouseDown(MouseEventArgs e)
{ if (e.Button == MouseButtons.Left) //マウスの左ボタン
{ player.PlayLooping(); }
if (e.Button == MouseButtons.Right) //マウスの右ボタン
{ player.Stop(); }
}
}
class form01
{
public static void Main()
{
MyForm mf = new MyForm();
Application.Run(mf);
}
}
|
if (e.Button == MouseButtons.Left) //マウスの左ボタン
{ player.PlayLooping(); }
if (e.Button == MouseButtons.Right) //マウスの右ボタン
{ player.Stop(); }
|
![]()