How can I prevent another program from showing a thumbnail preview in the taskbar?

Raymond Chen

A customer wanted to prevent the Contoso app from showing a thumbnail preview when the user hovers over it in the taskbar. They wrote something like this:

HWND h = FindWindow(TEXT("ContosoMainWindow"), NULL);
BOOL fTrue = TRUE;
DwmSetWindowAttribute(h, DWMWA_FORCE_ICONIC_REPRESENTATION,
    &fTrue, sizeof(fTrue));

They reported that this works for most applications, but if the target is Contoso, then it stops working when Contoso is minimized. They wanted to know if this is expected, and if there is any other way to prevent Contoso from showing a thumbnail preview.

Manipulating the windows of other applications is generally a rather dodgy undertaking. Sometimes you get away with it, sometimes you don’t. And even if you get away with it today, it may stop working tomorrow.

In this case, what happens is that you are changing the configuration of Contoso’s window, and then after you do that, Contoso reconfigures their window in a way you don’t like. I suspect Contoso enables a custom thumbnail on minimize so that they can show a prettier thumbnail than the default thumbnail.

It’s like saying, “I don’t like it when my neighbor keeps his gardening tools next to his shed, so I went into his yard and moved them to behind the shed. But every time he finishes gardening, he puts his tools next to the shed again. How do I make sure my neighbor always puts his gardening tools behind the shed instead of next to it?”

Answer: You can’t. They’re not your gardening tools nor your yard. If you sneak into his yard and move his gardening tools, it’s unreasonable to expect that they will stay where you moved it.

What you can do is have a talk with your neighbor and explain why you would prefer that he keep his gardening tools behind the shed. Maybe you can come to some sort of agreement. The customer should talk to the Contoso support team to see if there’s a policy or other setting for the Contoso app to suppress the thumbnail preview.