系统我已经做好了,基于对话框的,现在要实现打印与预览功能,怎么做啊. 急急!!!!
看了参考书说要建立单文档,然后在修改InitInstance()函数. 可是我不知道怎么把两个工程合到一快
我已经做好的,不好移的,但我另辟了一条路,就是在建一个工程,专门用来打印和御览。用ShellExecuteEx(&ShExecInfo);打开
我的数据是独立的在数据库的。
这样也好。。
<PRE id=pre1 style='MARGIN-TOP: 0px' nd='21'>void CMyDialog::Print()
{
CDC dc;
CPrintDialog printDlg(FALSE);
if (printDlg.DoModal() == IDCANCEL) // Get printer settings from user
return;
dc.Attach(printDlg.GetPrinterDC()); // Get and attach a printer DC
dc.m_bPrinting = TRUE;
CString strTitle; // Get the application title
strTitle.LoadString(AFX_IDS_APP_TITLE);
DOCINFO di; // Initialise print document details
::ZeroMemory (&di, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = strTitle;
BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job
// Get the printing extents and store in the m_rectDraw field of a
// CPrintInfo object
CPrintInfo Info;
Info.m_rectDraw.SetRect(0,0,
dc.GetDeviceCaps(HORZRES),
dc.GetDeviceCaps(VERTRES));
OnBeginPrinting(&dc, &Info); // Call your "Init printing" function
for (UINT page = Info.GetMinPage();
page <= Info.GetMaxPage() && bPrintingOK;
page++)
{
dc.StartPage(); // begin new page
Info.m_nCurPage = page;
OnPrint(&dc, &Info); // Call your "Print page" function
bPrintingOK = (dc.EndPage() > 0); // end page
}
OnEndPrinting(&dc, &Info); // Call your "Clean up" function
if (bPrintingOK)
dc.EndDoc(); // end a print job
else
dc.AbortDoc(); // abort job.
dc.DeleteDC(); // delete the printer DC
}
</PRE>
谢谢大家了,我用对话框加单文挡,那套偷梁换柱的办法实现了,但预览时显示的是空白。
CMyApp::CMyApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMyApp object
CMyApp theApp;
HINSTANCE hInstance;
RxADO ado;
PrintStruct m_ps;
/////////////////////////////////////////////////////////////////////////////
// CMyApp initialization
BOOL CMyApp::InitInstance()
{
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
//载入动态库
hInstance =LoadLibrary("RxDLL.dll");
//载入RXDLL中的函数
MoneyToChineseCode=(_MoneyToChineseCode*)GetProcAddress(hInstance,"MoneyToChineseCode");
CTimeToCString=(_CTimeToCString*)GetProcAddress(hInstance,"CTimeToCString");
CStringTOCTime=(_CStringTOCTime*)GetProcAddress(hInstance,"CStringTOCTime");
Padl=(_Padl*)GetProcAddress(hInstance,"Padl");
CharToLetterCode=(_CharToLetterCode*)GetProcAddress(hInstance,"CharToLetterCode");
CString ConnertionString;
ConnertionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=zyl;Initial Catalog=HuMan;Data Source=去掉了";
if(ado.SetConnection(ConnertionString)==false)
{
MessageBox(NULL,"连接服务器失败,请重新配置!","系统提示",MB_OK|MB_ICONSTOP);
// ::ShellExecute(NULL, "open", "数据库设置.exe", NULL, NULL, SW_SHOWNORMAL);
return false;
}
cnn=ado.GetConnection();
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CMyView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
/*CommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
*/
CMainDlg dlg;
dlg.DoModal();
return TRUE;
}
void CMyView::OnDraw(CDC* pDC)
{
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//逻辑设备大小
LogicSize.cx=pDC->GetDeviceCaps(HORZRES);
LogicSize.cy=pDC->GetDeviceCaps(VERTRES);
//画主标题
PrintMainCaption(pDC,false);
//画副标题
PrintDeckCaption(pDC,false);
//画表头
LVCOLUMN col;
CString stext;
int wid,xpos,ypos;
xpos=30;
ypos=m_pos.cy;
pDC->Rectangle(30,ypos,LogicSize.cx-30,ypos+1);
ypos=ypos+10;
for(int i=0;i<m_ps.Grid->GetCols();i++)
{
col.mask=LVCF_TEXT;
col.pszText=stext.GetBuffer(stext.GetLength());
col.cchTextMax=255;
m_ps.Grid->GetColumn(i,&col);
wid=m_ps.Grid->GetColumnWidth(i);
pDC->TextOut(xpos,ypos,col.pszText);
xpos=xpos+wid;
}
ypos=ypos+ 20;//m_pos向下移动一个字的宽度
pDC->Rectangle(30,ypos,LogicSize.cx-30,ypos+1);
//画表格内容
ypos=ypos+10;
xpos=30;
for(int r=0;r<m_ps.Grid->GetRows();r++)
{
for(int c=0;c<m_ps.Grid->GetCols();c++)
{
stext=m_ps.Grid->GetItemText(r,c);
wid=m_ps.Grid->GetColumnWidth(c);
pDC->TextOut(xpos,ypos,stext);
xpos=xpos+wid;
}
xpos=30;
ypos=ypos+20;
m_pos.cx=30;
m_pos.cy=ypos;
}
//打印合计信息
pDC->Rectangle(30,ypos,LogicSize.cx-30,ypos+1);
PrintTotal(pDC, false);
// TODO: add draw code for native data here
}
void CMyView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
}
6楼的老师真不错哦
呵呵
你可以调用系统给你定义好的打印啊(Cprintdialog())就好了
模拟MFC的单文档框架的方法不好,无法实现MFC静态连接
因为对话框程序静态连接时不会自动将打印对话框的资源链入,导致执行时断言错误
学习
2007-09-19 13:51:44 被【maxjimmy2008】修改
1.将数据库的数据保存到一个缓冲区中。
二。利用 ondarw() / onprint() 函数 设置字体 打印格式
最新老虎机上分器,老虎机定位器,老虎机遥控器,老虎机干扰器,老虎机退币器,老虎机游戏下载,达利上分器,上分器,达利破解,出老千,斗地主游戏,斗地主刷分器,,斗地主上分器,连线机破解,轮盘机破解
本公司专门生产上分器,老虎J定位器.各种街机,奔驰宝马.赛车风云.雪豹.彩金狮王.疯狂斗地主.水果大餐.大小老虎机.斗地主.小型水果机.动物乐园.狮子彩金及部分连线机,轮盘机,等等 作弊器,让你打暴老虎J..`详加QQ270535397 电话13959878721
itriwp167 公兴搬场 公兴搬场公司 上海公兴搬场 搬家公司 公兴搬场 公兴搬场公司 上海公兴搬场 搬场 搬家 搬场公司 上海搬场公司 上海搬家公司 fastener internship inshanghai internship in china itriwp167 搬家公司 搬家公司 搬家公司 搬家公司 搬家公司 搬家公司 搬家公司 公兴搬场 公兴搬场 公兴搬场 公兴搬场 公兴搬场 公兴搬场 itriwp167 公兴搬场公司 公兴搬场公司 公兴搬场公司 公兴搬场公司 公兴搬场公司 公兴搬场公司 itriwp167 上海公兴搬场 上海公兴搬场 上海公兴搬场 上海公兴搬场 上海公兴搬场 上海公兴搬场 itriwp167 搬场 搬场 搬场 搬场 搬场 搬场 搬场 itriwp167 搬家 搬家 搬家 搬家 搬家 搬家 搬家 itriwp167 搬场公司 搬场公司 搬场公司 搬场公司 搬场公司 搬场公司 搬场公司 itriwp167 上海搬场公司 上海搬场公司 上海搬场公司 上海搬场公司 上海搬场公司 上海搬场公司 上海搬场公司 itriwp167 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 搬场 搬场 搬家 搬家 搬场公司 搬场公司 搬家公司 搬家公司 上海搬场公司 上海搬场公司 上海搬家公司 上海搬家公司 金属回收 物资回收 废品回收 废金属回收 上海废品回收 itriwp167 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 上海搬家公司 itriwp167 靓方中国 靓方中国论坛 靓方中国博客 搜索引擎优化论坛 搜索引擎优化博客 itriwp167
2008-04-21 16:04:50 被【kongjiejie】修改
回一个
老虎机破解仪器 | 游戏机台价格行情 销售区http://www.yaokongqi.net/forum-7-1.html
老虎机破解视频区-〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-63-1.
老虎机街机下载 - 〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-46-1.html
暴力破解下载 - 〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-47-1.html
免费在线电影下载-〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-58-1.html
两性小说下载-〖老虎机遥控器上分论坛〗
http://www.yaokongqi.net/forum-54-1.html
基金知识-〖老虎机遥控器上分论坛〗
http://www.yaokongqi.net/forum-65-1.html
姚明专区- 〖老虎机遥控器上分论坛〗
http://www.yaokongqi.net/forum-36-1.html
NBA图片库-〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-38-1.html
灌水 广告 新闻 八卦 -〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-56-1.html
姚明专区- 〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-36-1.html
NBA图片库-〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-38-1.html
灌水 广告 新闻 八卦 -〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-56-1.html
秘密花园-〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-40-1.html
七情六欲-〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-41-1.html
十大美女风云榜-〖老虎机遥控器上分论坛〗http://www.yaokongqi.net/forum-55-1.html
手机;15060055297
公司网址:http://www.51laohuji.cn
★〓销售 QQ:450471338〓专业生产销售老虎机破解仪器,包括:干扰器、上分器、退币器、定位器、遥控器。已破解的机器有:框体机,模拟机,玛利机、苹果机、水果机、老虎机,连线机、转盘机。我们的仪器易操作、隐匿性强,不死机,不对屏幕有干扰,返修率低。。苹果机破解器!★〓销售 QQ:450471338 电话英雄,魔掌★〓,狗药耗子,神话,大长今,★〓威威财神,棋王,超级星期天,冲击波,丑小鸭,电子基盘,东方之珠,动感地带,功夫,红绿黄,吉祥三宝,决战光明顶,康师傅,老鼠爱大米★〓,两只蝴蝶,★〓牛气冲天,
手机;15060055297
公司网址:http://www.51laohuji.cn
要是不好实现的话,可以考虑一下用底层的方法。建立一个DC作为打印输出的DC,然后调用直接调用打印的API(不是MFC Doc类里那个)打印DC就可以了。至于如何输出打印预览,也很简单,直接建立一个窗口,把原来打印DC里的东西Bitblt过去即可。
