January 18th, 2021

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

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.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

10 comments

Discussion is closed. Login to edit/delete existing comments.

  • M. W.

    In my experience, talking with people rarely works; I’ve filed countless bug-reports for various programs and websites and reported countless fraudulent listings on eBay and so on, but they usually just they end up being ignored or rejected. Unfortunately, most of the time, the only way to get things done is to just burn down the shed. 🤷

    • Flux

      … at which point the police would arrest and incarcerate you for arson. Rumor has it that in the American prison, other prisoners forcibly reconfigure your face, the painful way.

      On a more serious note, when more than one developer rejects your bug reports, it is high time you realized there is something wrong with your reports.

      • Bwmat

        Your second paragraph is quite naive.

      • Joshua Hudson

        Microsoft rejects bugs because they don’t want to put in the effort. This means your test is poor. Elsewhere I get better response rate and actual fix rate. But sometimes it just doesn’t get fixed. I remember this one where the musl-libc developers and the glibc developers were each telling the other they were wrong about what a library function should do.

      • Marc K

        It seems like outsourced support reps are either incentivized to close cases or are penalized for letting an issue get escalated. It's very frustrating when it's so obvious the rep's goal is to discard my case as fast as possible. Then some teams are happy to let cases languish forever. I've got one case with a firewall vendor that's been open almost a year now because they deemed a satisfactory work-around is...

        Read more
      • Jonathan Harston

        I’ve had arguments like that.
        min(x,y) should return the smallest value.
        What if they’re equal? I’ve had arguments over whether a=1; b=1; c=min(a,b); should return a or b.

      • Bwmat · Edited

        Does that ‘min’ take in and return references? Otherwise why would it matter?

      • Neil Rashbrook

        Then there’s positive and negative zero…

      • cheong00

        Easy. Just let them supply their own compare function to it. The choice of “<" and "<=" will enable them to decide whether to return a or b.

        At least that's how LINQ solved this kind of problem.

      • Joshua Hudson

        if (vfork() == 0) { setuid(2); exec(…); } dreadlocks on musl long. I submitted a one line patch that was rejected. Then the musl and glibc devs argued over whether or not that sequence is defined.