// PDFCompOptionsDlg.cpp : implementation file // #include "stdafx.h" #include "PDFCompDemo.h" #include "PDFCompDemoDoc.h" #include "PDFCompOptionsDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CPDFCompOptionsDlg dialog CPDFCompOptionsDlg::CPDFCompOptionsDlg(CWnd* pParent /*=NULL*/) : CDialog(CPDFCompOptionsDlg::IDD, pParent) { //{{AFX_DATA_INIT(CPDFCompOptionsDlg) m_n1Bit = 5; m_n2Bit = 0; m_nPict = 2; m_bCheckBackground = TRUE; m_nSeg = 0; // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_nQFactor = 5; } void CPDFCompOptionsDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPDFCompOptionsDlg) DDX_Control(pDX, IDC_QFACTOR, m_QFactor); DDX_CBIndex(pDX, IDC_1BIT, m_n1Bit); DDX_CBIndex(pDX, IDC_2BIT, m_n2Bit); DDX_CBIndex(pDX, IDC_PICT, m_nPict); DDX_Check(pDX, IDC_BACKGROUND, m_bCheckBackground); DDX_CBIndex(pDX, IDC_SEGMENTATION, m_nSeg); // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPDFCompOptionsDlg, CDialog) //{{AFX_MSG_MAP(CPDFCompOptionsDlg) ON_CBN_SELCHANGE(IDC_PICT, OnSelchangePict) // NOTE: the ClassWizard will add message map macros here //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPDFCompOptionsDlg message handlers void CPDFCompOptionsDlg::OnSelchangePict() { UpdateData( ); GetDlgItem( IDC_QFACTOR )->EnableWindow( m_nPict < 6 ); GetDlgItem( IDC_BESTQUALITY )->EnableWindow( m_nPict < 6 ); GetDlgItem( IDC_BESTCOMP )->EnableWindow( m_nPict < 6 ); } void CPDFCompOptionsDlg::OnOK() { CDialog::OnOK(); } BOOL CPDFCompOptionsDlg::OnInitDialog() { CDialog::OnInitDialog(); OnSelchangePict(); m_QFactor.SetRange( 2, 255 ); m_QFactor.SetTicFreq( 25 ); m_QFactor.SetPos( m_nQFactor ); return TRUE; } BOOL CPDFCompOptionsDlg::DestroyWindow() { m_nQFactor = m_QFactor.GetPos( ); return CDialog::DestroyWindow(); } ///////////////////////////////////////////////////////////////////////////// // PDFCompDPIOptionsDlg dialog PDFCompDPIOptionsDlg::PDFCompDPIOptionsDlg(CWnd* pParent /*=NULL*/) : CDialog(PDFCompDPIOptionsDlg::IDD, pParent) { //{{AFX_DATA_INIT(PDFCompDPIOptionsDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_Resolution.cx = 0 ; m_Resolution.cy = 0 ; } void PDFCompDPIOptionsDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(PDFCompDPIOptionsDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(PDFCompDPIOptionsDlg, CDialog) //{{AFX_MSG_MAP(PDFCompDPIOptionsDlg) // NOTE: the ClassWizard will add message map macros here //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // PDFCompDPIOptionsDlg message handlers void PDFCompDPIOptionsDlg::SetDPIResolution ( CSize resolution ) { m_Resolution = resolution ; } CSize PDFCompDPIOptionsDlg::GetDPIResolution ( ) { return m_Resolution ; } void PDFCompDPIOptionsDlg::OnOK() { CString str ; int nTemp = 0 ; GetDlgItem ( IDC_EDT_HORIZONTAL )->GetWindowText ( str ) ; nTemp =_ttoi ( str.GetBuffer ( str.GetLength ( ) ) ) ; if ( ( nTemp > 1000 ) || ( nTemp < 10 ) ) { MessageBox ( _T ( "Resolution should be between (10-1000)" ), _T ( "Error" ) ) ; str.Format ( _T ( "%d" ), m_Resolution.cx ) ; GetDlgItem ( IDC_EDT_HORIZONTAL )->SetWindowText ( str ) ; GetDlgItem ( IDC_EDT_HORIZONTAL )->SetFocus ( ) ; return ; } else { m_Resolution.cx = nTemp ; } str.ReleaseBuffer ( ) ; GetDlgItem ( IDC_EDT_VERTICAL )->GetWindowText ( str ) ; nTemp = _ttoi ( str.GetBuffer ( str.GetLength ( ) ) ) ; if ( ( nTemp > 1000 ) || ( nTemp < 10 ) ) { MessageBox ( _T ( "Resolution should be between (10-1000)" ), _T ( "Error" ) ) ; str.Format ( _T ( "%d" ), m_Resolution.cy ) ; GetDlgItem ( IDC_EDT_VERTICAL )->SetWindowText ( str ) ; GetDlgItem ( IDC_EDT_VERTICAL )->SetFocus ( ) ; return ; } else { m_Resolution.cy = nTemp ; } str.ReleaseBuffer ( ) ; CDialog::OnOK(); } BOOL PDFCompDPIOptionsDlg::OnInitDialog() { CDialog::OnInitDialog(); CString str ; str.Format ( _T ( "%d" ), m_Resolution.cx ) ; GetDlgItem ( IDC_EDT_HORIZONTAL )->SetWindowText ( str ) ; str.ReleaseBuffer ( ) ; str.Format ( _T ( "%d" ), m_Resolution.cy ) ; GetDlgItem ( IDC_EDT_VERTICAL )->SetWindowText ( str ) ; str.ReleaseBuffer ( ) ; CenterWindow ( ) ; return TRUE; }