大家好!当我进行打印预览的进行时候,所弹出的预览窗口中“上一页”按钮始终是灰色的,当我移动到下一页以后想返回时,却无法返回。我想知道如何去控制预览窗口中的几个按钮,希望各位大侠能够鼎力相助,不胜感激!
解决方案 »
- 在对话框贴JPG图片是Win32平台运行成功,在6410上出现了如下错误
- 新人求助!Fortran 77 读文档程序,编译没有错误,运行就出错!怎么办??马上就要见导师了,还没有搞出来。。求救啊!!!谢谢了!!!!
- 如何把串口信号转换为USB信号?
- 请教如何在c++中控制输出的小数格式
- 遇到一个特别奇怪的问题,UDP极限??
- 如何从记录集中读取char[]型数据
- 那位能帮忙解决一下识别硬盘序列号的问题
- 有没有人做过布料的模拟阿
- 计算器的编写!!!!!!!!!!!!!!!!!
- 在VC中,datagrid 导入到EXCEL的过程中,为何大于20行就会出现错误,显示"行号无效"
- 程序在本地可运行,其他机子则无任何反应
- 知道注*册*表....\uninstall\..下键值后如何用程序卸栽应用程序
// MyPreviewView.h : header file
//#include "afxpriv.h"
#include "mappedbitmapbutton.h"/////////////////////////////////////////////////////////////////////////////
// CMyPreviewView viewclass CMyPreviewView : public CPreviewView
{
protected:
CMyPreviewView(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CMyPreviewView)// Attributes
public:protected: //各个按钮
CMappedBitmapButton m_print;
CMappedBitmapButton m_next;
CMappedBitmapButton m_previous;
CMappedBitmapButton m_onetwo;
CMappedBitmapButton m_zoomIn;
CMappedBitmapButton m_zoomOut; BOOL m_bOne;// Operations
public:// Overrides
virtual void OnDisplayPageNumber(UINT nPage, UINT nPagesDisplayed); // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyPreviewView)
//}}AFX_VIRTUAL// Implementation
protected:
virtual ~CMyPreviewView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif // Generated message map functions
protected:
//{{AFX_MSG(CMyPreviewView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
afx_msg void OnPreviewPrint();
afx_msg void OnUpdateNumPageChange(CCmdUI* pCmdUI);
afx_msg void OnUpdateZoomIn(CCmdUI* pCmdUI);
afx_msg void OnUpdateZoomOut(CCmdUI* pCmdUI);
DECLARE_MESSAGE_MAP()
};
#include "stdafx.h"
#include "afxpriv.h"
#include "afxres.h"
#include "MyPreviewView.h"
#include "resource.h"IMPLEMENT_DYNCREATE(CMyPreviewView, CPreviewView)#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CMyPreviewView
CMyPreviewView::CMyPreviewView()
{
}CMyPreviewView::~CMyPreviewView()
{
}void CMyPreviewView::OnDisplayPageNumber(UINT nPage, UINT nPagesDisplayed)
{
CPreviewView::OnDisplayPageNumber( nPage, nPagesDisplayed );
}void CMyPreviewView::OnPreviewPrint()
{
CPreviewView::OnPreviewPrint();
}BEGIN_MESSAGE_MAP(CMyPreviewView, CPreviewView)
//{{AFX_MSG_MAP(CMyPreviewView)
ON_WM_CREATE()
//}}AFX_MSG_MAP
ON_COMMAND(AFX_ID_PREVIEW_PRINT, OnPreviewPrint)
ON_UPDATE_COMMAND_UI(AFX_ID_PREVIEW_NUMPAGE, OnUpdateNumPageChange)
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMyPreviewView drawing/////////////////////////////////////////////////////////////////////////////
// CMyPreviewView diagnostics#ifdef _DEBUG
void CMyPreviewView::AssertValid() const
{
CPreviewView::AssertValid();
}void CMyPreviewView::Dump(CDumpContext& dc) const
{
CPreviewView::Dump(dc);
}
#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////
// CMyPreviewView message handlersvoid CMyPreviewView::OnUpdateNumPageChange(CCmdUI* pCmdUI)
{
UINT nPages = m_nZoomState == ZOOM_OUT ? m_nPages : m_nZoomOutPages; if (m_bOne) {
if (nPages == 1) {
// need to swap to show 2 pages
m_onetwo.LoadBitmap( IDB_PREV_TWO );
m_bOne = FALSE;
m_onetwo.Invalidate();
}
}
else {
if (nPages != 1) {
// need to swap to show 1 page
m_onetwo.LoadBitmap( IDB_PREV_ONE );
m_bOne = TRUE;
m_onetwo.Invalidate();
}
} // enable it only if valid to display another page and not zoomed
pCmdUI->Enable(m_nZoomState == ZOOM_OUT && m_nMaxPages != 1 &&
(m_pPreviewInfo->GetMaxPage() > 1 || m_nPages > 1));
}int CMyPreviewView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CPreviewView::OnCreate(lpCreateStruct) == -1)
return -1; m_pToolBar->EnableToolTips( TRUE ); m_bOne = FALSE; // the default is to show 2 pages, set in the dialog text m_print.AutoLoad( AFX_ID_PREVIEW_PRINT, m_pToolBar, IDB_PREV_PRINT );
m_next.AutoLoad( AFX_ID_PREVIEW_NEXT, m_pToolBar, IDB_PREV_NEXT );
m_previous.AutoLoad( AFX_ID_PREVIEW_PREV, m_pToolBar, IDB_PREV_PREVIOUS );
m_onetwo.AutoLoad( AFX_ID_PREVIEW_NUMPAGE, m_pToolBar, IDB_PREV_TWO );
m_zoomIn.AutoLoad( AFX_ID_PREVIEW_ZOOMIN, m_pToolBar, IDB_PREV_ZOOMIN );
m_zoomOut.AutoLoad( AFX_ID_PREVIEW_ZOOMOUT, m_pToolBar, IDB_PREV_ZOOMOUT );
return 0;
}
在自己的视图中加入一个函数:
void CMyView::MyPrintPreview()
{
CPrintPreviewState* pState = new CPrintPreviewState;
if (!DoPrintPreview(IDD_PREVIEW, this,
RUNTIME_CLASS(CMyPreviewView), pState))
{
// In derived classes, reverse special window handling here for
// Preview failure case
TRACE0("Error: DoPrintPreview failed.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
delete pState; // preview failed to initialize, delete State now
}
}在需要的地方调用这个MyPrintPreview()函数,就可以预览了
帖了这么多,累死我了
TO yuliangpei(踏雪无痕):你设置了打印的最大页数了吗?SetMaxPage()