如何预览应用程序 [英] How do I get a preview of an application

查看:100
本文介绍了如何预览应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!



我正在尝试在WPF应用程序中找到一种可视化应用程序(任何类型)的方法。让我解释一下我的情况:



我正在开发一个用于医疗目的的WPF应用程序。医生的电脑将配备两台显示器,扩展桌面。我正在处理的应用程序将是医生的控制面板,它将显示在医生面前的监视器1上。这个wpf应用程序将在某个时刻启动一个新进程(.exe,不一定是wpf),在监视器2上显示病人面前的窗口。考虑到医生可能不在同一个房间。耐心,我需要反映患者在我的WPF应用程序中可视化的内容,以便医生控制正在发生的事情。



现在,我最好的例外need,是当鼠标悬停时,我们现在在任务栏中的Windows 7和8中所拥有的精美缩略图预览。我已经看过这个API,但找不到在这些缩略图中获取图像的方法......



任何帮助都将不胜感激:)

Hi there !

I'm trying to find a way to visualize an application (of any kind) in a WPF application. Let me explain my situation :

I'm developping an application in WPF for medical purpose. The doctor's computer will have two monitors, in extended desktop. The application I'm working on will be the control panel for the doctor, which will be displayed on monitor 1, in front of the doctor. This wpf application, will, at some point, start a new process (.exe, not necessarily wpf), to display a window in front of the patient, on monitor 2. Considering that the doctor may not be in the same room as the patient, I need to mirror what the patient is visualizing in my WPF application, for the doctor to control what is happening.

Now, my best exemple of what I would need, is the beautiful thumbnail preview that we have nowadays in Windows 7 & 8 in the tasks bar, when mouse is hovering. I've taken a look in this API but can't find a way to get the image in those thumbnail...

Any help would be greatly appreciated :)

推荐答案

这些图像只是缩放到不同大小的屏幕截图;请参阅 https://www.google.com/search?q=screen+capture+c%23 [ ^ ]关于屏幕截图的文章。
Those images are just screen captures that are scaled to a different size; see https://www.google.com/search?q=screen+capture+c%23[^] for articles on screen capturing.


谢谢你,我一直在尝试其中的几个解决方案,但大多数都是为截图设计的,我正在寻找直播流。这可能是另一个主题,但有了这些解决方案,问题归结为流动性和内存利用率,我的应用程序在30秒左右后崩溃...



编辑:



此代码似乎工作正常,这是



Thank you for that, I've been trying several of these solutions though, but most of them are designed for screenshots, where I'm looking for "live stream". That might be another subject but with those solutions, the problem comes down to fluidity, and memory utilisation, my app crashing after 30 seconds or so...

EDIT :

This code seems to be working correctly, thx

IntPtr hBitmap;
            IntPtr hDC = User32.GetDC(User32.GetDesktopWindow());
            IntPtr hMemDC = GDI32.CreateCompatibleDC(hDC);

            hBitmap = GDI32.CreateCompatibleBitmap(hDC, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

                IntPtr hOld = (IntPtr)GDI32.SelectObject
                                       (hMemDC, hBitmap);

                GDI32.BitBlt(hMemDC, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, hDC,
                                               0, 0, GDI32.SRCCOPY);

               
            
            WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero,
                                                                                         Int32Rect.Empty,
                                                                                         BitmapSizeOptions
                                                                                             .FromEmptyOptions());
            

            GDI32.SelectObject(hMemDC, hOld);
            GDI32.DeleteDC(hMemDC);
            User32.ReleaseDC(User32.GetDesktopWindow(), hDC);
            GDI32.DeleteObject(hBitmap);
            GC.Collect();
return WpfBitmap;


这篇关于如何预览应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆