Jump to content
  • Advertisement
Sign in to follow this  
xpload

Losing focus

This topic is 4094 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

Does somebody know why the D3D display begins to flicker (to flip frequently between the windows desktop and my program), when my program calls system("copy some files") ? Moreover, the cursor looses its real position and sends wrong data to my WinMain function... Help please :(

Share this post


Link to post
Share on other sites
Advertisement
Well... it's a large project. Here is the D3D initialization code:

m_pD3D = Direct3DCreate8( D3D_SDK_VERSION );
if ( m_pD3D == NULL ){
Error.generate( "Couldn’t create DirectX object.", PARX_SYSTEM );
return E_FAIL;
}
D3DPRESENT_PARAMETERS D3DPresentParams;
ZeroMemory( &D3DPresentParams, sizeof(D3DPRESENT_PARAMETERS) );
D3DPresentParams.Windowed = FALSE;
D3DPresentParams.BackBufferCount = 1;
D3DPresentParams.BackBufferWidth = 1024;
D3DPresentParams.BackBufferHeight = 768;
D3DPresentParams.BackBufferFormat = D3DFMT;
D3DPresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
D3DPresentParams.hDeviceWindow = m_hWnd;
HRESULT hResult = m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &D3DPresentParams, &m_pD3DDevice );

if (FAILED(hResult)){
Error.generate( "Failed to create Direct3D device.", PARX_SYSTEM );
return hResult;
}
return hResult;

And the MFC initialization:

WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = (HCURSOR)LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "mechanik2007";
wc.hIconSm = NULL;

RegisterClassEx(&wc);

g_hWnd = CreateWindowEx(
NULL,
"mechanik2007",
"mechanic 2007",
WS_OVERLAPPEDWINDOW,
0,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
GetDesktopWindow(),
NULL,
hInstance,
NULL);

When I start the program, everything is fine. But when the program loses its focus(I still don't need to realloc all the data) some elements begin to appear and hide repeatedly.

Here you can download the program: http://yanev.findmebg.com/mechanik2007.rar

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!