Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
After executing program it gets directly out side of project. I don't know why it happens.

C#
for (int i = 1; i != POINTS_ON_CURVE-1; i += 2)
{
  g.DrawRectangle(newpx, new Rectangle((int)p[i + 1], (int)p[i], 1, 1));
  g.Flush();
  Application.DoEvents();
}


After executing it gets off.

Plz help me.

Added from comment below:
ptList.Add(162); 
ptList.Add(127); 
ptList.Add(204); 
ptList.Add(124); 
ptList.Add(304); 
ptList.Add(207); // how many points do you need on the curve? 
const int POINTS_ON_CURVE = 1000; 
double[] ptind = new double[ptList.Count]; 
double[] p = new double[POINTS_ON_CURVE]; 
ptList.CopyTo(ptind, 0); 
bc.Bezier2D(ptind, (POINTS_ON_CURVE) / 2, p); 
//pictureBox1.Refresh(); 
// draw points 
for (int i = 1; i != POINTS_ON_CURVE - 1; i += 2) 
{ 
  g.DrawRectangle(newpx, new Rectangle((int)p[i + 1], (int)p[i], 1, 1)); 
  g.Flush(); 
  Application.DoEvents(); 
}


it is a program for drawing a curve when i go to execute it executes correctly but after drawing a curve it directly close the window
Posted
Updated 5-Apr-11 5:52am
v3
Comments
Sergey Alexandrovich Kryukov 5-Apr-11 11:41am    
Not enough information. For a developer, there is not such things as "get out", etc.
Can you simply use the Debugger and explain what happens?
Bad question.
--SA

1 solution

You Application.DoEvents already tells me you're doing something wrong. Is it inside OnPaint or handler of the Point event? Where did you get g? It looks like you have no idea on how to render graphics correctly and change it.

First of all, use Debugger to see what's going on.

See also my comment. I cannot help you if your explanation of the problem is so sloppy. You also don't show enough code.

—SA
 
Share this answer
 
v2
Comments
maheshpardeshi 5-Apr-11 11:48am    
ptList.Add(162);
ptList.Add(127);

ptList.Add(204);
ptList.Add(124);

ptList.Add(304);
ptList.Add(207);

// how many points do you need on the curve?
const int POINTS_ON_CURVE = 1000;

double[] ptind = new double[ptList.Count];
double[] p = new double[POINTS_ON_CURVE];
ptList.CopyTo(ptind, 0);

bc.Bezier2D(ptind, (POINTS_ON_CURVE) / 2, p);

//pictureBox1.Refresh();
// draw points
for (int i = 1; i != POINTS_ON_CURVE - 1; i += 2)
{
g.DrawRectangle(newpx, new Rectangle((int)p[i + 1], (int)p[i], 1, 1));
g.Flush();
Application.DoEvents();
}
}
it is a program for drawing a curve when i go to execute it executes correctly but after drawing a curve it directly close the window
Marc A. Brown 5-Apr-11 11:53am    
I copied this comment to your original question and formatted it. You'll want to make sure I didn't mess anything up in copying.
Sergey Alexandrovich Kryukov 5-Apr-11 13:05pm    
OK, this is all wrong. Where is your Paint or OnPaint? You don't show right part. You need to separate rendering and data. Basically, rendering should be under Paint, only DrawXXX operations. If you need to change it, you need Invalidate (nothing else). If you change it on a regular basis (like in animation), you need a thread for this.
--SA
maheshpardeshi 5-Apr-11 11:49am    
I have debug it but cant solve the problem
maheshpardeshi 5-Apr-11 12:02pm    
I solve the problem problem was with viblend button i change the button

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900