如何进行工作项目的打印屏幕并将其保存为位图 [英] How can I do a printcreen of working project and save them as bitmap

查看:76
本文介绍了如何进行工作项目的打印屏幕并将其保存为位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的初始化项目中有4个按钮(按钮控件)。我知道如何设置图片(位图)。 (使用bcg库)



这4个按钮代表4个最近的项目。我的目的是在用户例如关闭当前项目时进行打印,并将此打印屏幕保存为位图(我应该在哪里保存?)

如何保存此预览(位图)?



然后我加载这个位图作为我们最近的项目预览



我尝试过:



作为第一步,我知道bcg库中的方法,

I have 4 buttons (button controls) on our startpage project. I know how to set a picture(bitmap) on it. (using bcg library)

These 4 buttons represent 4 recent projects. My aim is to do printcreen when user for example close current project and save this printscreen as bitmap (where should I save?)
How to save this preview(bitmap)?

Then I load this bitmap as our recent project preview

What I have tried:

As a first step I know about method in bcg library,

CreateScreenshot

,但到目前为止还没有结果。

, but so far with no results.

推荐答案

当您的应用程序打开文档时,它会显示在 CWnd 派生类中(例如的CView )。有几种方法可以将 CWnd 的内容放入位图中;有和没有边框和标题:



  • 使用内存 CDC 调用 BitBlt (复制)或 StretchBlt (缩放副本)

  • 发送一个 WM_PRINTCLIENT 消息(源窗口必须支持)

  • 使用 CWnd :: PrintWindow (必须由派生的 CWnd 实施)

When your application has a document opened it is shown in a CWnd derived class (e.g. a CView). There are several methods to get the content of a CWnd into a bitmap; with and without border and caption:

  • Using a memory CDC calling BitBlt (copy) or StretchBlt (scaled copy)
  • Sending a WM_PRINTCLIENT message (must be supported by the source window)
  • Using CWnd::PrintWindow (must be implemented by the derived CWnd)
引用:

我应该保存在哪里?

保存此类数据的常见位置是

The common place to save such data is

%USERPROFILE%\AppData\Local\<MyCompany>\<MyApp>

漫游而不是 Local ,需要跨域同步。拨打 SHGetKnownFolderPath功能(Windows) [< a href =https://msdn.microsoft.com/en-us/library/windows/desktop/bb762188(v=vs.85).aspx\"target =_ blanktitle =New Window> ^ ]与 FOLDERID_LocalAppData FOLDERID_RoamingAppData 获取路径并附加您的公司和应用名称(这些子目录必须是安装应用程序时创建的。)



但是,正如您在回答之前的一个问题时所建议的那样,可能没有必要保存文件。启动应用程序时,您可以在隐藏视图中打开每个最近的文件以获取屏幕截图。这也避免了删除旧的位图文件。





or Roaming instead of Local when synchronizing across domains is required. Call the SHGetKnownFolderPath function (Windows)[^] with FOLDERID_LocalAppData or FOLDERID_RoamingAppData to get the path and append your company and app name (those sub directories must be created when installing your application).

But as already suggested in an answer to one of your previous questions it might be not necessary to save the files. When starting your application you might open each recent file in a hidden view to take the screenshot. This avoids also deleting old bitmap files.


Quote:

如何保存此预览(位图)?

How to save this preview(bitmap)?

因为您需要一个位图来显示,所以保存为位图是有意义的。使用 CImage 类来保存和加载图像。如果尺寸很重要,您也可以保存为PNG。

Because you need a bitmap for displaying, it makes sense to save as bitmap. Use the CImage class to save and load images. If size matters you may also save as PNG.


这篇关于如何进行工作项目的打印屏幕并将其保存为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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