Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Taskbar aero preview not working with DX9 fullscreen mode

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 beefsteak   Members   


Posted 01 August 2013 - 03:49 AM

Hi folks,

I've written a 2D game client in C++ using DirectX/D3D 9.
In case you want to try, you can get it here: http://darkfire-rpg.com/download.html

By default, the game runs in fullscreen mode, at a resolution of 800x600.

When the user leaves the application while running, for example using the alt-tab keys, the application is reduced to the taskbar.

In this state, when the user hovers with the cursor over the taskbar icon, a thumbnail and preview image of the application should be displayed. That's a feature of the "windows desktop manager", also known as "aero effect". In my case, these preview images are always blank and I couldn't find a good way to fix that. (Please note that the problem is limited entirely to the fullscreen mode - in window mode the preview images work perfectly.)




When the application is moved to the background (while in fullscreen mode), the device object I am using (IDirect3DDevice9) goes into the state of a "lost device" (D3DERR_DEVICELOST). In that state I cannot execute any drawing operation. Only after the application is activated again by the user (returning into the foreground), the application is able to "reset" the device and continue drawing. I suspect this might be the root of the problem: As the application is unable to draw while in the background, the preview images which supposedly reflect the current "screen" state, are also blank.

If that was true, how to fix it? - the behaviour of the device cannot be changed in that regard. I experimented with a mechanism that would automatically switch the application to window mode while in the background. That produced lots of unwanted side effects however, leaving the impression of a bad hack.

I also experimented with the windows desktop manager api. Using it allows for example to set a static bitmap for the thumbnail preview in the taskbar. Unfortunately, the windows desktop manager api is not available on windows XP, so when using and linking it, the application won't run on XP anymore.


Did anyone else run into this problem?

What is the proper solution?

Edited by beefsteak, 01 August 2013 - 03:58 AM.

#2 beefsteak   Members   


Posted 01 August 2013 - 04:15 AM

A also pondered about the device- and window-class configurations I am using: Maybe some special setting
I am using in fullscreen mode causes incompatibility issues with the windows desktop manager?


In case it matters I have posted my configurations below:

// window style for window-mode: title bar, close box, minimize box

// window style for fullscreen: no titlebar, popup style

Window::Window(HINSTANCE hInstance, WNDPROC messageHandler, LPCTSTR title, int width, int height, bool pFullscreen):
	// start with default cursor
	activeCursor = DfCursor::C_DEFAULT;

	// define window class properties
	windowClass.style = NULL;
	windowClass.lpfnWndProc = messageHandler;
	windowClass.cbClsExtra = 0;
	windowClass.cbWndExtra = 0;
	windowClass.hInstance = hInstance;
	windowClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
	windowClass.hCursor = activeCursor == NULL ? NULL : activeCursor->getWinCursor();
	windowClass.hbrBackground = NULL;
	windowClass.lpszMenuName = NULL;
	windowClass.lpszClassName = title;

	// calculate correct window size and position
	RECT clientRect;
	calculatePosition(width, height, fullscreen, &clientRect);

	window = CreateWindow(windowClass.lpszClassName,
			clientRect.left, clientRect.top,
			clientRect.right - clientRect.left, clientRect.bottom - clientRect.top,
			GetDesktopWindow(), NULL, windowClass.hInstance, NULL);

	if (window == NULL) {
		throw (TEXT("Window Constructor: Failed to create a new window!"));
DfGraphicsManager::DfGraphicsManager(ResourceManager *resourceManager, HWND window, int width, int height, bool fullscreen):
desiredScreenResolutionY(height) {
	context = Direct3DCreate9(D3D_SDK_VERSION);

	if (context == NULL) throw(TEXT("D3DManager Constructor: Failed to create a Direct3D Context!"));

	parameters.BackBufferWidth = width; parameters.BackBufferHeight = height;
	parameters.BackBufferFormat = D3DFMT_X8R8G8B8;
	parameters.BackBufferCount = 1;
	parameters.MultiSampleType = D3DMULTISAMPLE_NONE;
	parameters.MultiSampleQuality = 0;
	parameters.SwapEffect = D3DSWAPEFFECT_FLIP; // flip between front and back buffer
	parameters.hDeviceWindow = window;
	parameters.Windowed = !fullscreen;
	parameters.EnableAutoDepthStencil = true;
	parameters.AutoDepthStencilFormat = D3DFMT_D16;
	parameters.Flags = NULL;
	parameters.FullScreen_RefreshRateInHz = 0;
	parameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	// create the device.
	HRESULT result = context->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
		D3DCREATE_MIXED_VERTEXPROCESSING, &parameters, &device);
	errorCheck(result, TEXT("D3DManager Constructor: Failed to create device!\r\n"));

	// for a 2D application: turn off z-buffer, culling and lightning
	device->SetRenderState(D3DRS_ZENABLE, false);
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

Edited by beefsteak, 01 August 2013 - 11:20 AM.

#3 belfegor   Members   


Posted 01 August 2013 - 05:01 AM

I am not sure, can you try with CreateWindowEx and set layered flag WS_EX_LAYERED and see if that works?


And this might be of interest.

Edited by belfegor, 01 August 2013 - 05:04 AM.

#4 beefsteak   Members   


Posted 01 August 2013 - 07:38 AM

The flag WS_EX_LAYERED didn't change much. For some reason, with WS_EX_LAYERED the preview is not entirely blank anymore, but rather showing an empty (white) window including borders and title bar.

The function DwmSetIconicLivePreviewBitmap is part of the WDM api, which I'd rather not use due to Windows XP support. Using it would allow for some workarounds probably.

Edited by beefsteak, 01 August 2013 - 11:21 AM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.