// ZoomPercent.cpp : implementation file // #include "stdafx.h" #include "ocrutil.h" #include "ZoomPercent.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CZoomPercent dialog CZoomPercent::CZoomPercent(L_FLOAT fZoom, CWnd* pParent /*=NULL*/) : CDialog(CZoomPercent::IDD, pParent) { //{{AFX_DATA_INIT(CZoomPercent) m_fZoomPercent = fZoom; //}}AFX_DATA_INIT } void CZoomPercent::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CZoomPercent) DDX_Control(pDX, IDOK, m_btnOK); DDX_Text(pDX, IDC_EDIT_ZOOM_PERCENT, m_fZoomPercent); DDV_MinMaxInt(pDX, (int)m_fZoomPercent, 10, 200); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CZoomPercent, CDialog) //{{AFX_MSG_MAP(CZoomPercent) ON_EN_CHANGE(IDC_EDIT_ZOOM_PERCENT, OnChangeEditZoomPercent) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CZoomPercent message handlers BOOL CZoomPercent::OnInitDialog() { CDialog::OnInitDialog(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CZoomPercent::OnOK() { CDialog::OnOK(); } void CZoomPercent::OnChangeEditZoomPercent() { CString csText; GetDlgItemText(IDC_EDIT_ZOOM_PERCENT, csText); L_BOOL bOK = (!csText.IsEmpty()); if (bOK) { L_FLOAT fZoom = 1.0f; #ifdef _UNICODE char * pszText=(char*)malloc(csText.GetLength()); if(pszText) { wcstombs(pszText, csText, csText.GetLength()); fZoom = (L_FLOAT)atof(pszText); free(pszText); } #else fZoom = (L_FLOAT)atof(csText); #endif /* _UNICODE */ bOK = (fZoom <= MAX_ZOOM_VALUE && fZoom >= MIN_ZOOM_VALUE); } m_btnOK.EnableWindow(bOK); }