Skip to main content
gamedev.net
🔒 Locked

Code doesn't work

Started by programmermattc Jun 3, 2006 at 11:33 AM 0 replies 400+ views
Original Post
programmermattc
programmermattc
Hey everyone, I'm trying to create some code that creates my basic window by calling an object of that class and it compiles fine but doesn't work, any ideas? Here's the code (Don't worry about initializing Dx or Rendering the scene, I just added that thinking it'd make my window appear)
=============================RhinoXNA - Easily start building 2D games in XNA!Projects
Xrystal
Xrystal
Ah I see the problem .. you're creating the format of the window and registering it but you're not actually creating the window and showing it.

You need to add something like the following after registering your WNDCLASS structure.

bool CApp::CreateWin(void){	m_hWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, //the extended style 		                m_szClass,    	        //the class name				m_szTitle,	        //the window's title			        WS_OVERLAPPEDWINDOW,	//the window's style				CW_USEDEFAULT,  CW_USEDEFAULT,	//the position			        m_iWidth,		//the width				m_iHeight,		//the height				NULL,			//no parent window				NULL,			//no menu needed				m_hInstance,	        //the window's instance				NULL );		//nothing to pass to WM_CREATE	if (!m_hWnd)	{		Shutdown( );						return false;				}	return true;}bool CApp::ActivateWindow(void){	ShowWindow( m_hWnd, SW_SHOW );	//Show the window	SetForegroundWindow( m_hWnd );	//Give the window a high priority	SetFocus( m_hWnd );     //Sets the keyboard's focus to the window	return true;}


Not dabbled with unmanaged c++ in a while but I used this code in a base class and then created sub classes from it for regular different types of windows like for OpenGL or DirectX usage.

I'm sure once you implement these routines into your program it will run.

Topic Locked

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

Sign in to reply to this topic.