调用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表示: 无效的像素格式。
我一直搞不明白,希望各位大神能搭救搭救。
...全文
238 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
  • 打赏
  • 举报
回复
谢谢楼上的回答,不过没有解决我的问题啊。求各位高手明示
源码链接: https://pan.quark.cn/s/4059260b3dc9 在电子设计自动化(EDA)范畴内,Verilog作为一项关键的硬件描述语言(HDL),被普遍应用于构建数字系统的模型,其应用范围涵盖从基础的逻辑门构造到高级的系统级设计,例如本案例所探讨的电梯系统。运用Verilog进行的电梯系统构建是一个典型的综合实践任务,它融合了数字逻辑、嵌入式系统以及计算机工程等多个核心知识领域。 我们必须明确电梯系统的功能要求。电梯需依据乘客的楼层指令,智能地选择其运行路径、选择停靠的楼层以及安排门的开启流程。这一过程涉及到状态机的设计,这是Verilog编程中的一个核心概念。状态机能够将电梯的操作流程划分为多个独立的状态,例如待机、上行、下行、开门、关门等,通过状态间的转换条件来执行各类操作。 Verilog程序通常由多个模块构成,每个模块对应电路的一部分。在此项目中,可能包含以下模块:主控制单元模块、楼层识别模块、按键输入单元模块、电机驱动模块等。各模块均具备特定的功能,例如主控制单元负责统筹各部分的工作,而电机驱动模块则依据指令操控电梯的升降动作。 在构建电梯系统时,还需关注实时性和同步性。例如,电梯不允许在两个楼层同时开启门,这需要在Verilog程序中运用适当的同步手段,例如边沿触发的时钟信号,以确保数据传输的精确性与统一性。 接下来是仿真环节和验证步骤。借助ModelSim或Vivado这类软件工具,我们可以对Verilog程序进行仿真,模拟电梯的操作情形,考察其在不同情境下的表现是否符合设计预期。此步骤极为关键,有助于识别并修正设计中的缺陷。 倘若设计满足所有条件,可将Verilog程序编译并上传至FPGA(现场可编程门阵列)进行硬件层...
内容概要:本文基于Simulink平台,构建了一个包含风能、太阳能、储能系统和质子交换膜(PEM)电解水制氢系统并网运行的交流母线协调仿真模型。该模型旨在研究多种能源形式与制氢负荷在共用交流母线下的协调运行机制,重点分析风光出力波动性对系统稳定性的影响,以及储能与制氢负荷在能量调节和消纳富余可再生能源方面的作用。通过设计合理的控制策略,实现系统内功率的动态平衡与高效利用,并对系统在不同工况下的动态响应特性进行了仿真验证,为高比例可再生能源接入背景下风光储氢一体化系统的规划与运行提供了技术参考。; 适合人群:具备一定电力系统、新能源或自动化专业背景,从事相关领域研究或工程应用的研发人员及高年级本科生、研究生。; 使用场景及目标:①研究风光储氢多能互补系统的集成与协调控制策略;②分析储能与电解制氢负荷在平抑可再生能源波动、提升系统稳定性方面的作用;③掌握基于Simulink的多能源系统建模仿真方法,服务于科研项目、毕业设计或工程预研。; 阅读建议:建议结合Simulink软件动手复现模型,重点关注各单元模块的控制逻辑与接口设计,通过调整参数和工况进行对比仿真,深入理解系统动态特性与协调运行机理。
下载代码方式:https://pan.quark.cn/s/06ddd041bd02 STM32CubeIDE是由STMicroelectronics(意法半导体)开发的一款功能全面的集成开发平台,主要面向STM32微控制器的应用。该v1.0.2版本特别适配于Windows操作系统,并且能够适用于x86及x64架构的计算机系统。STM32CubeIDE融合了代码编写、编译执行、调试诊断以及项目管理等多项核心功能,致力于精简STM32应用的开发步骤,从而显著提升开发工作的效率。 STM32CubeIDE的主要特性具体包含: 1. **集成开发环境(IDE)**:该平台提供了一个统一的操作界面,开发者能够在此平台上进行代码的编写、编译、链接以及调试STM32应用程序。IDE的设计注重用户体验,支持包括C和C++在内的多种编程语言。 2. **代码生成器**:STM32CubeMX作为STM32CubeIDE的一个组成部分,是一个图形化的配置工具,用户可以通过它来设定微控制器的多种参数,例如时钟系统配置、外设接口选择等。完成配置后,该工具能够自动生成初始化代码,从而大幅减少手动编写基础代码的工作量。 3. **项目模板**:STM32CubeIDE提供了多种预先配置好的项目模板,这些模板覆盖了STM32系列的不同微控制器型号,从而使得新项目的启动过程更加迅速和便捷。 4. **调试工具**:IDE内建了功能强大的调试器,支持JTAG和SWD接口,且兼容多种ST-LINK/V2、ST-LINK/V3以及各类第三方调试设备。调试功能涵盖了断点设置、变量监控、内存检查、性能评估等多个方面。 5. **编译工具链**:STM32CubeIDE集成了GCC编译器以及针对ARM...

16,550

社区成员

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

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

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