[问题] C++ 如何更变打印机默认纸张大小

楼主: gary22675129 (冈)   2015-12-21 21:40:48
开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++
我试着在createDC里面丢DEVMODE来设定大小
但印出来的纸张长度还是跟默认的一样
这个试了好几天了还是没用
跪求大神帮忙解难题
程式码(Code):(请善用置底文网页, 记得排版)
#include<windows.h>
#include<Wingdi.h>
#include<Winspool.h>
#include<iostream>
using namespace std;
前头有引入https://support.microsoft.com/en-us/kb/167345的子集合
int main(){
SetDefaultPrinter("NEC Pinwriter P2200");
HANDLE gPrinter;
OpenPrinter("NEC Pinwriter P2200",&gPrinter,NULL);
DOCINFO kk={0};
kk.cbSize=sizeof(DOCINFO);
kk.lpszDocName="报表";
kk.lpszOutput="";
kk.fwType=0;
HDC gHDC=0;
gHDC = CreateDC(
NULL,
"NEC Pinwriter P2200",
NULL,
GetLandscapeDevMode((HWND)gPrinter,"NEC Pinwriter P2200")
);
StartDoc(gHDC,&kk);
StartPage(gHDC);
HFONT hFont;
hFont=CreateFont(30,0,0,0,FW_BOLD,0,0,0,0,0,0,2,0,"SYSTEM_FIXED_FONT");
SelectObject(gHDC,hFont);
TextOut(gHDC,300,63,"中文",4);
EndPage(gHDC);
EndDoc(gHDC);
system("PAUSE");
return 0;
}
作者: testPtt (测试)   2015-12-21 23:27:00
挂.net比较容易
作者: stupid0319 (征女友)   2015-12-22 00:02:00
GetLandscapeDevMode后,你没有去改DEVMODE 内容吧
楼主: gary22675129 (冈)   2015-12-22 10:25:00
Stupid大 我把step2的部分删掉双面打印 改成纸张长度&宽度唷Testptt大 请教.net是什么 小弟初学VC++ 都靠MSDN

Links booklink

Contact Us: admin [ a t ] ucptt.com