Am I really in full screen mode?

Started by
4 comments, last by sipickles 17 years, 11 months ago
Hi, When I Alt-tab my app into fullscreen mode, it appears to work ok... monitor clicks into gear, etc Strangely, if I point the cursor at any of the corners and press LMB, the 'fullscreen' app loses focus and it switches back to the desktop. Also if i hove the mouse over the edge, I get a resizing icon for a mouse pointer.... If I start in fullscreen mode, the WS_POPUP that the app creates the window with makes it work fine. How do I tell directX to use WS_POPUP after toggling from a WS_OVERLAPPEDWINDOW? or to put it another way, from a resetdevice not a createwindow? Thank you. Simon
Advertisement
Are you setting the backbuffer width, height, etc? Or just the style in the CreateWindowEx function?
The latter appears to work, but isn't real fullscreen. That may be the problem, though I've never seen it do what you have before.
____________________________________Spazuh- Because I've had too much coffee
Try

SetWindowLong(yourHwnd, GWL_style, WS_POPUP);
_______________________________________________________________________Hoo-rah.
It also sounds to me like you're not resetting your device properly (With IDirect3DDevice9::Reset()), and just changing the window style.

Also note that if you do what Drakex said, you'll need to Reset() the device, and call SetWindowPos() passing the SWP_FRAMECHANGED flag to properly update the window frame.
Although you usully only need to update the frame when going from fullscreen to windowed.

Can we see your code for changing between fullscreen / windowed mode?
Here's my device handling function. The app uses this function for both creating and resetting the device, depending on bool firstTime parameter.

///////////////////////////////////////////////////////////////// cFramework::RestoreDevice - creates d3d9 device or resets it///////////////////////////////////////////////////////////////bool cFramework::RestoreDevice( bool firstTime ){	// Prepare the device presentation parameters.	D3DPRESENT_PARAMETERS d3dpp;	ZeroMemory( &d3dpp, sizeof( D3DPRESENT_PARAMETERS ) );	d3dpp.BackBufferWidth				= m_displaySettings->m_screenWidth;//g_deviceEnumeration->GetSelectedDisplayMode()->Width;	d3dpp.BackBufferHeight				= m_displaySettings->m_screenHeight;//g_deviceEnumeration->GetSelectedDisplayMode()->Height;	d3dpp.BackBufferFormat				= m_displaySettings->m_screenFormat;//g_deviceEnumeration->GetSelectedDisplayMode()->Format;//	d3dpp.BackBufferFormat				= D3DFMT_A8R8G8B8;	d3dpp.BackBufferCount				= 2;	d3dpp.MultiSampleType				= D3DMULTISAMPLE_NONE;	d3dpp.MultiSampleQuality			= 0;	d3dpp.SwapEffect					= D3DSWAPEFFECT_DISCARD;	d3dpp.hDeviceWindow					= m_displaySettings->m_hWnd;	d3dpp.Windowed						= m_displaySettings->m_windowed;	d3dpp.EnableAutoDepthStencil		= true;	d3dpp.AutoDepthStencilFormat		= D3DFMT_D24S8;	//d3dpp.FullScreen_RefreshRateInHz	= g_deviceEnumeration->GetSelectedDisplayMode()->RefreshRate;	if( m_displaySettings->m_vSync == true )		d3dpp.PresentationInterval		= D3DPRESENT_INTERVAL_DEFAULT;	else		d3dpp.PresentationInterval		= D3DPRESENT_INTERVAL_IMMEDIATE;	//TEST for software or hardware vertex support	D3DCAPS9 d3dCaps;	if( FAILED( m_d3d->GetDeviceCaps( D3DADAPTER_DEFAULT,									   D3DDEVTYPE_HAL, &d3dCaps ) ) )	{		MessageBox(NULL, "FAILED", "GetDeviceCaps", MB_OK);		return false;	}	DWORD dwBehaviorFlags = 0;	D3DDEVTYPE DeviceType;	if( d3dCaps.VertexProcessingCaps != 0 )	{		DeviceType = D3DDEVTYPE_HAL;		dwBehaviorFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING/* | D3DCREATE_MULTITHREADED*/;		g_debugMode = FULL;		g_log->SYSTEM( "Attempting HAL %s device\n", m_displaySettings->m_windowed ? "windowed" : "fullscreen" );	}	else	{		DeviceType = D3DDEVTYPE_REF;// D3DDEVTYPE_SW		dwBehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING/* | D3DCREATE_MULTITHREADED*/;		g_debugMode = LAPTOP;		g_log->SYSTEM( "Attempting REF %s device\n", m_displaySettings->m_windowed ? "windowed" : "fullscreen" );	}	HRESULT hr = S_OK;	if ( firstTime )	{		// Create the Direct3D device.		hr = m_d3d->CreateDevice( D3DADAPTER_DEFAULT, 								DeviceType, 								m_displaySettings->m_hWnd, 								dwBehaviorFlags, 								&d3dpp, 								&g_device );		if( FAILED( hr ) )		{			MessageBox(NULL, "Create Device FAILED!", "Error", MB_OK);			return false;		}			g_log->SYSTEM( "Direct3D9 Device Created\n" );		g_simulation->OnCreateDevice();		g_guiManager->OnCreateDevice();		}	else		// this is a reset	{		OnLostDevice();		// clear VBs and textures from allocations, like GUI, simulation?		g_device->Reset( &d3dpp );		hr = g_device->TestCooperativeLevel();		if ( hr==D3DERR_DEVICELOST ) 		{			return false;				// app doesnt have focus		} 		else if ( hr==D3DERR_DEVICENOTRESET ) 		{			// Reset device code here 			RestoreDevice( false );		// reset device if lost, loopback and try again		}		else if ( hr==D3DERR_INVALIDCALL )			MessageBox( NULL, "D3DERR_INVALIDCA", "D3DERR_INVALIDCA", MB_OK );						if( FAILED( hr ) )		{			//MessageBox(NULL, "Reset Device FAILED!", "Error", MB_OK);			return false;		}			g_log->LogNewLine();		g_log->SYSTEM( "Direct3D9 Device Reset\n" );		if ( g_framework->GetDisplaySettings()->m_windowed )		{			//Reset the window styles after D3D has buggered it			RECT rc;			rc.top = 0; rc.left = 0;			rc.right = g_framework->GetDisplaySettings()->m_screenWidth;			rc.bottom = g_framework->GetDisplaySettings()->m_screenHeight;			AdjustWindowRect(	&rc,								WS_OVERLAPPEDWINDOW, FALSE );											rc.right -= rc.left;			rc.bottom -= rc.top;			SetWindowLong(	g_framework->GetDisplaySettings()->m_hWnd,							GWL_STYLE,							WS_OVERLAPPEDWINDOW);			SetWindowPos(	g_framework->GetDisplaySettings()->m_hWnd,							NULL,							0,0,							rc.right,rc.bottom,							SWP_FRAMECHANGED|SWP_NOZORDER);			ShowWindow( g_framework->GetDisplaySettings()->m_hWnd, SW_SHOW );		}					g_simulation->OnResetDevice();		g_guiManager->OnResetDevice();		}	return true;}
Thats done it guys!

Thanks

Si

This topic is closed to new replies.

Advertisement