Home > Software engineering >  Urgent for great god! New small white a face of meng force...
Urgent for great god! New small white a face of meng force...

Time:09-18


As shown in figure, the establishment of such a dialog application, after enter the upper left and lower right corner two rectangular range, and then determined by radio buttons and button in the scope of rectangle to draw graphics, sine is two cycles of sine wave, straight line is a straight line between two angular point, rectangular are two corner rectangle is determined, specific need what functions, hope that they can take time to help me have a look at the great god, thank you very much,

CodePudding user response:

Void CMFCApplication1Dlg: : OnPaint ()
{
CPaintDC dc (this);//for drawing device context
Dc. MoveTo (10, 20);
Dc. LineTo (100, 20);

Dc. MoveTo (10, 30);
Dc. LineTo (100, 30);
Dc. LineTo (100, 100);
Dc. The LineTo (10, 100);
Dc. LineTo (10, 30);


CPen pen_Zuobixi pen_sinx;
Pen_Zuobixi. CreatePen (PS_SOLID, 4, RGB (0, 0, 0));
Pen_sinx. CreatePen (PS_SOLID, 2, RGB (0, 0, 0));
Dc. SelectObject (& amp; Pen_Zuobixi);
//specify the origin
Dc. SetViewportOrg (50, 250);
Double y, radian;
Dc. SelectObject (& amp; Pen_sinx);
For (int x=- 30; x<660; X++)
{
//radians=X coordinate/Angle coefficient curve width * * PI
//* Y=amplitude curve width * sin (arc)
Radian=x/((double) 60 * 2) * PI;
Y=sin (radian) * 2 * 60;
Dc. MoveTo ((int), x, y) (int).
Dc. LineTo ((int), x, y) (int).
}
Pen_sinx. DeleteObject ();
Pen_Zuobixi. DeleteObject ();
}

CodePudding user response:

Bosses, the rectangular coordinates is given? Then if I want to use edit box on the left side of the input of rectangular coordinates to determine the rectangle and draw to do?

CodePudding user response:

reference 1st floor kuangbao9 response:
void CMFCApplication1Dlg: : OnPaint ()
{
CPaintDC dc (this);//for drawing device context
Dc. MoveTo (10, 20);
Dc. LineTo (100, 20);

Dc. MoveTo (10, 30);
Dc. LineTo (100, 30);
Dc. LineTo (100, 100);
Dc. The LineTo (10, 100);
Dc. LineTo (10, 30);


CPen pen_Zuobixi pen_sinx;
Pen_Zuobixi. CreatePen (PS_SOLID, 4, RGB (0, 0, 0));
Pen_sinx. CreatePen (PS_SOLID, 2, RGB (0, 0, 0));
Dc. SelectObject (& amp; Pen_Zuobixi);
//specify the origin
Dc. SetViewportOrg (50, 250);
Double y, radian;
Dc. SelectObject (& amp; Pen_sinx);
For (int x=- 30; x<660; X++)
{
//radians=X coordinate/Angle coefficient curve width * * PI
//* Y=amplitude curve width * sin (arc)
Radian=x/((double) 60 * 2) * PI;
Y=sin (radian) * 2 * 60;
Dc. MoveTo ((int), x, y) (int).
Dc. LineTo ((int), x, y) (int).
}
Pen_sinx. DeleteObject ();
Pen_Zuobixi. DeleteObject ();
}

Bosses, the rectangular coordinates is given? Then if I want to use edit box on the left side of the input of rectangular coordinates to determine the rectangle and draw to do?

CodePudding user response:

If you edit box attribute is set to Int, it can directly Int x=GetDlgItemInt (IDC_XXX);
If the string is the default:
Cstrings STR.
GetDlgItemText (IDC_XXX, STR);
Int x=_ttoi (STR);
Separately for each edit box, MoveTo, LineTo corresponding value can be replace
Finally, Invalidate (TRUE); the

CodePudding user response:

To calculate a point, and then draw it

CodePudding user response:

Calculate a point first, and then connect,
It is better to draw on the diagram, and then displayed,
  • Related