调用CreateEnhMetaFile后,再调用GetLastError返回2000

OPT_lezhehao 2015-02-27 05:58:33
我想要通过emf把图形通过打印机打印出来。


但是
m_hDcMeta = CreateEnhMetaFile(m_hDcPrinter, NULL, NULL, NULL);//创建增强型图元FER支持双缓冲
int ret = GetLastError(); // ret = 2000

m_hDcPrinter:是打印机句柄---已经确定句柄是正确的。

ret = 2000表示: 无效的像素格式。
我一直搞不明白,希望各位大神能搭救搭救。
...全文
233 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
worldy 2015-02-28
  • 打赏
  • 举报
回复
CreateEnhMetaFile The CreateEnhMetaFile function creates a device context for an enhanced-format metafile. This device context can be used to store a device-independent picture. HDC CreateEnhMetaFile( HDC hdcRef, // handle to a reference device context LPCTSTR lpFilename, // pointer to a filename string CONST RECT *lpRect, // pointer to a bounding rectangle LPCTSTR lpDescription // pointer to an optional description string ); Parameters hdcRef Handle to a reference device for the enhanced metafile. lpFilename Pointer to the filename for the enhanced metafile to be created. If this parameter is NULL, the enhanced metafile is memory based and its contents are lost when it is deleted by using the DeleteEnhMetaFile function. lpRect Pointer to a RECT structure that specifies the dimensions (in .01-millimeter units) of the picture to be stored in the enhanced metafile. lpDescription Pointer to a string that specifies the name of the application that created the picture, as well as the picture's title. Return Values If the function succeeds, the return value is a handle to the device context for the enhanced metafile. If the function fails, the return value is NULL. Windows NT: To get extended error information, callGetLastError. Remarks Where text arguments must use Unicode characters, use the CreateEnhMetaFile function as a wide-character function. Where text arguments must use characters from the Windows character set, use this function as an ANSI function. The system uses the reference device identified by the hdcRef parameter to record the resolution and units of the device on which a picture originally appeared. If the hdcRef parameter is NULL, it uses the current display device for reference. The left and top members of the RECT structure pointed to by the lpRect parameter must be less than the right and bottom members, respectively. Points along the edges of the rectangle are included in the picture. If lpRect is NULL, the graphics device interface (GDI) computes the dimensions of the smallest rectangle that surrounds the picture drawn by the application. The lpRect parameter should be provided where possible. The string pointed to by the lpDescription parameter must contain a null character between the application name and the picture name and must terminate with two null characters — for example, "XYZ Graphics Editor\0Bald Eagle\0\0", where \0 represents the null character. If lpDescription is NULL, there is no corresponding entry in the enhanced-metafile header. Applications use the device context created by this function to store a graphics picture in an enhanced metafile. The handle identifying this device context can be passed to any GDI function. After an application stores a picture in an enhanced metafile, it can display the picture on any output device by calling the PlayEnhMetaFile function. When displaying the picture, the system uses the rectangle pointed to by the lpRect parameter and the resolution data from the reference device to position and scale the picture. The device context returned by this function contains the same default attributes associated with any new device context. Applications must use the GetWinMetaFileBits function to convert an enhanced metafile to the older Windows metafile format. The filename for the enhanced metafile should use the .EMF extension.
OPT_lezhehao 2015-02-28
  • 打赏
  • 举报
回复
谢谢lsq19871207 我用打印机的区域应该是可以的吧,就是把屏幕换成打印机吧。 其实我不知道这样行不行
OPT_lezhehao 2015-02-28
  • 打赏
  • 举报
回复
谢谢worldy的回答 CreateEnhMetaFile中的参数lpRect为NULL是表示在内存中画图吧,然后我把NULL改为了纸张的大小,还是返回2000呐
信阳毛尖 2015-02-28
  • 打赏
  • 举报
回复
worldy 2015-02-28
  • 打赏
  • 举报
回复
CONST RECT *lpRect,一个不能使用NULL吧
OPT_lezhehao 2015-02-28
  • 打赏
  • 举报
回复
谢谢楼上的回答,不过没有解决我的问题啊。求各位高手明示
标题基于SpringBoot的学生读书笔记共享平台设计研究AI更换标题第1章引言介绍学生读书笔记共享平台的研究背景、意义、国内外研究现状、论文方法以及创新点。1.1研究背景与意义阐述学生读书笔记共享平台在当前教育环境下的重要性。1.2国内外研究现状分析国内外学生读书笔记共享平台的研究进展与现状。1.3研究方法及创新点概述本文的研究方法与平台设计的创新点。第2章相关理论总结和评述与SpringBoot及读书笔记共享平台相关的理论。2.1SpringBoot框架介绍阐述SpringBoot框架的特点、优势及其在Web开发中的应用。2.2读书笔记共享平台相关理论介绍读书笔记共享平台的设计原则、功能需求及用户体验理论。2.3数据库设计与优化理论简述数据库设计的基本原则及优化策略。第3章平台设计详细介绍基于SpringBoot的学生读书笔记共享平台的设计方案。3.1平台架构设计平台的整体架构,包括前端、后端及数据库的设计。3.2功能模块设计阐述平台的主要功能模块,如用户管理、笔记上传、笔记分享等。3.3数据库设计介绍数据库的设计方案,包括表结构、索引及关系设计。第4章平台实现详细描述平台的具体实现过程,包括技术选型、开发环境搭建等。4.1技术选型与开发环境介绍开发平台所采用的技术栈及开发环境配置。4.2关键代码实现展示平台实现过程中的关键代码片段,如用户登录、笔记上传等功能的实现。4.3平台测试与优化平台的测试过程及优化策略,确保平台的稳定性和性能。第5章平台应用与分析对平台的应用效果进行分析,包括用户反馈、使用数据等。5.1用户反馈收集与分析收集用户反馈,分析用户对平台的满意度及改进建议。5.2使用数据分析通过数据分析工具,分析平台的使用情况,如用户活跃度、笔记分享量等。5.3对比方法分析对比其他类似平台,分析本平台的优势与不足。第6章结论与展望总结本文的研究成果,并对未来研究方向
内容概要:本文针对多渗透率电动汽车接入对配电网的影响,开展承载能力评估研究,提出了一套融合多类型分布式资源的综合评估体系。研究构建了包含电动汽车、分布式光伏及静止无功补偿器(SVC)的配电网协同运行基础模型,建立了涵盖一次设备安全性、负荷平稳性、电能质量与系统运行效率的多维度评价指标体系,并采用熵权法与模糊综合评价相结合的双层模型实现指标客观赋权与系统承载能力的量化评分。通过Matlab仿真平台,系统分析了不同电动汽车渗透率下各项指标的演变规律与敏感性特征,揭示了高比例电动汽车接入对配电网的潜在压力,从而为电网的规划决策、扩容改造以及电动汽车的有序充电管理提供了科学、量化的技术支撑。; 适合人群:具备电力系统、电气工程或相关领域基础知识,从事新能源并网、智能配电网、电动汽车与电网互动(V2G)等方向研究的研究生、科研人员及电力系统工程技术人员。; 使用场景及目标:①评估大规模电动汽车无序或有序接入对配电网安全稳定运行的综合影响;②为配电网络的升级改造、设备选型及电动汽车充电基础设施布局提供决策依据;③学习并复现基于熵权-模糊综合评价法的多指标体系构建与量化评估方法,掌握其在复杂电力系统分析中的应用。; 阅读建议:建议结合文中提供的Matlab代码进行仿真复现,重点理解算例参数设置、多维指标体系的设计逻辑以及双层评价模型的具体实现步骤,通过调整渗透率等关键参数进行对比实验,以深化对评估方法原理与实际应用效果的理解。

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧