Home > Software engineering >  CPoint problem, equivalent expressions, drawing is not the same as I don't know why?
CPoint problem, equivalent expressions, drawing is not the same as I don't know why?

Time:09-26

 int I=0; 
CPoint m_pt=0;
Void CMmkView: : OnTimer (UINT nIDEvent)
{
//TODO: Add your message handler code here and/or call the default
The CView: : OnTimer (nIDEvent);
CClientDC dc (this);
If (i<3600)
{
Dc. MoveTo (m_pt);
Dc. LineTo (I/5, I/5);
M_pt=(I/5, I/5);
I +=5;
}
}
Why you paint figure and the following is not the same?
int i=0;
CPoint m_pt=0;
Void CMmkView: : OnTimer (UINT nIDEvent)
{
//TODO: Add your message handler code here and/or call the default
The CView: : OnTimer (nIDEvent);
CClientDC dc (this);
If (i<3600)
{
Dc. MoveTo (m_pt);
Dc. LineTo (I/5, I/5);
M_pt. X=I/6;
M_pt. Y=I/6;
I +=5;
}

CodePudding user response:

M_pt=(I/5, I/5); And
M_pt. X=I/6;
M_pt. Y=I/6;
The result is not the same,

CodePudding user response:

/5/6 are integers, floating point I/6.0

CodePudding user response:

CPoint doesn't support floating point, want to use floating point, can only use the net to drawing,
If insist on using CPOINT, also can put the floating point converts an integer to paint

CodePudding user response:

 BOOL LineTo (
Int x,
Int y
);
BOOL LineTo (
POINT POINT
);

CodePudding user response:

Your drawing code is better on the OnPaint/ontouch () function to do ~

CodePudding user response:

CPoint ptUndefined;
CPoint ptTopLeft (0, 0);

//works from a POINT, too

POINT ptHere;
PtHere. X=35;
PtHere. Y=95;

CPoint ptMFCHere (ptHere);

//works from A SIZE

The SIZE sHowBig;
SHowBig. Cx=300;
SHowBig. Cy=10;

CPoint ptMFCBig (sHowBig);

//or from a DWORD

DWORD dwSize;
DwSize=MAKELONG (35, 95);

CPoint ptFromDouble (dwSize);
ASSERT (ptFromDouble==ptMFCHere);

CodePudding user response:

M_pt=CPoint (I/5, I/5);


M_pt. X=I/5;
M_pt. Y=I/5;

CodePudding user response:

I/5, of course, I/6