|
the final code is:
<br />
using System;<br />
using System.Runtime.InteropServices;<br />
using System.Diagnostics;<br />
using System.Threading;<br />
using System.IO;<br />
using System.Reflection;<br />
namespace yournamespace<br />
{<br />
public class WSounds<br />
{<br />
private byte[] m_soundBytes;<br />
private bool disable=false;<br />
private enum Flags<br />
{ <br />
SND_ASYNC = 0x0001, <br />
SND_MEMORY = 0x0004 <br />
}<br />
[DllImport("winmm.dll",CallingConvention = CallingConvention.Winapi)]<br />
static extern int PlaySound(byte[] wfname,int hMod,int sf);<br />
<br />
public WSounds(string s)<br />
{<br />
if (s == null)<br />
{<br />
disable = true;<br />
return;<br />
}<br />
<br />
try<br />
{ <br />
Stream a = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(s);<br />
m_soundBytes = new byte[a.Length];<br />
a.Read(m_soundBytes, 0, (int)a.Length);<br />
}<br />
catch (Exception e) { disable = true; }<br />
}<br />
public void Play()<br />
{<br />
if (!disable)<br />
PlaySound(m_soundBytes, 0, (int)(Flags.SND_ASYNC | Flags.SND_MEMORY));<br />
}<br />
}<br />
<br />
<br />
}<br />
then in your main code you must add a file to your resources list "file.wav" for example that will be along the classes..and change his property to :"embedded resources" so it will compile him along with the exe.
and you call the class this way:
<br />
private WSounds ws;<br />
<br />
ws = new WSounds("yournamespace.file.wav");<br />
<br />
ws.Play();<br />
thats it.
R.Z
-- modified at 6:05 Monday 30th January, 2006
|
|
|
|
|
Hello is there a way to Use the DirectX Api to encode MPEG2 files from a capture card using c#
Any help would be great --
Thanks in Advance
|
|
|
|
|
I new to c# but I am having a lot of fun with it. But there are a couple of thing that I am trying to do, but have not found the solution to.
I want to make a window that should be “glued” to the top and the middle of the screen. It should have an “always on top” function. And when I do not point my mouse over it, it should “slide away” after a certain delay (the only ting I shall be able to see is a progress bar). When I move my mouse over it again, the window should “slide out” again (like a drawer)
Does anyone knew of a component that could do this or is there any other way ?.
|
|
|
|
|
Hi,
I tried to create a web services and the button OK is not active.
I have write to write on that directory. So what it mist there?
Thanks
Gregoire
|
|
|
|
|
What do you mean by the OK button is not active ? Web Service creates a service, there is no user interface or OK button associated with it. Please be more specific.
Simon
|
|
|
|
|
Hi,
I wasn't able to find any posts about this so hopefully this is the first.
I'm trying to use Single.Parse() in .net 2.0 to parse "99.5E-1". However, after it parses the float value is 9.949999998... etc. Why does it do this, and not have it as 9.95?
Thanks,
Stephen
|
|
|
|
|
atanamir wrote: However, after it parses the float value is 9.949999998... etc. Why does it do this, and not have it as 9.95?
Limitations in internal representation of the number.
As you already know, a computer can only deal with ones and zeros. So to represent a floating point number the computer splits the binary into a mantissa (the actual digits) and exponent (position of the point) - this effectively places a virtual dot in the binary.
If you assume the following is 16 bits (5 for the exponent which is set to 00100 [4])
BIN: 0001.1000000 == DEC 1.5
BIN: 1001.1000000 == DEC 9.5
BIN: 1001.1100000 == DEC 9.75
BIN: 1001.1110000 == DEC 9.875
BIN: 1001.1111000 == DEC 9.9375
BIN: 1001.1111100 == DEC 9.96875
BIN: 1001.1111010 == DEC 9.953125
BIN: 1001.1111001 == DEC 9.9453125
Anyway, you can continue refining the value to as close to 9.95 as you can until you hit the 32 bit limit of a single, but you get the idea that in a binary representation 9.95 isn't going to get hit exactly.
If you absolutely must be able to represent 9.95 with no rounding errors like this (for example, because it is an accountancy package) then I recommend using a decimal which is explicitly designed for handling money.
DISCLAIMER: It has been almost 15 years since I last had to do a calculation like this so there may be errors in the detail, but the general concept is the same
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Hi,
Thanks for the reply;
Yeah i was thinking about using a double or decimal value for this; but I am writing a compiler which has REAL and LONGREAL, hence i was trying to use float. I tried this in code:
float n = 99.5E-1F;
Console.Writeline(n);
that comes out as 9.95.
Infact, I just tried hard-coding this in:
object n = Single.Parse("99.5E-1");
Console.Writeline(n);
it will still come out as 9.95. However, I have following:
class Token {
object _val;
}
If I store the value in there, it gets transformed to 9.949999....
Am i not supposed to cast it into object?
Thank you for your time
Stephen
|
|
|
|
|
Hi,
I have a problem with app.config file.
I put a connection string inside and I tried to retrieve the information in my application in the constructor form , after InitializeComponent().
If I am using:
string ConnString =
System.Configuration.ConfigurationSettings.AppSettings["ConnectionStringSVH"];
ConnString is null after execurion.
If I’am using:
system.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
ConnString=((string)(configurationAppSettings.GetValue("ConnStringSVH", typeof(string))));
I got the exception: {"The key 'ConnString' does not exist in the appSettings configuration section." }
I realize that if I put in Debug directory the config file will be deleted when I run in debug the application.
Any thought?
P.S.1. I rename the config file and put the name of myapp.config
2. I have several project in the same solution Is just in the last one that it didn’t work.
Thanks
Gregoire
|
|
|
|
|
gregoire.b wrote: P.S.1. I rename the config file and put the name of myapp.config
Your project solution should contain the file named as app.config. When it gets copied to the output directory (debug or release), then the file gets renamed as myapp.config. You don't/shouldn't do this manually.
How does "ConnectionStringSVH" look in the app.config file?
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
I m using asp.net with C#.I want to use open sub reports. I wrote code like this.
subreportObject = Report.ReportDefinition.ReportObjects
it generates error that type or name space Report could not be found.i added
"using CrystalDecisions.CrystalReports.Engine;".can any body tell me whts error cause
|
|
|
|
|
Have you also added a reference to the relevant assemblies in your project. Right-click the references folder in the project and select "Add Reference..."
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Is there any way to make a control redraw itself (with Refresh(), in my case) when the form containing it is moved, or has changed in some other chaphical way? It would be fine to do that from the control class...
Can someone help me?
Viktor
|
|
|
|
|
How about myControl.Invalidate(); , or from inside the control's code, this.Invalidate(); .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You could bind the LocationChanged from the ParentForm (property of control).
|
|
|
|
|
Hello! I'm .Net-developer from Ukrain and my English is bad.
In this article http://www.codeproject.com/cs/media/csharpfilters.asp i read about Gaussian blur, but i have red the matrix of Gaussian filter without Radius setting. Where i can read about real Gaussian filter with settings of tolerance radius.
Thanks.
|
|
|
|
|
I think the best option would be to ask the author of the article in the discussion board you linked.
Christian Graus is very active in this board, so I think you'll get a reply soon.
bye
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hello,
I am looking for a feature in .NET listView wherein you can start the Marquee selection from the
ListView Items. Is there a way to intiate the marquee selection using sendmessage.
Live Life King Size
Alomgir Miah
|
|
|
|
|
There's no support for it built into the .NET Framework. There are, however, methods to get something to work. The message you're thinking of, with the help of the Win32 SendMessage function, is LVS_EX_DOUBLEBUFFER. This message is only available in ComCtrl32 Version 6.00 (Windows XP) and above.
I'd give you a link to the documentation in the Windows SDK site, but it's Search function appears to be busted right now. http://windowssdk.msdn.microsoft.com/library/[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Would someone tell me how to read the data selected by the user in a comboBoxNames, and put the name into a variable string name; ?????
Thanks .
aPerfectTool
|
|
|
|
|
What I do is create objects (instantiated classes) of each item in the combo box, with ToString()'s. I add the objects to the combo box, the combo box shows the string representations of the object. Once I want to read the combo box, the SelectedItem property contains the object, not just the string so I don't have to match up the string to possible objects.
It's quite an elegant way to handle that type of selection.
|
|
|
|
|
I have a Dataset that has returned data from SQL Server. I would like to read in what the SQL Server type is for each Column and what the size is. For instance is the column is a nvarchar(20) I would like to be able to find out that the column has a size of 20. Is this possible? I can't seem to figure this out even using the DataColumn.
DataColumn.MaxLength is returning -1.
I tried also SQL Command:
SELECT COL_LENGTH('MyTable','MyColumnName') AS 'MyColumnLength'
it's running fine in SQL Query analyzer but it's returning 0 in C#
Any idea?
thanks
|
|
|
|
|
You can use SQLDMO to access specific DB Schema .Add reference to SQLDMO object - can be found under COM tab - add entry named "Microsoft SQLDMO Object Library".
The snippet shows how to get column details for table "Customers" in "Northwind" DB.
<br />
SQLDMO.SQLServerClass sqlServer = new SQLServerClass();<br />
sqlServer.Connect("MYSERVER", "username", "password");<br />
<br />
foreach (SQLDMO.Database db in sqlServer.Databases)<br />
{<br />
if (! db.SystemObject)<br />
{<br />
if(db.Name=="Northwind")<br />
{<br />
foreach( SQLDMO.Table table in db.Tables )<br />
{<br />
if(table.Name=="Customers")<br />
{<br />
foreach(SQLDMO.Column column in table.Columns )<br />
{<br />
Console.WriteLine( column.Name );<br />
Console.WriteLine( column.Length );<br />
Console.WriteLine( column.Datatype );<br />
}<br />
}<br />
<br />
}<br />
}<br />
}<br />
} <br />
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
It's pretty good but it is working some slowly...
Anyway I'm using it...
thanks a lot
|
|
|
|
|
Hi ! I am looking for someone who have programmed Irda commnunication port between a Pocket-PC and the Microchip MCP2155. I have found some articles in C++ and some other in C# that doesn't work very well.
I can establish the communication but the transfer of good data is hard to achieve.
Visual Studio 2005, Compact Framework 2.0.
Is there any problem with the new Compact Framework ?
Thank you a lot !
Danny Gilbert, enginneer
Montréal, Canada
|
|
|
|