|
Please help...
I am trying to do something in a loop while letting the user press the keyboard when he/she sees something I put on screen. So I decided to time his/her response time using Form1_KeyDown.
But the problem is: when the user hits the key, the event seems to be queued or buffered. And I never got to the Form1_KeyDown code until the for loop is over.
Could anybody help?
Thanks
private void menuLoop_Click(object sender, System.EventArgs e)
{
for (int i=0; i< 100; i++)
{
//do something here
Console.WriteLine("Loop #{0}", i);
}
}
private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
long tick;
Win32.QueryPerformanceCounter(out tick);
Console.WriteLine("Current tick: {0}", tick);
}
|
|
|
|
|
private void menuLoop_Click(object sender, System.EventArgs e)
{
for (int i=0; i< 100; i++)
{
//do something here
Console.WriteLine("Loop #{0}", i);
Application.DoEvents();
}
}
Paul
And you run and you run to catch up with the sun, but it's sinking Racing around to come up behind you again The sun is the same in a relative way, but you're older Shorter of breath, one day closer to death - Pink Floyd, Time
|
|
|
|
|
Hello everyone,
The problem is simple:
in my class I obtained a type using reflection GetType.
Type t = Type.GetType(my_StringT);
NOW: how should I cast a variable to type obtained???
simple cast doesn't work...
Object my_NewType = (t) my_OldType; -> here the compiler told that
type or namespace 't' could not be found.
So, how should I use obtained type to cast my variable????
Thanks,
Don Miguel.
|
|
|
|
|
Don Miguel wrote:
So, how should I use obtained type to cast my variable????
You dont. This has riddled my mind a few times, but I have realise this is NEVER necessary.
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
leppie wrote:
You dont.
Is this impossible??
leppie wrote:
this is NEVER necessary.
how is that???? I don't understand.
|
|
|
|
|
Don Miguel wrote:
how is that???? I don't understand
What exactly is the point of this code?
Type t = Type.GetType(my_StringT);
Object my_NewType = (t) my_OldType;
Line 1: You are getting a Type object called my_StringT. Fair.
Line 2: Now this line screams of errors! lets start right to left.
- what is my_OldType? OK, the compiler cant assume, but I can. Is it a Type object or an instance of that Type? See?
- (t) . You can only cast to a type. Is t a type? No, it is a Type object. A class name is a type.
- Object my_NewType: Why are you casting in the first place? All objects downcast automatically to their parent types, iow object.Just like most OO languages, everything is an object of type Object (the root/parent/mother class).
Now think again what your are trying to do, and if in fact it is necessary. You get what I am saying? Feel free to ask some more questions.
Cheers
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
Thanks for your patience with me, until now.
leppie wrote:
Is t a type? No, it is a Type object. A class name is a type.
With above, you pointed me in right direction. I was really confused,
finally I realise what I intent to do.
Was a mess in my mind
Don Miguel
|
|
|
|
|
Don Miguel wrote:
Thanks for your patience with me, until now.
Hey, I never stop being patient...
Don Miguel wrote:
I realise what I intent to do.
Was a mess in my mind
That was what I was hoping you would see
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
I want to display 3 additional property tabs when a particular object in my project is selected. However, I cannot associate more than one tab with my class because the PropertyTabAttribute doesnt allow multiple instances (AttributeUsage.AllowMulltiple = false ).
This is especially confusing since the PropertyTabAttribute class clearly supports the addition of multiple tabs as is evident by its help page.
Can anyone tell me some other way of doing it?
Regards,
Umair Ahmad
|
|
|
|
|
I want to use IHtmlPainter,IElementBehavior,IElementBehaviorFactory with C# to draw grid in web browser like visual studio .net IDE's Web Form Designer.
guangxu qin
|
|
|
|
|
Hi all -
I have a problem I hope one of you can help me with.
I have created an addin to VS.NET - the addin worked perfectly fine during the time I developed it. Today I finalized the installer and began final testing - then suddenly I couldn't execute any of my commands. I get the error: "Command "Namespace.Class.Name" is not available."
I have tried whatever I could think of but nothing works. Any of you have any idea of what could be the problem?
I have come across something about the commands or the addin should be registered in the registry - but I lack more info about that.
Thanks in advance -
----
Edit:
5 min. after I posted this thread I found the problem.
Somehow I must have deleted the last part of this line:
public class Connect : Object, Extensibility.IDTExtensibility2, IDTCommandTarget
So it read:
public class Connect : Object, Extensibility.IDTExtensibility2
I know - stupid me. Sorry to have bothered you all with this post.
|
|
|
|
|
thanx for your tips but i still cannot move the shape from one position to another.i want to ask i have a lot of rectangle in the form how can i know which rectangle i have select to move and can i remain the size of the rectangle when i move and can i see the effect of the move when i move the rectangle.thank you for help me answer the question.
|
|
|
|
|
I'm trying my best to decipher your question, forgive me if I've understood it wrong
By the sounds of it, what you need to do is create a custom control that inherits from System.Windows.Forms.Control, create an OnPaint override to draw your rectangle image, and override the MouseDown, MouseUp and MouseMove events to implement drag-and-drop style moving on your Form surface.
|
|
|
|
|
how can i delete a specific amount of bytes (say 10) from a certian area of a open file (in this case location 0)...or if that cant be done..how can i open a file from a special point (say 10 bytes ahead of the start) FileStream.Read(bytelength,offset,totallengthtoread) ??
thanks alot
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
The only way to delete bytes from a file would be to copy it to another file, skipping the bytes you don't want. For what you want to do, try this:
FileStream fs = File.OpenRead(filename);<br />
fs.Seek(10, SeekOrigin.Begin);<br />
|
|
|
|
|
thanks alot for the help furty =)....still lookin for a way to embedd the salt bytes.....i can do it with the above code snip. thanks alot for all the help furty.......
Jesse M.
The Code Project Is Your Friend...
|
|
|
|
|
How do I get a trackbar to jump to the position at which I click? Instead of having the trackbar slide towards the mouse pointer...
|
|
|
|
|
There is no in-built methods to do this - the default behavior when clicked is the move the pointer +/- the LargeChange value.
The only way to achieve the behavior you're looking for would be to create a inherited TrackBar control, and override the MouseDown event. In your override you'll want to calculate the mouse position in relation to the TrackBar client rectangle, then use this to set the Value property based on the Minimum and Maximum property values.
|
|
|
|
|
can i knw wat class i need to have and what is the code to draw an arrow?thank you.
|
|
|
|
|
AFAIK there is no base class to draw an arrow. The System.Windows.Forms.ControlPaint class can draw a right-facing MenuGlyph but that's it. You'll have to paint it yourself.
|
|
|
|
|
You mean something like this?
private void Form1_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
Pen p = new Pen(Color.Blue,1);
p.EndCap=LineCap.ArrowAnchor;
e.Graphics.DrawLine(p,20,20,100,100);
}
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
animation mechanics in SVG (latest pic 1) (latest pic 2)
|
|
|
|
|
thats like... cheating :P :P
//Roger
|
|
|
|
|
hmm, but how do you change the size of the arrow - it seems to be proportional to the line width.
ta
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
There is a custom cap, maybe that will help you out.
Otherwise, it'll be pretty easy to derive from Line and automatically draw an arrow (of your choice) at the end of it.
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
animation mechanics in SVG (latest pic 1) (latest pic 2)
|
|
|
|
|
Hello
well i m having problems updating my tables. please have a look at the piece of code i m using
dataSet11.Tables["BPS"].Rows[index][1] = Int32.Parse(tBBPSVal.Text);//db field is int
dataSet11.Tables["BPS"].Rows[index][2] = Int32.Parse(tBInc.Text);//db field is int
sqlDataAdapter1.Update(dataSet11, "BPS");
MessageBox.Show("Record has been updated");
sqlDataAdapter1.Fill(dataSet11, "BPS");
i call this code behind update button but it doesnot work. wen i get the values of dataset they r changed but database remains same and does not reflect any change.
please help
Regards
|
|
|
|