VC 下 控制打印机打印,

paozi124 2008-07-31 02:01:50
大哥们,刚碰到需要在VC下进行对打印机控制及打印,小弟以前没做过关于打印机的程序,需要大家帮忙!!
VC用什么函数连接打印机,并且通过什么函数可以把要打印的数据传给打印机,然后控制打印机打印,
谢谢
...全文
45 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunyim 2008-08-01
  • 打赏
  • 举报
回复
控制打印机需要打印机的接口函数
sunyim 2008-08-01
  • 打赏
  • 举报
回复

void ***::OnPrintreport()
{
// TODO: Add your control notification handler code here
UpdateData(true);
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *)pFrame->GetActiveFrame();
CDemoDoc* pDoc= (CDemoDoc*)pChild->GetActiveDocument();

PRINTDLG pd;
pd.lStructSize = sizeof(PRINTDLG);
pd.Flags = PD_RETURNDC;
//pd.hDC = NULL;
pd.hwndOwner = NULL;
pd.hInstance = NULL;
pd.nMaxPage = 1;
pd.nMinPage = 1;
pd.nFromPage = 1;
pd.nToPage = 1;
pd.nCopies = 1;
pd.hDevMode = NULL;
pd.hDevNames = NULL;
// PrintDlg(&pd);
if(!PrintDlg(&pd)) return ;
// ASSERT(pd.hDC!=NULL);

int nHorRes = GetDeviceCaps(pd.hDC, HORZRES);
int nVerRes = GetDeviceCaps(pd.hDC, VERTRES);
TEXTMETRIC tm;
GetTextMetrics(pd.hDC, &tm);
int nCharHeight = tm.tmHeight;
int nCharWidth = tm.tmAveCharWidth;

int nXMargin = 2;
int nYMargin = 2;

DOCINFO di;
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "*****表";
di.lpszOutput = (LPTSTR) NULL;
di.lpszDatatype = (LPTSTR) NULL;
di.fwType = 0;
StartDoc(pd.hDC, &di);

StartPage(pd.hDC);
// int oriy=-100,space=-40,space1=-36;
// HFONT afont1;
HFONT afont1,afont2;
int a=SetMapMode(pd.hDC,MM_LOENGLISH);
// CString str;

HPEN pen1,pen2,pen3;
afont1=CreateFont(-35,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,GB2312_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_MODERN,"宋体");

CTime m_time;
CString strTime;
m_time = CTime::GetCurrentTime();
strTime = m_time.Format("20%y年%m月%d日");

SelectObject(pd.hDC,afont2);
TextOut(pd.hDC,620,-60,strTime,strlen(strTime));

EndPage(pd.hDC);

EndDoc(pd.hDC);
//打印结束

DeleteDC(pd.hDC);
}

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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