// PDFCompDemoView.cpp : implementation of the CPDFCompDemoView class // #include "stdafx.h" #include "PDFCompDemo.h" #include "PDFCompDemoDoc.h" #include "PDFCompDemoView.h" #include "PDFCompSetDlg.h" #include "PDFCompOptionsDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern L_VOID PDFCompError(HWND hwnd, L_INT nCode, L_TCHAR* pTitle, L_TCHAR* pFilename); ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoView IMPLEMENT_DYNCREATE(CPDFCompDemoView, CView) BEGIN_MESSAGE_MAP(CPDFCompDemoView, CView) //{{AFX_MSG_MAP(CPDFCompDemoView) ON_COMMAND(ID_FILE_SAVEALLADDEDFILES, OnFileSavealladdedfiles) ON_COMMAND(ID_OPTIONS_ADDIMAGE, OnOptionsAddimage) ON_COMMAND(ID_OPTIONS_ADVANCED, OnOptionsAdvanced) ON_COMMAND(ID_OPTIONS_MODIFY, OnOptionsModify) ON_UPDATE_COMMAND_UI(ID_OPTIONS_MODIFY, OnUpdateOptionsModify) ON_COMMAND(ID_OPTIONS_DELETE, OnOptionsDelete) ON_UPDATE_COMMAND_UI(ID_OPTIONS_DELETE, OnUpdateOptionsDelete) ON_WM_LBUTTONDBLCLK() ON_WM_PAINT() ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) ON_WM_VSCROLL() ON_WM_HSCROLL() ON_WM_KEYDOWN() ON_WM_KEYUP() ON_UPDATE_COMMAND_UI(ID_OPTIONS_ADDIMAGE, OnUpdateOptionsAddimage) //}}AFX_MSG_MAP // Standard printing commands ON_MESSAGE(WM_HANDLEPALETTE,OnHandlePalette) ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoView construction/destruction CPDFCompDemoView::CPDFCompDemoView() { } CPDFCompDemoView::~CPDFCompDemoView() { CPDFCompDemoDoc* pDoc = GetDocument(); CPDFCompDemoApp* pApp = (CPDFCompDemoApp *)AfxGetApp(); if (pDoc->m_PDFCompSettings.bAdded == TRUE) { pDoc->m_PDFCompSettings.bAdded = FALSE; pApp->SetPageOrder(pDoc->m_PDFCompSettings.nPageNumber, FALSE, TRUE, -1); } } BOOL CPDFCompDemoView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoView drawing UserBitmapWindow::UserBitmapWindow() { ZeroMemory(&m_rcKeyRect, sizeof(m_rcKeyRect)); } L_VOID UserBitmapWindow::OnDraw(HDC hdc,RECT& Rect) { LBitmap KeyBitmap; HDC keyDC; CString pszStatus, pszIndex; COLORREF rgbFill; HPEN hOldPen; RECT rcDest ; LOGFONT LogFont; L_INT nRet ; static L_BOOL bRet ; BLENDFUNCTION BlendFunc; HPALETTE hPalette, hSlavePalette=NULL; POSITION pos ; HFONT hOldFont; if( GetWidth() <=100 || GetHeight() <=100 ) return; pos = pDoc->GetFirstViewPosition(); CPDFCompDemoView* pView= (CPDFCompDemoView* )pDoc->GetNextView(pos); hPalette = pView->m_LBitmapWnd.CreatePaintPalette(hdc); hSlavePalette = SelectPalette( hdc, hPalette, TRUE); RealizePalette(hdc); SelectPalette( hdc, hSlavePalette, TRUE); SetBkMode( hdc, TRANSPARENT); memset( &LogFont, 0, sizeof( LogFont ) ); LogFont.lfHeight = 18; LogFont.lfWeight = FW_BOLD; lstrcpy( LogFont.lfFaceName, TEXT("Arial") ); hOldFont = SelectFont( hdc, CreateFontIndirect( &LogFont )); if(pDoc->m_PDFCompSettings.bAdded) { pszStatus = TEXT(" Status : ADDED\n"); pszIndex.Format(TEXT(" Page Index : %d\n"),pDoc->m_PDFCompSettings.nPageNumber); pszStatus += pszIndex; if(!pDoc->m_PDFCompSettings.m_bNOMRC) { pszStatus += TEXT(" Input Quality: "); switch(pDoc->m_PDFCompSettings.nPDFComboSel) { case 0: pszStatus += TEXT("Auto"); break; case 1: pszStatus += TEXT("Noisy"); break; case 2: pszStatus += TEXT("Scanned"); break; case 3: pszStatus += TEXT("Printed"); break; case 4: pszStatus += TEXT("Computer Generated"); break; case 5: pszStatus += TEXT("Photo"); break; case 6: pszStatus += TEXT("User Defined"); break; } pszStatus += TEXT("\n Output Quality : "); switch(pDoc->m_PDFCompSettings.nImgQComboSel) { case 0: pszStatus += TEXT("Auto"); break; case 1: pszStatus += TEXT("Poor"); break; case 2: pszStatus += TEXT("Average"); break; case 3: pszStatus += TEXT("Good"); break; case 4: pszStatus += TEXT("Excellent"); break; case 5: pszStatus += TEXT("User Defined"); break; } } } else pszStatus = TEXT(" Status : NOT ADDED"); pView->m_LBitmapWnd.GetRects(NULL, NULL, &rcDest, NULL) ; pView->m_LBitmapWnd.m_rcKeyRect.top = rcDest.top; pView->m_LBitmapWnd.m_rcKeyRect.left = rcDest.left; pView->m_LBitmapWnd.m_rcKeyRect.right = rcDest.right; DrawText( hdc, pszStatus, lstrlen(pszStatus), &pView->m_LBitmapWnd.m_rcKeyRect, DT_LEFT | DT_WORDBREAK | DT_CALCRECT ); KeyBitmap.Create( pView->m_LBitmapWnd.m_rcKeyRect.right, pView->m_LBitmapWnd.m_rcKeyRect.bottom, 24, ORDER_BGR, NULL,TOP_LEFT,TYPE_CONV, NULL, 0) ; if( pDoc->m_PDFCompSettings.bAdded ) rgbFill = RGB(0,255,0); else rgbFill = RGB(255,0,0); nRet = KeyBitmap.Fill( rgbFill); keyDC = KeyBitmap.CreateLeadDC(); DeleteBrush(SelectBrush( keyDC, GetStockBrush( NULL_BRUSH ) )); hOldPen = SelectPen( keyDC, CreatePen( PS_SOLID, 1, 0 ) ); nRet = Rectangle( keyDC, pView->m_LBitmapWnd.m_rcKeyRect.top, pView->m_LBitmapWnd.m_rcKeyRect.left, pView->m_LBitmapWnd.m_rcKeyRect.right, pView->m_LBitmapWnd.m_rcKeyRect.bottom); DeletePen( SelectPen( keyDC, hOldPen ) ); BlendFunc.AlphaFormat = 0; BlendFunc.SourceConstantAlpha = 120; BlendFunc.BlendFlags = 0; BlendFunc.BlendOp = 0; /* AC_SRC_OVER */ bRet = ::AlphaBlend(hdc, 0, 0, pView->m_LBitmapWnd.m_rcKeyRect.right, pView->m_LBitmapWnd.m_rcKeyRect.bottom, keyDC, 0, 0, pView->m_LBitmapWnd.m_rcKeyRect.right, pView->m_LBitmapWnd.m_rcKeyRect.bottom, BlendFunc); DrawText( hdc, pszStatus, lstrlen(pszStatus), &pView->m_LBitmapWnd.m_rcKeyRect, DT_LEFT | DT_WORDBREAK ); DeleteFont(SelectFont( hdc, hOldFont)); pView->m_StatusRect.CopyRect(&pView->m_LBitmapWnd.m_rcKeyRect); KeyBitmap.DeleteLeadDC(keyDC); if(KeyBitmap.IsAllocated()) KeyBitmap.Free(); } void CPDFCompDemoView::OnDraw(CDC* pDC) { CPDFCompDemoDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here } void CPDFCompDemoView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) { // TODO: Add your specialized code here and/or call the base class if(bActivate==TRUE&&pActivateView==this) { m_LBitmapWnd.HandlePalette(WM_QUERYNEWPALETTE,0,0); ::SetFocus(m_LBitmapWnd.GetBitmapWnd()); } } void CPDFCompDemoView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: Add your message handler code here and/or call default InvalidateRect(&m_LBitmapWnd.m_rcKeyRect); CView::OnVScroll(nSBCode, nPos, pScrollBar); } void CPDFCompDemoView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: Add your message handler code here and/or call default InvalidateRect(&m_LBitmapWnd.m_rcKeyRect); CView::OnHScroll(nSBCode, nPos, pScrollBar); } void CPDFCompDemoView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default InvalidateRect(&m_LBitmapWnd.m_rcKeyRect); CView::OnKeyDown(nChar, nRepCnt, nFlags); } void CPDFCompDemoView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default InvalidateRect(&m_LBitmapWnd.m_rcKeyRect); CView::OnKeyUp(nChar, nRepCnt, nFlags); } ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoView printing BOOL CPDFCompDemoView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CPDFCompDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CPDFCompDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoView diagnostics #ifdef _DEBUG void CPDFCompDemoView::AssertValid() const { CView::AssertValid(); } void CPDFCompDemoView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CPDFCompDemoDoc* CPDFCompDemoView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPDFCompDemoDoc))); return (CPDFCompDemoDoc* )m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CPDFCompDemoView message handlers void CPDFCompDemoView::OnInitialUpdate() { CView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class m_LBitmapWnd.SetHandle(GetDocument()->m_LeadBitmap.GetHandle()) ; m_LBitmapWnd.SetWndHandle(GetSafeHwnd()); m_LBitmapWnd.EnableCenterOnZoom(FALSE); m_LBitmapWnd.pDoc = GetDocument(); m_LBitmapWnd.Region()->Free(); m_LBitmapWnd.CancelRgn(); } BOOL CPDFCompDemoView::DestroyWindow() { // TODO: Add your specialized code here and/or call the base class if (m_LBitmapWnd.IsAllocated()) m_LBitmapWnd.Free(); return CView::DestroyWindow(); } void CPDFCompDemoView::OnFileSavealladdedfiles() { CMDIFrameWnd* pFrame = (CMDIFrameWnd* )AfxGetApp()->m_pMainWnd; CMDIChildWnd* pChild = (CMDIChildWnd* )pFrame->GetActiveFrame(); static OPENFILENAME OpenFileName; L_TCHAR szFileName[_MAX_PATH]=_T(""); pPDFCOMPSETTENGS pPDFSettings=NULL; L_INT nRet=SUCCESS; L_INT i=0; L_TCHAR szSaveFileFilter[] = {TEXT("Acrobat (*.pdf)\0") TEXT("*.pdf\0")}; L_TCHAR* pFileName=NULL; CPDFCompDemoView* pView; CPDFCompDemoDoc* pDoc ; do { if (pChild) { pView= (CPDFCompDemoView* )pChild->GetActiveView(); pDoc = (CPDFCompDemoDoc* )pChild->GetActiveDocument(); if(pDoc->m_PDFCompSettings.bAdded) { pPDFSettings = (pPDFCOMPSETTENGS) realloc(pPDFSettings,sizeof(PDFCOMPSETTENGS)*(i+1)); memcpy(&pPDFSettings[i], &pDoc->m_PDFCompSettings, sizeof(PDFCOMPSETTENGS)) ; pPDFSettings[i].pBitmap = &pView->m_LBitmapWnd; i++; } } pChild = (CMDIChildWnd* ) pChild->GetWindow(GW_HWNDNEXT); } while (pChild); if(0 == i) { MessageBox(TEXT("No image is added"), TEXT("PDFComp Demo"), MB_ICONEXCLAMATION); } else { ZeroMemory( &OpenFileName, sizeof( OPENFILENAME ) ); OpenFileName.lStructSize = sizeof( OPENFILENAME ); OpenFileName.hwndOwner = m_hWnd; OpenFileName.hInstance = NULL; OpenFileName.lpstrFilter = szSaveFileFilter; OpenFileName.lpstrCustomFilter = NULL; OpenFileName.nMaxCustFilter = 0; OpenFileName.lpstrFile = szFileName; OpenFileName.nFilterIndex = 1; OpenFileName.nMaxFile = sizeof( szFileName )/sizeof(L_TCHAR); OpenFileName.lpstrFileTitle = szFileName; OpenFileName.nMaxFileTitle = sizeof( szFileName )/sizeof(L_TCHAR); OpenFileName.lpstrInitialDir = NULL; OpenFileName.lpstrTitle = TEXT("Save to PDF"); OpenFileName.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; OpenFileName.nFileOffset = 0; OpenFileName.nFileExtension = 0; OpenFileName.lpstrDefExt = TEXT(""); OpenFileName.lCustData = 0L; OpenFileName.lpfnHook = NULL; OpenFileName.lpTemplateName = NULL; if(!GetSaveFileName( &OpenFileName )) return; //Sort documents depending on page number ApplySort(pPDFSettings, i); //Save to MRC nRet = ApplyPDFSave (OpenFileName.lpstrFile, pPDFSettings, i ); if(pPDFSettings) free(pPDFSettings); if(SUCCESS != nRet) MessageBox(TEXT("PDF Save Error"), TEXT("PDFComp Demo"), MB_ICONEXCLAMATION); } } L_VOID CPDFCompDemoView::ApplySort( pPDFCOMPSETTENGS pPDFSettings, L_INT nSize ) { PDFCOMPSETTENGS HoldPDFSettings; L_INT x, y; for(x = 0; x < nSize; x++) { for(y = 0; y < nSize-1; y++) { if(pPDFSettings[y].nPageNumber > pPDFSettings[y+1].nPageNumber) { HoldPDFSettings = pPDFSettings[y+1]; pPDFSettings[y+1] = pPDFSettings[y]; pPDFSettings[y] = HoldPDFSettings; } } } } L_INT CPDFCompDemoView::ApplyPDFSave( L_TCHAR* pFileName, pPDFCOMPSETTENGS pPDFSettings, L_INT nSize) { L_INT i = 0; L_INT nRet=FAILURE; PDFCOMPOPTIONS PDFOptions; LPDFCompressor pdf; PDFCOMPRESSION pdfComp; BeginWaitCursor(); nRet = pdf.Init(); if(nRet != SUCCESS) return nRet; for(i=0; i< nSize; i++ ) { pdfComp.uStructSize = sizeof(PDFCOMPRESSION); pdfComp.dwFlags = PDFCOMP_1BITCOMPTYPE_ENABLED | PDFCOMP_2BITCOMPTYPE_ENABLED | PDFCOMP_PICTURECOMPTYPE_ENABLED; pdfComp.comp1Bit = (PDFCOMP_1BITCOMPTYPE)pPDFSettings[i].m_n1Bit; pdfComp.comp2Bit = (PDFCOMP_2BITCOMPTYPE)pPDFSettings[i].m_n2Bit; pdfComp.compPicture = (PDFCOMP_PICTURECOMPTYPE)pPDFSettings[i].m_nPict; pdfComp.nQFactor = pPDFSettings[i].m_nQFactor; nRet = pdf.SetCompression( &pdfComp ); if(SUCCESS != nRet) return nRet; if(pPDFSettings[i].m_bNOMRC ) { nRet = pdf.InsertNormal(pPDFSettings[i].pBitmap); if(SUCCESS != nRet) return nRet; } else { ZeroMemory( &PDFOptions, sizeof(PDFCOMPOPTIONS)); PDFOptions.uStructSize = sizeof(PDFCOMPOPTIONS); PDFOptions.imageQuality = PDFCOMP_IMAGEQUALITY_USER; PDFOptions.outputQuality = PDFCOMP_OUTPUTQUALITY_USER; PDFOptions.uBackGroundThreshold = pPDFSettings[i].nBKThreshold; PDFOptions.uCleanSize = pPDFSettings[i].nCleanSize; PDFOptions.uColorThreshold = pPDFSettings[i].nCLRThreshold; PDFOptions.uCombineThreshold = pPDFSettings[i].nCombThreshold; PDFOptions.uSegmentQuality = pPDFSettings[i].nSegQuality; PDFOptions.dwFlags = pPDFSettings[i].m_nSeg; if( FALSE == pPDFSettings[i].m_bCheckBackground ) PDFOptions.dwFlags |= PDFCOMP_WITHOUT_BACKGROUND; nRet = pdf.InsertMRC( pPDFSettings[i].pBitmap, &PDFOptions); if(SUCCESS != nRet) return nRet; } } nRet = pdf.Write( pFileName); if(nRet != SUCCESS) return nRet; EndWaitCursor(); pdf.Free(); return nRet; } void CPDFCompDemoView::OnOptionsAddimage() { CPDFCompDemoDoc* pDoc = GetDocument(); CPDFCompSetDlg SettingDlg; if(pDoc->m_PDFCompSettings.bAdded) { SettingDlg.m_nBKThreshold = pDoc->m_PDFCompSettings.nBKThreshold ; SettingDlg.m_nCleanSize = pDoc->m_PDFCompSettings.nCleanSize; SettingDlg.m_nCLRThreshold = pDoc->m_PDFCompSettings.nCLRThreshold; SettingDlg.m_nCombThreshold = pDoc->m_PDFCompSettings.nCombThreshold; SettingDlg.m_nSegQuality = pDoc->m_PDFCompSettings.nSegQuality ; SettingDlg.m_bAdded = pDoc->m_PDFCompSettings.bAdded; SettingDlg.m_nPDFComboSel = pDoc->m_PDFCompSettings.nPDFComboSel; SettingDlg.m_nImgQComboSel = pDoc->m_PDFCompSettings.nImgQComboSel; SettingDlg.m_nPageOrder = pDoc->m_PDFCompSettings.nPageNumber; SettingDlg.m_bNOMRC = pDoc->m_PDFCompSettings.m_bNOMRC; } else { SettingDlg.m_bAdded = 0; } SettingDlg.DoModal(); if(SettingDlg.m_bAdded) { pDoc->m_PDFCompSettings.nBKThreshold = SettingDlg.m_nBKThreshold; pDoc->m_PDFCompSettings.nCleanSize = SettingDlg.m_nCleanSize; pDoc->m_PDFCompSettings.nCLRThreshold = SettingDlg.m_nCLRThreshold; pDoc->m_PDFCompSettings.nCombThreshold = SettingDlg.m_nCombThreshold; pDoc->m_PDFCompSettings.nSegQuality = SettingDlg.m_nSegQuality; pDoc->m_PDFCompSettings.bAdded = SettingDlg.m_bAdded; pDoc->m_PDFCompSettings.nPDFComboSel = SettingDlg.m_nPDFComboSel; pDoc->m_PDFCompSettings.nImgQComboSel = SettingDlg.m_nImgQComboSel; pDoc->m_PDFCompSettings.nPageNumber = SettingDlg.m_nPageOrder; pDoc->m_PDFCompSettings.m_bNOMRC = SettingDlg.m_bNOMRC; } else { pDoc->m_PDFCompSettings.bAdded = FALSE; } Invalidate(); } void CPDFCompDemoView::OnOptionsAdvanced() { CPDFCompDemoDoc* pDoc = GetDocument(); CPDFCompOptionsDlg OptionsDlg; OptionsDlg.m_n1Bit = pDoc->m_PDFCompSettings.m_n1Bit; OptionsDlg.m_n2Bit = pDoc->m_PDFCompSettings.m_n2Bit; OptionsDlg.m_nPict = pDoc->m_PDFCompSettings.m_nPict; OptionsDlg.m_nSeg = pDoc->m_PDFCompSettings.m_nSeg; OptionsDlg.m_nQFactor = pDoc->m_PDFCompSettings.m_nQFactor; OptionsDlg.m_bCheckBackground = pDoc->m_PDFCompSettings.m_bCheckBackground; if( IDOK == OptionsDlg.DoModal() ) { pDoc->m_PDFCompSettings.m_n1Bit = OptionsDlg.m_n1Bit; pDoc->m_PDFCompSettings.m_n2Bit = OptionsDlg.m_n2Bit; pDoc->m_PDFCompSettings.m_nPict = OptionsDlg.m_nPict; pDoc->m_PDFCompSettings.m_bCheckBackground = OptionsDlg.m_bCheckBackground; pDoc->m_PDFCompSettings.m_nSeg = OptionsDlg.m_nSeg; pDoc->m_PDFCompSettings.m_nQFactor = OptionsDlg.m_nQFactor; } } void CPDFCompDemoView::OnOptionsModify() { OnOptionsAddimage(); } void CPDFCompDemoView::OnUpdateOptionsModify(CCmdUI* pCmdUI) { CPDFCompDemoDoc* pDoc = GetDocument(); if(pDoc->m_PDFCompSettings.bAdded) pCmdUI->Enable(TRUE); else pCmdUI->Enable(FALSE); } void CPDFCompDemoView::OnOptionsDelete() { CPDFCompDemoDoc* pDoc = GetDocument(); CPDFCompDemoApp* pApp = (CPDFCompDemoApp* )AfxGetApp(); pDoc->m_PDFCompSettings.bAdded = FALSE; pApp->SetPageOrder(pDoc->m_PDFCompSettings.nPageNumber, FALSE, TRUE, -1); Invalidate(); } void CPDFCompDemoView::OnUpdateOptionsDelete(CCmdUI* pCmdUI) { CPDFCompDemoDoc* pDoc = GetDocument(); if(pDoc->m_PDFCompSettings.bAdded) pCmdUI->Enable(TRUE); else pCmdUI->Enable(FALSE); } void CPDFCompDemoView::OnLButtonDblClk(UINT nFlags, CPoint point) { if(m_StatusRect.PtInRect(point)) OnOptionsAddimage(); CView::OnLButtonDblClk(nFlags, point); } void CPDFCompDemoView::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here // Do not call CView::OnPaint() for painting messages } void CPDFCompDemoView::OnFilePrintPreview() { L_INT nRet; LDialogFile DlgFile; PRINTPREVIEWDLGPARAMS PrintPreviewParams; CPDFCompDemoDoc* pDoc = GetDocument(); ZeroMemory(&PrintPreviewParams,sizeof(PrintPreviewParams)); PrintPreviewParams.uStructSize = sizeof (PrintPreviewParams) ; PrintPreviewParams.pBitmap = m_LBitmapWnd.GetHandle(); PrintPreviewParams.nCmdShow = SW_SHOW ; DlgFile.SetBitmap (&m_LBitmapWnd); nRet = LDialogFile::Initialize (0); nRet = DlgFile.SetPrintPreviewParams(&PrintPreviewParams); nRet = DlgFile.DoModalPrintPreview( AfxGetApp()->m_pMainWnd->m_hWnd) ; if(nRet < SUCCESS ) PDFCompError (AfxGetApp()->m_pMainWnd->m_hWnd, nRet, TEXT("Print Preview"), TEXT("")); if ( NULL != PrintPreviewParams.hDevMode ) GlobalFree ( PrintPreviewParams.hDevMode ) ; if ( NULL != PrintPreviewParams.hDevNames ) GlobalFree ( PrintPreviewParams.hDevNames ) ; } LRESULT CPDFCompDemoView::OnHandlePalette(WPARAM wParam,LPARAM lParam) { if(lParam==TRUE) { m_LBitmapWnd.HandlePalette(WM_PALETTECHANGED,wParam,0); m_LBitmapWnd.Repaint(); } else { if(m_LBitmapWnd.HandlePalette(WM_QUERYNEWPALETTE,0,0)==FALSE) m_LBitmapWnd.Repaint(); } return TRUE; } void CPDFCompDemoView::OnUpdateOptionsAddimage(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here CPDFCompDemoDoc* pDoc = GetDocument(); if(pDoc->m_PDFCompSettings.bAdded) pCmdUI->Enable(FALSE); else pCmdUI->Enable(TRUE); }