Dabbeling with win API

Started by
0 comments, last by darkelf2k5 15 years, 7 months ago
So I'm building a directX game for my final project for my directx class and the other day I was trying to clean up my code a bit so I desided to write a wrapper class that handles creating my window and any other window api stuff for me so its not all in main. so to be brief this is inside my class

private:
	DWORD		m_dwExstyle;		///< 
	LPCTSTR		m_lpClassName;		///< Name of the window class
	LPCTSTR		m_lpWindowName;		///< Title of the window
	DWORD		m_dwstyle;			///< Window style
	INT		m_nX;				///< X-Position of the window
	INT		m_nY;				///< Y-Position of the window
	INT		m_nWidth;			///< Width of the Window
	INT		m_nHeight;			///< Height of the window
	HWND		m_hWndParent;		///< Do we have a parant window?, NULL
	HMENU		m_hMenu;			///< Are we useing menus?, NULL
	HINSTANCE	m_hInstance;		///< Application handle
	LPVOID		m_lpParam;			///< Used with multiple windows, NULL

public:
	CCreateWindow( HINSTANCE hInstance )
	{
		m_dwExstyle		= NULL;		
		m_lpClassName	        = L"Class1";		
		m_lpWindowName	        = L"Main Window";		
		m_dwstyle		= WS_OVERLAPPEDWINDOW;			
		m_nX			= 300;				
		m_nY			= 300;				
		m_nWidth		= 500;			
		m_nHeight		= 400;			
		m_hMenu			= NULL;			
		m_hInstance		= hInstance;		
		m_lpParam		= NULL;	
	}


And in my main I'm trying to create it like so:

CCreateWindow mainWindow( hInstance );
hWnd = mainWindow;


So the problem is I get a compile error:

1>c:\users\$$$\documents\visual studio 2008\projects\window\main.cpp(49) : error C2440: '=' : cannot convert from 'CCreateWindow' to 'HWND'
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called


So I'm guessing that I'm missing something any ideas?
Advertisement
You didn't specify a conversion operator.

operator HWND()
{ return m_hWnd; //whatever it's called }
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!

This topic is closed to new replies.

Advertisement