C# WinMo Mouse over e Som

ahcor1991

Membro
boas, este é o meu primeiro tópico aqui, já consultei este forum varias vezes e está muito bom!!!

o meu problema é o seguinte...
estou a desenvolver um programa C# para windows mobile 6.1
o que eu quero fazer é ao passar com o rato por cima de um botão, reproduz-se um som.
em relação ao som, já o consegui meter mas só funciona com click no butão e o som tem que estar num sitio especifico e o que quero é tê-lo num sitio relativo (em vez de ser C:\... ,ser \...).
outra coisa é o mouse over, não sei se no WinMo é drag over ou outra coisa qualquer.

resumindo, quero fazer um botão que, arrasto o dedo por cima, ele toca um som.

aqui está o que tenho...

using
System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SmartDeviceProject4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_click(object sender, EventArgs e)
System.Media.
SoundPlayer meuPlayer = new System.Media.SoundPlayer(@"\My Storage\sound.wav");
meuPlayer.Play();
}
}

muito obrigado e já agora, se puderem, expliquem-me como se eu fosse muito burro, pois iniciei-me em C# à coisa de uma semana...

;)
 
Última edição:
Não pode ser

Código:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] button1_click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender, [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e)[/SIZE]
pela simples razão que assim só iria dar som quando clicasses no botão. Tens que por o evento assim:

Código:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] button1_mousehover([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender, [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e)[/SIZE]

Assim vai dar ao passar com o rato por cima do botão.
 
o nome da função nem interessa, o evento para essa função é que tem de ser o correcto. Mas claro que é melhor alterar o nome para o que queres verdadeiramente para não levar a confusões

cumpzz
 
A nível do som estar num sítio relativo podes usar isto:
Código:
...
System.Media.[SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]SoundPlayer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] meuPlayer = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Media.[/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]SoundPlayer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]Application[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=white].StartupPath.ToString() + [/COLOR][/SIZE][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]@"\My Storage\sound.wav"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
...
[/SIZE]
O "Application.StartupPath.ToString()" vai procurar a pasta no directório em que o executável se encontra, logo o caminho assim será "pasta_em_que_o_exe_esta\My Storage\sound.wav".

Espero que ajude ;)

Cumps
 
Olá,

Eu não sei bem a sintaxe de C# mas tens de adicionar um evento para onmouseover.

Deve ser algo como:
Código:
[SIZE=2]
button1.onmouseover+=onmouseover_function;
[/SIZE]
Código:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]onmouseover_function[/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender, [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e)
System.Media.[/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]SoundPlayer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] meuPlayer = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Media.[/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]SoundPlayer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]@"\My Storage\sound.wav"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
meuPlayer.Play();
}[/SIZE]
 
Back
Topo