| |

VerySource

 Forgot password?
 Register
Search
View: 649|Reply: 3

error C2664: cannot convert parameter 2 from 'class CDC *' to 'class CDC' ???

[Copy link]

3

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-9 13:00:01
| Show all posts |Read mode
void CCalendarView :: OnUpdate (CView * pSender, LPARAM lHint, CObject * pHint)
{
CDC * pDC = GetDC ();
CDrawUI * pDraw = new CDrawUI;
RECT rect;
rect.left = START_X;
rect.top = START_Y;
rect.bottom = START_X + 100;
rect.right = START_Y + 50;
pDraw-> DrawRect (rect, pDC); // Error positioning here
}
error C2664: 'DrawRect': cannot convert parameter 2 from 'class CDC *' to 'class CDC'

void CDrawUI :: DrawRect (RECT rect, CDC * pDC)
{
CBrush pTitleBrush (TITLE_BKCLR);
CBrush * pOldBrush = pDC-> SelectObject (&pTitleBrush);
pDC-> Rectangle (&rect);

pDC-> SelectObject (pOldBrush);
ReleaseDC (pDC);
}
Reply

Use magic Report

0

Threads

55

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-4-3 22:00:02
| Show all posts
CDC * pDC = GetDC ();
There is something wrong with this sentence.
Reply

Use magic Report

0

Threads

70

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 United States

Post time: 2020-4-4 10:30:02
| Show all posts
What is the definition of DrawRect function of CDrawUI?
Reply

Use magic Report

0

Threads

70

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-4-4 12:45:01
| Show all posts
It should be that the declaration of the DrawRect function does not match the pDC type you gave, one is CDC * and the other is CDC
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list