作者gary22675129 (岡)
看板C_and_CPP
標題[問題] C++ 如何更變印表機預設紙張大小
時間Mon Dec 21 21:40:48 2015
開發平台(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;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 124.218.65.102
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1450705253.A.A9D.html
→ testPtt: 掛.net比較容易 12/21 23:27
推 stupid0319: GetLandscapeDevMode後,你沒有去改DEVMODE 內容吧 12/22 00:02
→ gary22675129: Stupid大 我把step2的部分刪掉雙面列印 改成紙張長 12/22 10:25
→ gary22675129: 度&寬度唷 12/22 10:25
→ gary22675129: Testptt大 請教.net是什麼 小弟初學VC++ 都靠MSDN 12/22 10:27