Deklaration von variablen

Hallo,

schreibe anstelle von:

SiS-Shadowman hat gesagt.:
Code:
void CTag3Dlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	if ((nFlags & MK_LBUTTON) == MK_LBUTTON) {
		CClientDC dc(this);
		
		dc.MoveTo(m_iPrevX, m_iPrevY);
		dc.LineTo(point.x, point.y);

		m_iPrevX = point.x;
		m_iPrevY = point.y;
	}
	
	CDialog::OnMouseMove(nFlags, point);
}

das:

Code:
void CTag3Dlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	if ((nFlags & MK_LBUTTON) == MK_LBUTTON) {
		CClientDC dc(this);
		
		dc.MoveTo((int)m_iPrevX, (int)m_iPrevY);
		dc.LineTo(point.x, point.y);

		m_iPrevX = point.x;
		m_iPrevY = point.y;
	}
	
	CDialog::OnMouseMove(nFlags, point);
}
 
Nun kommt diese fehlermeldung ^^:

E:\Programme\Microsoft Visual Studio\MyProjects\Tag3\Tag3Dlg.cpp(179) : error C2440: 'type cast' : cannot convert from 'int (__thiscall CTag3Dlg::*)(void)' to 'int'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast
E:\Programme\Microsoft Visual Studio\MyProjects\Tag3\Tag3Dlg.cpp(179) : error C2440: 'type cast' : cannot convert from 'int (__thiscall CTag3Dlg::*)(void)' to 'int'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast

Code:
void CTag3Dlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	if ((nFlags & MK_LBUTTON) == MK_LBUTTON) {
		CClientDC dc(this);

		dc.MoveTo((int)m_iPrevX, (int)m_iPrevY);
		dc.LineTo(point.x, point.y);

		m_iPrevX = point.x;
		m_iPrevY = point.y;
	}
	
	CDialog::OnMouseMove(nFlags, point);
}
 
In Dev-cpp funktionierts so. War einen Versuch wert.

Versuchs mal mit einem static_cast Operator ( wird so in der Fehlerbeschreibung vorgeschlagen )
Code:
 MSDN:

static_cast Operator

static_cast < type-id > ( expression )

The static_cast operator converts expression to the type of type-id based solely on the types present in the expression. No run-time type check is made to ensure the safety of the conversion.

The static_cast operator can be used for operations such as converting a pointer to a base class to a pointer to a derived class. Such conversions are not always safe.

static_cast<int>(variable)
 
Zuletzt bearbeitet:
SiS-Shadowman hat gesagt.:
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast

Code:
		dc.MoveTo((int)m_iPrevX, (int)m_iPrevY);

Bin mir nicht sicher. Es müsste dann so aussehen :
Code:
dc.MoveTo(static_cast<int>(m_iPrevX),static_cast<int>(m_iPrevY));
 
du keine ahnung, also ich denke das sollten variablen sein, da dort die maus position gespeichert ist (also x, y koordinate)

*edit* hey cool, ich musste die klammern da entfernen, danke dass du mich auf die richtige spru gebracht hast *kiss* ^^

jetzt kann ich wieder weiterproggen
 
Zurück