Click to See Complete Forum and Search --> : Determining if a window is activated/deactivated?
dxfoo
July 17th, 2006, 01:21 AM
It was pretty easy in C#, but I'm confused on how to get a boolean state on whether the parent rendering window is activated or not. I know I should use WM_ACTIVATE, but what I do inside that code block is what gets me. Some sources or simple code would be helpful. Thanks...
humptydumpty
July 17th, 2006, 01:27 AM
It was pretty easy in C#, but I'm confused on how to get a boolean state on whether the parent rendering window is activated or not. I know I should use WM_ACTIVATE, but what I do inside that code block is what gets me. Some sources or simple code would be helpful. Thanks...
if you just want to Know that Which window is Active() you can use GetActiveWindow() .This method retrieves a pointer to the active window. The active window or NULL if no window was active at the time of the call. The pointer may be temporary and should not be stored for later use.
After That you can use GetWindowText() to retrive the Name of the Active Window.and do what ever you want to do.
Thanx
dxfoo
July 17th, 2006, 01:46 AM
Thanks for your thoughts. My goal is to have a window that does my DirectX rendering, but if the user leaves to another window outside of my program, I'd like my rendering window to recognize that and set 'active' to false. Thus, the rendering stops too. If he clicks on the window, active would be set back to true. Would I still use GetActiveWindow()?
humptydumpty
July 17th, 2006, 02:16 AM
dude When user Clicks On any Other Window That Time Another Window will get The Focus and your GetAvctiveWindow() function will return the handle of your new window.so I din't Dound Any Problem With GetActiveWindow();
Thanx
dxfoo
July 17th, 2006, 02:40 AM
Ah, okay... I got it.
void Render()
{
if (pd3dDevice == NULL)
return;
pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(100, 149, 237), 1.0f, 0);
if (GetActiveWindow() == g_hWnd)
{
pd3dDevice->BeginScene();
pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
pd3dDevice->EndScene();
}
pd3dDevice->Present(NULL, NULL, NULL, NULL);
}
Once a window is put ontop of it, the rendering stops. Thanks!
humptydumpty
July 17th, 2006, 03:02 AM
u Welcome Dude.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.