调用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表示: 无效的像素格式。
我一直搞不明白,希望各位大神能搭救搭救。
...全文
228 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/1c143f32ee83 华为作为全球领先的通信设备供应商,其产品系列广泛涉及各类网络设备,其中包括我们接下来要探讨的上网卡产品。华为上网卡驱动程序是一种专门为华为品牌旗下多种型号上网卡开发的软件模块,其主要功能在于保障这些设备与计算机操作系统的无缝对接。涉及的型号涵盖EC8189、EC226、EC169C、EC360、EC1260、EC1261、EC189、EC122、EC150以及EC168,这些均是由华为公司推出的移动宽带调制解调器,旨在通过移动网络实现便捷的互联网接入服务。驱动程序在计算机系统中的地位举足轻重,它充当了硬件设备与操作系统之间的媒介,负责对硬件设备发出的指令进行解读和执行,并将操作系统的指令传递给硬件设备。华为上网卡驱动程序的及时更新和精准安装是保障设备稳定运作和性能达到最优的关键因素。"天翼宽带安装程序V1.3.3.exe"是由中国电信提供的一个整合性软件包,内含华为上网卡的驱动程序及配套的管理工具。用户可借助此安装程序来执行华为上网卡的相关驱动安装及更新,同步享受中国电信的3G或4G网络服务。版本标识V1.3.3代表软件经过迭代优化,通常包含了对错误的修正、性能的改善以及新功能的引入。 "SetupInfo.xml"作为安装程序的配置文档,其中收录了安装流程中的各项设定和元数据信息,例如安装流程、文件定位、依赖条件等。它是安装程序在执行时参照和遵循的纲领,旨在确保安装流程按既定方案进行。文件名"CT_HW_EVDO_Driver"或许指向华为的EVDO(Evolution-Data Optimized)驱动程序,EVDO是一种3G无线通信规范,具备高速数据传输的特性。该驱动可...
内容概要:本文围绕【博士论文复现】基于小信号扫频辨识的光伏并网逆变器正负序交互稳定性分析展开,结合Matlab代码与Simulink仿真实现,系统研究了光伏并网逆变器在弱电网环境下的正负序阻抗建模与交互稳定性问题。重点采用小信号扫频法进行系统辨识,获取逆变器的正负序阻抗特性,并通过奈奎斯特稳定判据等方法分析其在不同电网强度下的稳定性表现。文中详细阐述了扫频激励信号的设计原理、频域响应数据的提取与处理流程、阻抗模型的拟合与验证方法等关键技术环节,实现了对逆变器在复杂电网条件下动态交互行为的精确刻画。该研究不仅深入揭示了新能源并网系统中潜在的宽频振荡机理,也为提升系统稳定性、优化控制器设计提供了坚实的理论依据和有效的技术手段。; 适合人群:具备电力电子、自动控制及电力系统基础知识,从事新能源并网、电力系统稳定性研究的研究生、科研人员及工程技术人员。; 使用场景及目标:① 掌握基于小信号扫频法的电力电子装置阻抗建模方法;② 深入理解光伏并网逆变器在弱电网下的正负序交互稳定性机理;③ 学习并复现高水平博士论文中的核心仿真技术,提升科研实践能力;④ 为实际工程中新能源并网系统的稳定性分析、振荡问题诊断与控制器优化设计提供理论支持和技术参考。; 阅读建议:学习者应结合提供的Matlab代码与Simulink模型,深入理解扫频辨识的原理与实现步骤,重点关注锁相环、电流控制环等关键模块对系统阻抗特性的影响,并尝试改变系统参数以观察稳定性变化,从而加深对理论知识的掌握。
代码转载自:https://pan.quark.cn/s/a4b39357ea24 OPC(OLE for Process Control)是由微软推出的一种应用于工业自动化场景下的数据交换规范,其目的是使多样化的自动化装置与软件平台之间能够实现信息互通。在本项研究中,我们集中探讨的是一个运用C#语言构建的完整OPC客户端的源代码实现。该客户端具备与OPC服务器建立连接、获取或设置数据的能力,从而促成设备间的协同工作。鉴于C#是.NET框架的核心编程语言,并且拥有丰富的类库资源及强大的面向对象支持,它特别适合用于开发此类工业环境的应用程序。接下来将针对OPC客户端源代码中可能涉及的核心技术要点进行详尽的阐述: 1. **OPC Foundation .NET库**:为了在C#环境下实现OPC通信功能,开发人员通常会选择采用OPC Foundation提供的.NET库,例如OPC-UA .NET Standard或OPC Classic .NET。这些库提供了操作OPC服务器的必要API,涵盖了建立连接、遍历服务器节点、读取与写入数据等一系列操作。 2. **OPC连接配置**:客户端在运行前必须先与OPC服务器建立通信通道。这一过程通常需要配置服务器的位置信息、身份验证凭证(包括用户名和密码)以及连接的详细参数。在源代码中,可能会包含一个`Connect()`方法来处理这些连接细节。 3. **数据项订阅机制**:OPC客户端通过向服务器订阅数据项来实时获取数据更新。在订阅阶段,客户端会指定需要监控的数据项的唯一标识,并设定当数据发生变化时触发的回调函数。在C#编程语言中,这一过程可能通过`AddSubscription()`和`AddItem()`方法来完...

16,550

社区成员

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

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

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