Ensure WPF Taskbar Window Preview is actualized

☆樱花仙子☆ 提交于 2019-12-14 03:39:50

问题


How can I ensure that the hower preview of my WPF application (.net 4) is refreshed when the user places the mouse over the taskbar icon.
I have an app that visualizes some status values. If the app window is minimized and the user hovers over the taskbar button, the preview window that is shown shows the last view of the window at which the window was active. However I would like to have an actualized view.
Is there a possiblity to achieve that?


回答1:


I believe you'd need to customize the preview, as described here (under the Customizing Preview section). Which leverages the Windows API Code Pack for Microsoft® .NET Framework.

An example can be found here, but looks like:

TabbedThumbnail preview = new TabbedThumbnail(parentForm.Handle, childForm.Handle);
TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview);
preview.TabbedThumbnailBitmapRequested += (o, e) =>
    {
        Bitmap bmp = new Bitmap(width, height);

        // draw custom bitmap...

        e.SetImage(bmp);
        e.Handled = true;
    };

Another example, can be found here which states:

The CustomWindowsManager class provides an abstraction of a customized window thumbnail preview and live preview (peek), including the facilities to receive a notification when a preview bitmap is requested by the Desktop Window Manager (DWM) and to automatically grab the preview bitmap of a window.

The download link for this code is here, which includes the CustomWindowsManager class. This appears to provide the live preview.




回答2:


You probably can't. Windows 7 pipes the graphics of an open window to the live preview from the Taskbar. It can't know what the window now looks like while it is minimized because it isn't being drawn at all.

I guess it's not impossible to do custom thumbnails. Aside from CodeNaked's answer, I also found this article, which even includes multiple thumbnails from the same app.



来源:https://stackoverflow.com/questions/6298556/ensure-wpf-taskbar-window-preview-is-actualized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!