|
Thanks, but does anyone knows how to open these wave bytes??? I know that there's an API function called PlaySound, but it can play from file or from *Win32* resource. As far as I'm concerned C# doesn't compile resources as a Win32 type, but as it own format... Any ideas?
|
|
|
|
|
This is one of those areas where I can't help but think *there has to be a better way*...
If you take Mr. Johnson's GetWave method above and combine it with something like this...
public static void PlaySoundMemory(string resid)
{
PlaySound(
IntPtr.Zero,
IntPtr.Zero,
PlaySoundFlags.SND_SYNC
);
byte[] buffer = GetWave(resid);
if (null != buffer)
{
IntPtr p = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0);
PlaySound(
p,
IntPtr.Zero,
PlaySoundFlags.SND_SYNC | PlaySoundFlags.SND_MEMORY
);
}
}
You end up with something that works. You could also write the resource to a temp file and play it directly from there. The PlaySound Function and the PlaySoundFlags are just API definitions lifted from the Platform SDK headers.
Regards
|
|
|
|
|
Yesss, now it works!!! Thanks a lot!!!
|
|
|
|
|
Does anyone know how I can launch a URL in C# ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
System.Diagnostics.Process myproc = new System.Diagnostics.Process();
myproc.Start("IExplore.exe", "http://www.microsoft.com");
Why in the world Process is part of the Diagnostics namespace is beyond me though :-P
James
Simplicity Rules!
|
|
|
|
|
bah, I just realized this only works for IE and not the default browser
However, what happens if you put the URL inplace of IExplore.exe?
James
*James is currently munching on some pizza so he can't be bothered to type a test program in with one hand *
Simplicity Rules!
|
|
|
|
|
Just setting the .StartInfo.FileName property to the URL and the StartInfo.Verb to "Open" should do the trick...
i.e.
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "http://www.codeproject.com/";
process.StartInfo.Verb = "Open";
process.Start();
Regards
|
|
|
|
|
I found that start was a static method, I had to do it all in one line. Is this not the case ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
The Start method I use in the given code (no parameters) is not static. The others are.
Regards
|
|
|
|
|
Doh, blame the documentation :-P
What I wrote was a conversion of a VB sample
James
Simplicity Rules!
|
|
|
|
|
Thanks - between you and Neil I think I have all I need to update the code tonight for the 7 people still using Netscape, although they are all more likely to be using a slashdot screensaver than one from CP
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
Christian Graus wrote:
be using a slashdot screensaver
I think they're running SETI
James
Simplicity Rules!
|
|
|
|
|
I'm a newbie when it comes to C# and I was wondering if someone can help me with it. Has anyone successfully use the ListView.Items.Contains method? It does not work for me at all (always returns a "true" no matter what the data).
here's an example code of what I did:
//----------------------------------------------
string FilePath = @"C:\SomeFolder\SomeFile.txt";
FileInfo FI = new FileInfo(FilePath);
string[] fileInfo = {FI.Name,FI.DirectoryName};
ListViewItem myListItem = new ListViewItem(fileInfo,0);
if(lvMain.Items.Contains(myListItem) == false && tFI.Attributes != FileAttributes.Directory)
{
listView1.Items.Add(myListItem);
}
//----------------------------------------------
It works fine the first run, but if I run the code again with the same FilePath info it still adds the myListItem onto the listView1, resulting in redundant entry in my ListView control...
please someone help me get this Contains method to work! TIA
|
|
|
|
|
Oops, sorry about that. The "lvMain" object is suppose to be the "listView1" object...forgot to rename it, lol
|
|
|
|
|
Still can't get the code to work. If you know anything please reply. Thanks.
|
|
|
|
|
One issue here is that you are using a direct comparison on the Attributes property of the FileInfo object. This isn't safe considering it can be a combination of the posible values.
Use a comparison such as (0 == (fi.Attributes & FileAttributes.Directory)) in place of the !=.
Regards
|
|
|
|
|
D'oh! That was an embarrasing one... . Thanks for the heads up Neil. Greatly appreciated!
Now if only I can get the Contains method to work...
|
|
|
|
|
I know how to find all my monitors using the Windows.Screen object, but how can I specify which window to put a form onto ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
I believe if you use the Windows.Screen.Bounds value to determine the bounds of the screen this will tell you where that particular screen resides with respect to the entire virtual desktop. Then set the StartPosition property of your form to the bounds position for the screen. You can also use the Location property to change the position of form at runtime.
You can also use the SystemInformation.VirtualScreen Property to determine maximum virtual space for your multiple monitors. This will also tell you if there are negative coordinates for the virtual desktop.
Good Luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks, but I found and tried all this. My main desktop is on the right, but the virtualScreen does not hafve any negative numbers, nor does drawing beyond my desktop on the one draw to the other. This would probably work *if* I had a dual monitor setup where they were considered a single desktop, but then it would work just by getting the bounds of the current desktop.
Have you got two monitors ? I'm keen to know if you've had success with this method.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
The experience that I have had with multi-monitor support has shown me that each screen comprises a sub-rectangle in the entire large screen. The primary monitor will always be located at (0,0), for backward compatibility.
I am curious what the bounds value for each screen returns. Are they both located at (0,0), or are they arranged logically on the virtual desktop like the documentation suggests.
What does the virtual desktop setting return? Does it still not return a very large rectangle where both of your monitors are found?
I don't have Visual Studio .Net at home, so I can't really test this, but I have done it with Visual Basic. From reading the documentation, I believe that Visual Basic and C# perfrom this operation in much the same way. I do not know if this will help you, but there is a VB sample in MSDN called MultiMon.exe.
If I come up with something else I will let you know. Good Luck.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
kilowatt wrote:
The experience that I have had with multi-monitor support has shown me that each screen comprises a sub-rectangle in the entire large screen. The primary monitor will always be located at (0,0), for backward compatibility.
That can be true, if the computer is set up to treat the monitors as one large desktop.
kilowatt wrote:
I am curious what the bounds value for each screen returns. Are they both located at (0,0), or are they arranged logically on the virtual desktop like the documentation suggests.
No, they return co-ordinates arranged as if they were one desktop. But if I draw onto my primary desktop to negative co-ordinates in the X direction, nothing appears on my secondary monitor, which is on the left.
kilowatt wrote:
What does the virtual desktop setting return? Does it still not return a very large rectangle where both of your monitors are found?
It returns a large rectangle, my problem is that I cannot use any values I get from Screen to actually access the secondary desktop.
kilowatt wrote:
I don't have Visual Studio .Net at home, so I can't really test this, but I have done it with Visual Basic. From reading the documentation, I believe that Visual Basic and C# perfrom this operation in much the same way. I do not know if this will help you, but there is a VB sample in MSDN called MultiMon.exe.
Is it VB.NET ?
kilowatt wrote:
If I come up with something else I will let you know. Good Luck.
Thanks for your help. I expected it to work the way you are suggesting, or expose a method to actually *access* a screen, but it doesn't appear to be the case.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
I just came back to let you know I am an idiot I had my app set to full screen, which overrode my other settings, which is why this did not initially work. While I had found all this stuff before, it was your post that made me go back to play with it again and find my error, so thanks a million.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|
|
Your Welcome!
I am glad that you figured it out.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I've been through the properties a bajillion times - could someone please tell me where Microsoft have hidden the option for an edit box to only accept numbers ?
Thanks
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile.
- Jamie Hale, 17/4/2002
|
|
|
|