|
hi,
i have to play sound when user enter the mouse on toolstrip button,i have written followin code but it is not working.plzz help me out where is the problem
private void button5_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new SoundPlayer();
b=1
if (a == 1)
{
player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav";
player.Play();
}
}
private void tsbutton_MouseEnter(object sender,EventArgs e)
{
System.Media.SoundPlayer player = new SoundPlayer();
a = 1;
if (b == 1)
{
player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav";
player.Play();
}
}
thanks
-- modified at 4:33 Saturday 14th July, 2007
|
|
|
|
|
<br />
private void tsbutton_MouseEnter(object sender,EventArgs e)<br />
{<br />
System.Media.SoundPlayer player = new SoundPlayer();<br />
a = 1;<br />
if (b == 1)<br />
{<br />
player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav";<br />
player.Play();<br />
}<br />
}<br />
<br />
<br />
In this
<br />
a = 1;<br />
if (b == 1)<br />
{<br />
When your b will become 1 ? Is this is hiccup?
|
|
|
|
|
now plz check this out
private void button5_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new SoundPlayer();
b=1
if (a == 1)
{
player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav";
player.Play();
}
}
private void tsbutton_MouseEnter(object sender,EventArgs e)
{
System.Media.SoundPlayer player = new SoundPlayer();
a = 1;
if (b == 1)
{
player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav";
player.Play();
}
}
|
|
|
|
|
Hi,
some suggestions:
1. have only one SoundPlayer, make it a class member
2. dont use variable names such as a and b, no one understands them (including yourself)
3. have a bool "soundEnabled" which gets set/cleared by button5 and ...
4. have a bool "alreadyPlaying" to prevent multiple concurrent sounds
5. is MouseEnter handler first check soundEnabled, if false, dont do anything;
check alreadyPlaying, if false, set it true and start sound asynchronously
6. biggest problem will be how to clear alreadyPlaying since there is no event for end of
sound. Maybe a Forms.Timer is the way to go.
|
|
|
|
|
Hey,
I want to bring up multiple layout for my windows application. That is same application need have multiple view as same like our IDE, Center of the page we have text editor, bottom side compiler result, right side solution view etc., the same look and feel is possible in C# windows application? I have plyed around lot in VC++, now i would like to get the same in C#.
Can you please help out to me?
Thanks !
|
|
|
|
|
You want a sample which look like the Visual Studio IDE? You can try to look at SharpDevelop IDE. You can read their code to check how they wrote the multiple layout for C# windows application...
|
|
|
|
|
Is that code written in C#, since i want to build it using C#.
|
|
|
|
|
Yeah. It's in C#. Here is the URL.
But only one thing. there are too much of coding in it..
|
|
|
|
|
I do not see any URL, please send me again.
|
|
|
|
|
Did you move your mouse over the word "here"
Okay anyways.. here goes http://www.icsharpcode.net/OpenSource/SD/
|
|
|
|
|
My C# winforms app allows users to create documents. Embedded in a document is any author meta-data the author wanted to share, such as their website URL. Then, other users who open their document can click the URL entered by the author to have their browser opened to that page. My concern is that a malicious user, instead of entering his homepage into the URL field, will enter some kind of crazy URL that includes scripting code or some other internet exploit, which will do something bad to an unsuspecting user who clicks on that URL (sorry I'm not being more technical, but I don't really know how all these exploits work).
My question is this: Are there any specific characters or other junk that my C# app should filter out from a URL before sending it to the browser?
Thanks for the help!
|
|
|
|
|
You can regular expression for checking whether it's valid URL or not in your C# application.
here is the one that I google for you..
|
|
|
|
|
There's not really any point in trying to protect users from code in the url, as long as you are letting them link to a page of their own. They can put anything on the page they are linking to, and you can't check it. Of course you can check the url, but don't fool yourself (and your visitors) that it's safe just because the url itself doesn't contain anything harmful.
If you are afraid of malicious users, you should warn anyone that is clicking on a link that you don't have full control over, that they are moving to a page that might contain something harmful (or offensive, or illegal...).
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
i'm having a problem how to get a control from form 1 to form 2..for example:
i want gridview name dgvBlaBla from form1 can be access from form 2 ?_?
Can Anyone Help Me..I'm sorry i'm beginner in C#
Regard,
TCim
|
|
|
|
|
#1. Lets say there are two forms (form1, form2) in your application. you put one button called button1 in form2. You wanna get the control (button1) of form2 from form1.
Add one public property which is returned the control that you required in form2
eg:
<br />
public Button Button1<br />
{<br />
get<br />
{<br />
return button1;<br />
}<br />
}<br />
Then, you can access this control from form1.
eg:
<br />
Form2 obj = new Form2();<br />
MessageBox.Show(obj.Button1.Text);<br />
There are another way to get the control from other form or assembles. I'm not gonna mention here. If you are interest about this, please "Reflection" class from MSDN or google.
Hope it helps.
|
|
|
|
|
Thank You
It Helps Me solve My problem
Regard,
Tomi
|
|
|
|
|
You've got an answer already, but I'm asking myself why you want to do this? because I think there is a bit of a design problem here (information hiding? encapsulation?)
-^-^-^-^-^-
no risk no funk
|
|
|
|
|
I have to write the event handler for MSCOMM.OnComm who is listening to serial port for data, so that the event is fired 'OnComm' is executed when the data is arrived.
My understanding for the documentation is unclear as how to achieve this.
Does any one have the sample source code implementation in C# / C++?
Thanks and Regards.
Amar.
|
|
|
|
|
If you're using .NET 2.0 (Visual Studio 2005), why are you even bothering with the MSCOMM control? There's a SerialPort class built into the .NET Framework under the System.Io.Ports namespace.
|
|
|
|
|
Hello,
Trying to write an app that I can work with dual monitors and Windows windows...
I'd like to add buttons next to the minimize button for all windows within Windows. Can anyone point me in the right direction on this?
Thanks!
Andy
|
|
|
|
|
This peace of code will draw a button on title bar , however i don't like to write C# code
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM.NCPAINT Then
Me.DefWndProc(m)
Dim G As Graphics = Graphics.FromHdcInternal(GetWindowDC(Me.Handle))
Windows.Forms.ButtonRenderer.DrawButton(G, New Rectangle(Me.Width - 100, 5, 20, 20), VisualStyles.PushButtonState.Normal)
Else
MyBase.WndProc(m)
End If
End Sub
Other APIs you may use : GetSystemMetrics , GetWindowLong(HWND , GWL_STYLE) , GetWindowInfo -> to determine the size of window's border , to count title button ...
|
|
|
|
|
I want to display the properties of (.swf , .fla) files as height, width and resolution.
|
|
|
|
|
Hi,
Here's the code:
foreach (DataRow dr in myWebLoggerDataSet.MonitorList.Rows)
{
string name = dr["Name"].ToString();
string size = dr["FileSize"].ToString();
string colour = dr["Colour"].ToString();
string display = name +" : " +size;
string[] myItems = new string[]
{
display
};
ListViewItem lvi = new ListViewItem(myItems);
lvi.BackColor = Color.FromArgb(Convert.ToInt32(colour));
this.lvResourceMonitor.Items.Add(lvi);
}
The problem I have is that the item background color is used when debugging in W2K3 server but not when running normally on a Win XP machine. I need to manually select each item in XP to get the highlight color to take effect.
I've tried various options like redraw, giving the listview focus etc but to no effect.
Any suggestions for fixing this very frustrating issue?
Thanks.
-- modified at 5:42 Saturday 14th July, 2007
It happens on W2K3 as well. Works fine in debug mode though.
Glen Harvy
|
|
|
|
|
Hey Glen,
I can't get the same behaviour on my machine... it just works as expected when I try.
Have you suspended any of the drawing methods on the control to improve performance or anything like that? Have you got any other code setting properties on the listview? Have you tried invalidating the form?
|
|
|
|
|
Thanks for you response. I really need someone to talk to - I'm going nuts.
I haven't done anything that I can tell would make the listview behave differently between when run in debug mode versus production mode.
I have also tried lv.refresh, lv.update lv.invalidate various lv.focus etc but all to no efect. I have discovered at least three different ways to change the background color that all work in debug but not production mode.
This is the only instance of this error that I have had so I find it difficult to believe it's my computer at fault.
Could you try this for me please - set the listview to "Details" and see if that makes a difference.
Thanks.
Glen Harvy
|
|
|
|