Sign in to follow this  

Alt + Tab and D3D9, I've tried everything

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know this has already been answered, but I've looked at over 20 posts here on gamedev and searched on google to no avail. Everytime I press alt+tab my app closes. Here is my code:
//WndProc
//Try 1
case WM_ACTIVATE:
{
    int iActivate = LOWORD(wParam);
    if(iActivate == WA_CLICKACTIVE)
    {
        ShowWindow(hWnd, SW_SHOWNORMAL);
        return 0;
    }
    else if(iActivate == WA_INACTIVE)
    {
        ShowWindow(hWnd, SW_SHOWMINIMIZED);
        return 0;
    }
}

//Try 2
case WM_KILLFOCUS:
{
    ShowWindow(hWnd, SW_MINIMIZE);
    return 0;
}

case WM_SETFOCUS:
{
    ShowWindow(hWnd, SW_SHOWNORMAL);
    return 0;
}

// Direct3D reset code
HRESULT GraphicsDevice::Reset()
{
	if(m_pDevice->TestCooperativeLevel() == D3DERR_DEVICELOST)
		return D3DERR_DEVICELOST;
	
	if(m_pDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET)
	{
		D3DPRESENT_PARAMETERS PresentParams;
		ZeroMemory(&PresentParams, sizeof(D3DPRESENT_PARAMETERS));
		PresentParams.BackBufferCount			= 1;
		PresentParams.BackBufferWidth			= m_iWidth;
		PresentParams.BackBufferHeight			= m_iHeight;
		PresentParams.BackBufferFormat			= m_Format;
		PresentParams.hDeviceWindow				= m_hWnd;
		PresentParams.SwapEffect				= m_SwapEffect;
		PresentParams.Windowed					= m_bWindowed;
		PresentParams.EnableAutoDepthStencil	= TRUE;
		PresentParams.AutoDepthStencilFormat	= m_DepthFormat;
		
		m_hResult = m_pDevice->Reset(&PresentParams);
	}
	
	return S_OK;
}


I believe that I'm doing everything right, but I don't know. Any help would be awesome, thanks!

Share this post


Link to post
Share on other sites
Hmm yes this is a pain in the but especially if you didnt plan on implementing the reset from the start.

Well basically what comes to mind is that in addition to reseting the device certain memory needs to be reallocated.

Quote:

Calling IDirect3DDevice9::Reset causes all texture memory surfaces to be lost, managed textures to be flushed from video memory, and all state information to be lost. Before calling the IDirect3DDevice9::Reset method for a device, an application should release any explicit render targets, depth stencil surfaces, additional swap chains, state blocks, and D3DPOOL_DEFAULT resources associated with the device.


from msdn.

-CProgrammer

Share this post


Link to post
Share on other sites
I knew that (I should of stated that in the beginning). I'm not allocating any memory right now (only my window, Direct3D, and DirectInput are being created). I'm sure that I'm creating everything right (since my app is added to the TaskManager and the toolbar), but when I alt+tab it's gone.

Share this post


Link to post
Share on other sites
Ok, I've figured out that its not a problem with my graphics/windows code, but it's my DirectInput update code.

Okay, I figured out that my DirectInput's update code had an extra if() statement in it, but what I want to know is how come I could call my keyboard device's GetDeviceState() but it would give me a access violation when I tried to do my mouse device's.

Thanks

[Edited by - Programmer16 on August 28, 2004 12:55:53 AM]

Share this post


Link to post
Share on other sites

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this