C++ Learning Community Forum
August 01, 2010, 02:51:18 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: alt-tab handler  (Read 1666 times)
*brammie*
my rank:
C++ Freak
***
Posts: 309



View Profile WWW
« on: May 23, 2008, 02:53:34 PM »

does anyone know how to make a good alt-tab handler for directx?
Logged
*brammie*
my rank:
C++ Freak
***
Posts: 309



View Profile WWW
« Reply #1 on: May 25, 2008, 09:04:36 PM »

-bump-
nobody?
Logged
biggoron
C++ Freak
***
Posts: 351


View Profile
« Reply #2 on: May 25, 2008, 09:48:31 PM »

What's to handle?
Logged

Melastoma
C++ Freak
***
Posts: 326


>:3


View Profile
« Reply #3 on: May 25, 2008, 10:39:55 PM »

What's to handle?

When you alt-tab from a full screen DirectX app, you have to reset the device and re-create all the resources that were in video memory. I've never really looked into it, but I read somewhere that a good thing to do would be to have it call the initialization procedure once the window is re-activated. *Shrug*
Logged

Quote
The language itself isn't complicated, it's getting it to do what you want that's the puzzle.
Here, Here.That, my friend, should be on a T-shirt, or in somones signature.

*brammie*
my rank:
C++ Freak
***
Posts: 309



View Profile WWW
« Reply #4 on: May 26, 2008, 11:53:16 AM »

ok thanks, ill try it out when i come home Wink
edit: it works, but now, if i alt-tab out of it, it directly goes back without alt-tabbing in it.
this is my code:
Code:
HRESULT hr;
hr=d3ddev->TestCooperativeLevel();
if (hr==D3DERR_DEVICELOST || hr==D3DERR_DEVICENOTRESET) enable_d3d(hwnd,hi);
how could i make it wait until i alt-tab back in?
« Last Edit: May 26, 2008, 02:37:28 PM by *brammie* » Logged
TheoLogic
Nerd
****
Posts: 92



View Profile
« Reply #5 on: May 26, 2008, 03:54:39 PM »

D3DERR_DEVICELOST tells you that the device is lost, but it can't be resetted yet. So maybe do this;
Code:
if(hr == D3DERR_DEVICELOST)
{
Sleep(100); //Wait a bit so we don't burn through cycles for no reason
}
else if(hr == D3DERR_DEVICENOTRESET)
{
m_pd3dDevice->Reset(&d3dpp);
}
Logged

TheoLogic - Portfolio.
Wiki - Personal wiki pages.
Melastoma
C++ Freak
***
Posts: 326


>:3


View Profile
« Reply #6 on: May 26, 2008, 10:41:09 PM »

You can also use "WM_ACTIVATE", which I believe is called anytime a window gains or loses focus.
Logged

Quote
The language itself isn't complicated, it's getting it to do what you want that's the puzzle.
Here, Here.That, my friend, should be on a T-shirt, or in somones signature.

*brammie*
my rank:
C++ Freak
***
Posts: 309



View Profile WWW
« Reply #7 on: May 27, 2008, 07:43:01 AM »

well, i did try this:
Code:
HRESULT hr;
hr=d3ddev->TestCooperativeLevel();
if (hr==D3DERR_DEVICENOTRESET) enable_d3d(hwnd,hi);
but it won't work.
so i think i would try WM_ACTIVATE, ill edit if it works Wink
Logged
TheoLogic
Nerd
****
Posts: 92



View Profile
« Reply #8 on: May 27, 2008, 08:18:30 AM »

Alt-tab is a sizemove...

Code:
case WM_SIZE:
switch(wParam){
case SIZE_MAXIMIZED:
m_bFullScreen=true;
break;
case SIZE_MINIMIZED:
m_ptrGame->GameEnd();
bIsMinimised=true;
break;
case SIZE_RESTORED:
if(bIsMinimised){
m_ptrGame->GameStart();
bIsMinimised=false;
}
//if(bSizeMoved){//after a resize, not during resizing
// FullOrWindowed();
// bSizeMoved=false;
//}
break;
}
break;

This way changes the size also to fullscreen to windowed, but I think u'll get the idea Smiley
Logged

TheoLogic - Portfolio.
Wiki - Personal wiki pages.
*brammie*
my rank:
C++ Freak
***
Posts: 309



View Profile WWW
« Reply #9 on: May 27, 2008, 02:59:27 PM »

WM_SIZE works, thanks =)

Code:
case WM_DESTROY:
PostQuitMessage (0);
break;
case WM_SIZE:
if (alt_tab_reset && wParam==SIZE_RESTORED)
enable_d3d(hwnd,pass);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
break;
Logged
TheoLogic
Nerd
****
Posts: 92



View Profile
« Reply #10 on: May 27, 2008, 06:27:01 PM »

Glad to be of service. All those little things make a programmers life difficult Smiley
I'm programming a mini RTS in DX too, and it's getting the hell out of me. HLSL is cool too, but man, difficult Smiley
Logged

TheoLogic - Portfolio.
Wiki - Personal wiki pages.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!