Hack x Crack - Comunidad de Seguridad informática
Programación => Visual Basic => Mensaje iniciado por: DAV en Abril 01, 2012, 05:24:15 pm
-
Soy novato en programacion... en este momento tratando de trabajar con vb c# y lo q quiero hacer es crear un checkbox q al activar la casilla reproduzca un sonido.. desde ya agradezco su ayuda...
-
// a ver si me puden corregir
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
namespace TPN_1_Cursillo_2_Año
{
public partial class Form1 : Form
{
// Crear un temporizador para la hs.
Timer hora = new Timer();
int tiempoRest;
String txt1;
SoundPlayer segs = new SoundPlayer(@"C:\Windows\Media\alert_49.Wav");
public Form1()
{
InitializeComponent();
//delegado del evento tic
hora.Tick += new EventHandler(actualizar_hora);
hora.Start();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void actualizar_hora(object sender, EventArgs e)
{
label4.Text = DateTime.Now.ToLongTimeString();
}
void iniciarPrueba()
{
tiempoRest = 100;
txtTiempo.Text = " segundos";
timer1.Start();
}
private void button1_Click(object sender, EventArgs e)
{
iniciarPrueba();
}
private void timer1_Tick(object sender, EventArgs e)
{
tiempoRest -= 1;
txtTiempo.Text = tiempoRest + " segundos";
if (tiempoRest == 0)
{
timer1.Stop();
MessageBox.Show(txtTarea.Text);
}
}
private void txtTarea_TextChanged(object sender, EventArgs e)
{
txt1 = txtTarea.Text;
}
void checkBox1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
segs.Play();
}
}
}
}