不惜重金,请教打印高手

xhtwtpdc 2002-04-04 09:11:16
各位大虾:
我在做打印程序时遇到了一个问题,代码如下:
出现的问题是运行到标识的一步时,弹出出错对话框三个按钮的那种,终止,重试,取消
LRESULT CShenjianView::OnMyPrint(WPARAM a,LPARAM b)
{
CDC dc;
PRINTDLG pd;
LPDEVMODE lpDevMode;
CPrintDialog printDlg(FALSE);
if(AfxGetApp()->GetPrinterDeviceDefaults(&pd))
{
lpDevMode=(LPDEVMODE)pd.hDevMode;
lpDevMode->dmPaperLength=1500;
lpDevMode->dmPaperWidth=1100;
}
printDlg.m_pd.hDevMode=pd.hDevMode;
dc.Attach(printDlg.GetPrinterDC());
dc.m_bPrinting = TRUE;
CString strTitle;
strTitle="您当前打印的是生检质量";
DOCINFO di;
::ZeroMemory (&di, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = strTitle;
BOOL bPrintingOK = dc.StartDoc(&di); //运行到这一步时有问题
CPrintInfo Info;
OnBeginPrinting(&dc, &Info);
for (UINT page = Info.GetMinPage();
page <= Info.GetMaxPage() && bPrintingOK;
page++)
{
dc.StartPage();
Info.m_nCurPage = page;
int sty;
sty=Stpoint(m_pSet);
PrintBiaotou(&dc,sty);
bPrintingOK = (dc.EndPage() > 0);
}
OnEndPrinting(&dc, &Info);
if (bPrintingOK)
dc.EndDoc();
else

dc.AbortDoc();

dc.Detach();
return 1;
}
...全文
33 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
ji_hui 2002-04-10
  • 打赏
  • 举报
回复
dmPaperLength和dmPaperWidth为
3810 X 2794
huqiming 2002-04-10
  • 打赏
  • 举报
回复
MSDN的bug害死人那。

你老兄可以放松一下了。
huqiming 2002-04-10
  • 打赏
  • 举报
回复
谢谢。

有问题常联系
huqiming 2002-04-10
  • 打赏
  • 举报
回复
谢谢!!

常联系。
huqiming 2002-04-10
  • 打赏
  • 举报
回复
忘了近来了。

Thanks!
twtpdc 2002-04-06
  • 打赏
  • 举报
回复
up
twtpdc 2002-04-06
  • 打赏
  • 举报
回复
up
xhtwtpdc 2002-04-06
  • 打赏
  • 举报
回复
我想自定义纸张大小(15'X11'),可是不知
dmPaperLength和dmPaperWidth应设为多少。要不要先设置SetMapMode()?
xhtwtpdc 2002-04-04
  • 打赏
  • 举报
回复
to jiangsheng
谢谢你回我的贴子,不过我的打印程序是自定义的,不是基于视结构的,我做了
一个菜单……
现在的问题是我怎么样的自定义纸张大小。在哪里定义才有效?
xhtwtpdc 2002-04-04
  • 打赏
  • 举报
回复
to AKing
我的打印机绝对没有问题,因为我如果不自定义纸张大小,让用自定义,是可以打印的。
蒋晟 2002-04-04
  • 打赏
  • 举报
回复
HOWTO: Implement a View-Based Default Printer in Microsoft Foundation Classes

Q193103


--------------------------------------------------------------------------------
The information in this article applies to:

The Microsoft Foundation Classes (MFC), used with:
Microsoft Visual C++, 32-bit Editions, versions 5.0, 6.0

--------------------------------------------------------------------------------


SUMMARY
You may sometimes want the "default" printer for your MFC application to be other than the actual system-defined default printer. This article shows how you can:

Retrieve the system default printer.


Define your own application default printer based on the current view.


Modify the settings for this default printer.


Properly use the MFC CPrintDialog class to allow the user to override your application's default printer settings.
kingcaiyao 2002-04-04
  • 打赏
  • 举报
回复
是不是打印机的问题啊?
昵称被占用了 2002-04-04
  • 打赏
  • 举报
回复
呵呵,这个不会,不好乱发短消息。
panda_w 2002-04-04
  • 打赏
  • 举报
回复
不如你看看这个吧
http://www.vckbase.com/faq/printing/2.htm
xhtwtpdc 2002-04-04
  • 打赏
  • 举报
回复
to panda_w
定义了DEMODE后,怎样做,传给谁?谢谢你了!
xhtwtpdc 2002-04-04
  • 打赏
  • 举报
回复
to panda_w
我现在用的打印纸是那种老式的两边有孔的打印纸,应该是符合标准的吧,尺寸
是15'x11'
panda_w 2002-04-04
  • 打赏
  • 举报
回复
参考MSDN
typedef struct _devicemode {
..........
union {
struct {
short dmOrientation;
short dmPaperSize;
short dmPaperLength;
short dmPaperWidth;
};
..........
} DEVMODE;
panda_w 2002-04-04
  • 打赏
  • 举报
回复
自定义纸张也需要标准的大小,纸张以及其他的打印信息在DEVMODE结构中设置

16,472

社区成员

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

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

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