Skip to main content
gamedev.net
🔒 Locked

Windows Class Tutorial problem?

Started by startreky498 0 replies 350+ views
Original Post
startreky498
startreky498
I've been studying the Window Class code on gamedev.net. So far I've hit many problems, most of which I've been about to fix with a few tweaks that I'm not sure even work, beyond removing the errors I keep getting. Now I've hit a problem that I can't tweak my way out of. Here's the relevent code:

Window::tyMessageIterator Window::GetMessageHandler(long message)
{
	Window::tyMessageIterator it = m_MsgHandlers.find(message);
	if(it = m_MsgHandlers.end())
		return NULL;
	return it;
}

class Window
{
public:
	//I'm not sure where the following 3 lines were supposed to
	// go, but this is the only place that didn't produce an
	// error.
	typedef long (* tyMessageHandler)(Window &, HWND, long, long);
	typedef std::map<long, tyMessageHandler> tyMessageMap;
	typedef tyMessageMap::iterator tyMessageIterator;

	tyMessageMap m_MsgHandlers;

	LRESULT CALLBACK MsgRouter(HWND hwnd, UINT message,
		WPARAM wParam, LPARAM lParam);
	tyMessageIterator Window::GetMessageHandler(long message);
};


And here's the error I'm getting: c:\Other People's Projects\GameDev.net\Window Class\Window.cpp(12) : error C2451: conditional expression of type 'std::_Tree<_Traits>::iterator' is illegal with [ _Traits=std::_Tmap_traits,std::allocator>,false> ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called I'm not sure what I need to do to fix this problem. Does anyone have any idea what I can do? Better yet, does anyone have a working source for this project that I can study? Thanks.
mattd
mattd
In Window::GetMessageHandler:
	if(it = m_MsgHandlers.end())

should be
	if(it == m_MsgHandlers.end())


:)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.