|
Yes, that looks OK. Try it out and judge for yourself.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
How can i fail my program so this works?
|
|
|
|
|
Shani Aulakh wrote: How can i fail my program so this works?
What do you mean? Why would you want cause your program to deliberately fail?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Sorry for the confusing question. I meant to say, what should i do to see if it actually handle all exceptions
|
|
|
|
|
If you want to produce a FileNoFoundException or DirectoryNotFoundException , just try doing something that involves a file/directory that doesn't exist.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
If you just want to test that your catch blocks work the way you intend you can always throw an exception from code during testing. Just make sure to remove exception once you are convinced you're exception handling works the way you want. Depending on the application you could also use a driver for this.
throw new System.ApplicationException("Your message here");
You can replace ApplicationException with the exception types you actually want to test.
|
|
|
|
|
|
How can I set characters limit in the ProperGrid control property. Like, a Name property is being diplayed inside the propertygrid. I don't want user to enter more than 5 characters in the Name field.
I know if i have to check the string lenght but how can i stop the user not exceed more than that
|
|
|
|
|
netJP12L wrote: I don't want user to enter more than 5 characters in the Name field.
Why limit people to such few characters?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
i am trying to develop a player using mci...
i want to control volume with the track bar..... so what i did is
//
code//
mcisendstring(String.Format("set {0} volume to {1}",file, trackbar.value),String.Empty,0,0);
i don't see any effect
can someone help with this./..
another problem is getiing the length....
i don't know the format i am gettin my values in
what i do is
// first
mcisendstring("set file time format ms",String.Empty,0,0);
mcisendstring("status file length",result,255,0);
the result contains values which is unclear to me....
cud someone help with this as well?
thankx so much
//
|
|
|
|
|
Not sure. Do you care to tell us a little more about mcisendstring ?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Paul Conrad wrote: mcisendstring?
mciendstring is a system call part of the MCI API(MULTIMEDIA CONTROL INTERFACE.... it takes a list of command strings to make these calls....
i get some help on it from the MSDN.. maybe more can be read there..
examples" mcisendstring("set CDAudio door open", Sring.Empty,0,0)"===
this will open a CD tray....
|
|
|
|
|
My string is serial of words( abc& # SomeInterger; )
How can I convert it to utf8 as ( abc? )
Thanks!
QuynhTD
modified on Tuesday, December 18, 2007 1:44:31 PM
|
|
|
|
|
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello everybody,
does anybody have any idea of how it's possible to access a specific TreeNode object in a TreeView, given the 'FullPath' property of that node ?
Thanks for helping,
Pat.
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
|
Hi,
I have bought a Digital Pen that its handwriting only works with Info Path.
Is there any software that make my Pen (Genius G-Pen 560) compatible with any windows Form?
Best wishes
|
|
|
|
|
In an application I set the windows cursor to a WaitCursor, but other components within the same application set it back to Default. Is there a way to set the cursor type, and prevent other areas of the same application from changing it? Thank you in advance.
Kalvin
|
|
|
|
|
You can set the UseWaitCursor property to force the WaitCursor to be the one used when the mouse is within the bounds of an object with that property set to "true". I don't think that there is any way to prevent another app from changing it unless you are coding the app. If you are coding it, then look into thread synchronization techniques. The method I would try to implement would be to acquire a named mutex (or static variable) anytime you want to change the cursor. Then, if you want to prevent others within your app from changing it, just hold the mutex (static variable). Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Thanks a lot for your reply.
The cursor is being changed from different components that together make an application. Some components I have access to change, and others I can't access or modify the code. I also should have stated that this is in VS 2003 and the WaitCursor isn't available. I can't access other components to make them use a mutex. If those are the only options in C#, is there a way to use an API to do this or is doing this just not the way windows works?
Thanks again.
|
|
|
|
|
I'm not really certain if the following would lock only a local copy of the cursor, or if it would lock the cursor resource for all applications, but you could try to use the WinAPI calls LoadCursor[^] followed by a LockResource[^]. Again, I don't have time to experiment with these, but they would be worth looking into. Another idea would be to implement a timer that continuously checks the cursor, and sets it back if it is changed (this method scores a 9/10 on the hack scale). A better idea would be to listen to the windows events (like Spy++ does) and block any attempt at sending a WM_SETCURSOR (I assume this is the message being sent) message. I've never tried to intercept windows messages, but I'm sure you can google to discover how to go about this (perhaps look at overriding DefaultWndProc and WndProc methods on Control objects?). Please post results if you get it working.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Thank you for the reply and all of your help.
|
|
|
|
|
I need to programatically convert float values like 17.1054688 to 17.11 in C#
i.e want to restrict the float values upto 2 decimals.
For this I have written following code:
<br />
private void Roundupto2Decimals(ref float fVal)<br />
{ <br />
string strVal = fVal.ToString("F2");<br />
fVal = float.Parse(strVal);<br />
double dVal = (double)fVal;<br />
}<br />
In VS2005 watch window, I get the correct value for fVal.
for e.g:
Input : 17.1054688
strVal: "17.11"
fVal : 17.11
but ---> (double)fVal : 17.110000610351563
I am not sure when I typecast the same float to double I get unepcted value.
I expect dVal to be 17.11 too.
Can any one help me understand what is happening?
Thanks and Regards,
Arti Gujare
|
|
|
|
|
Hi,
I think it's because C# float is not exact. Try to use decimal instead.
zilo
|
|
|
|
|
It's all due to the way floating point numbers are represented - some numbers can't be represented exactly, so will have very tiny errors.
As suggested by the other poster, if you are using small numbers, and require high precision, then the Decimal type would be more suitable.
|
|
|
|