Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 views
in Technique[技术] by (71.8m points)

windows - C# - on mouseover at taskbar, a preview is generated. how can i achieve this by C# coding

I am developing a winForm application in which i am list all the running processes. on mouseover of any process, i want preview window like (In Windows 7, when you mouse over an application in your task bar, a preview is generated showing the contents of the application window.) See Image.

enter image description here

Any idea how to achieve this, i am not able to get it. Any suggestion will be helpful. Thanks..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

full example at this site
You need two functions :

[DllImport("dwmapi.dll")]
static extern int DwmRegisterThumbnail(IntPtr dest, IntPtr src, out IntPtr thumb);

[DllImport("dwmapi.dll")]
static extern int DwmUpdateThumbnailProperties(IntPtr hThumb, ref DWM_THUMBNAIL_PROPERTIES props);

usage of DwmRegisterThumbnail
you are at your form, and process it a external program that you want to paint at your program.

IntPtr hWnd = process.MainWindowHandle;
int i = DwmRegisterThumbnail(this.Handle, hWnd, out thumb);

after registration, you just saying to windows the location to paint the picture

            DWM_THUMBNAIL_PROPERTIES props = new DWM_THUMBNAIL_PROPERTIES();

            props.fVisible = true;
            props.dwFlags = DWM_TNP_VISIBLE | DWM_TNP_RECTDESTINATION | DWM_TNP_OPACITY;
            props.opacity = 255;
            props.rcDestination = new Rect(panel.Left, panel.Top, panel.Right, panel.Bottom);

            DwmUpdateThumbnailProperties(thumb, ref props);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...