// OCXWarpDlg.cpp : implementation file // #include "stdafx.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // COCWarpDlg dialog COCWarpDlg::COCWarpDlg(CWnd* pParent /*=NULL*/) : CDialog(COCWarpDlg::IDD, pParent) { //{{AFX_DATA_INIT(COCWarpDlg) //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void COCWarpDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(COCWarpDlg) DDX_Control(pDX, IDC_LEADCTRL_MASTER, m_LEADMaster); DDX_Control(pDX, IDC_LEADCTRL_SLAVE, m_LEADSlave); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(COCWarpDlg, CDialog) //{{AFX_MSG_MAP(COCWarpDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BUTTON_COMBINE, OnButtonCombine) ON_BN_CLICKED(IDC_RADIO_MASTER_VIEW_NORMAL, OnRadioMasterViewNormal) ON_BN_CLICKED(IDC_RADIO_MASTER_FIT_IMAGE, OnRadioMasterFitImage) ON_BN_CLICKED(IDC_BUTTON_ZOOMIN, OnButtonZoomin) ON_BN_CLICKED(IDC_BUTTON_ZOOM_OUT, OnButtonZoomOut) ON_BN_CLICKED(IDC_CHECK_RESAMPLE_DISPLAY, OnCheckResampleDisplay) ON_BN_CLICKED(IDC_CHECK_SHOW_OUTLINE, OnCheckShowOutline) ON_BN_CLICKED(IDC_RADIO_SLAVE_VIEW_NORMAL, OnRadioSlaveViewNormal) ON_BN_CLICKED(IDC_RADIO_SLAVE_FIT_IMAGE, OnRadioSlaveFitImage) ON_BN_CLICKED(IDC_BUTTON_LOAD_MASTER, OnButtonLoadMaster) ON_BN_CLICKED(IDC_BUTTON_LOAD_SLAVE, OnButtonLoadSlave) ON_BN_CLICKED(IDC_CHECK_BILINEAR_INTERPOLATE, OnCheckBilinearInterpolate) ON_WM_QUERYNEWPALETTE() ON_WM_PALETTECHANGED() ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() BEGIN_EVENTSINK_MAP(COCWarpDlg, CDialog) //{{AFX_EVENTSINK_MAP(CAnnotateView) ON_EVENT(COCWarpDlg, IDC_LEADCTRL_MASTER, 9 /* AnnDestroy */, OnAnnDestroyMaster, VTS_HANDLE) //}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP() void COCWarpDlg::OnAnnDestroyMaster(long hObject) { if (hObject == m_hObject) { // This object will be deleted, so create new one in the same place VARIANT xPoints; //array for the X coordinates VARIANT yPoints; //array for the Y coordinates VARIANT vValue; long nPoints; VariantInit(&xPoints); VariantInit(&yPoints); VariantInit(&vValue); nPoints = m_LEADMaster.AnnGetPointCount(m_hObject); //get the number of points xPoints = m_LEADMaster.AnnGetPointX(m_hObject); //get the X coordinates yPoints = m_LEADMaster.AnnGetPointY(m_hObject); //get the Y coordinates m_hObject = m_LEADMaster.AnnCreate(ANNOBJECT_POLYGON, TRUE, TRUE); m_LEADMaster.AnnSetPoints(m_hObject, xPoints, yPoints, 4); m_LEADMaster.AnnSetSelected(m_hObject, TRUE, FALSE); m_LEADMaster.AnnSetForeColor(m_hObject, RGB(255, 0, 0), FALSE); VariantClear(&xPoints); VariantClear(&yPoints); } } ///////////////////////////////////////////////////////////////////////////// // COCWarpDlg message handlers BOOL COCWarpDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here UNLOCKSUPPORT(m_LEADMaster); UNLOCKSUPPORT(m_LEADSlave); CButton *pCheckBox = (CButton*)GetDlgItem(IDC_CHECK_SHOW_OUTLINE); pCheckBox->SetCheck(TRUE); OnCheckShowOutline(); pCheckBox = (CButton*)GetDlgItem(IDC_CHECK_RESAMPLE_DISPLAY); pCheckBox->SetCheck(TRUE); pCheckBox = (CButton*)GetDlgItem(IDC_CHECK_BILINEAR_INTERPOLATE); pCheckBox->SetCheck(TRUE); CButton *pRadio = (CButton*)GetDlgItem(IDC_RADIO_SLAVE_FIT_IMAGE); pRadio->SetCheck(TRUE); CWnd *pWnd = NULL; m_LEADMaster.SetEnableScroll(TRUE); m_LEADSlave.SetEnableScroll(TRUE); m_LEADMaster.SetScaleMode(3); m_LEADSlave.SetScaleMode(3); // Disable the errors m_LEADMaster.SetEnableMethodErrors(FALSE); m_LEADSlave.SetEnableMethodErrors(FALSE); // Center the bitmaps in the windows m_LEADMaster.SetCenterImage(TRUE); m_LEADSlave.SetCenterImage(TRUE); m_LEADMaster.Load("Master.jpg", 0, 0, 1); SetMasterViewMode(PAINTSIZEMODE_FIT); m_LEADSlave.Load("slave.jpg", 0, 0, 1); SetSlaveViewMode(PAINTSIZEMODE_FIT); OnCheckBilinearInterpolate(); OnCheckResampleDisplay(); // Create the annotation polygon m_hObject = 0; CreateNewPolygon(); m_LEADMaster.SetAnnUserMode(ANNUSERMODE_DESIGN); if ((m_LEADMaster.GetBitmap() == 0) || (m_LEADSlave.GetBitmap() == 0)) { // Disable the combine button GetDlgItem(IDC_BUTTON_COMBINE)->EnableWindow(FALSE); } if (m_LEADMaster.GetBitmap() == 0) { GetDlgItem(IDC_RADIO_MASTER_VIEW_NORMAL)->EnableWindow(FALSE); GetDlgItem(IDC_RADIO_MASTER_FIT_IMAGE)->EnableWindow(FALSE); GetDlgItem(IDC_CHECK_RESAMPLE_DISPLAY)->EnableWindow(FALSE); GetDlgItem(IDC_CHECK_SHOW_OUTLINE)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_ZOOMIN)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_ZOOM_OUT)->EnableWindow(FALSE); } if (m_LEADSlave.GetBitmap() == 0) { GetDlgItem(IDC_RADIO_SLAVE_VIEW_NORMAL)->EnableWindow(FALSE); GetDlgItem(IDC_RADIO_SLAVE_FIT_IMAGE)->EnableWindow(FALSE); } HRESULT hr; CoInitialize(NULL); m_pRasterKrnDlg = NULL; hr = CoCreateInstance( CLSID_LEADRasterDlgKrn_D, NULL, CLSCTX_ALL, IID_ILEADRasterDlgKrn_D, (void**)&m_pRasterKrnDlg ); if (FAILED(hr)){DisplayLEADError(ERROR_INV_PARAMETER);exit(0);return FALSE;} m_pRasterKrnDlg->InitDlg(INIT_WITH_COLOR); m_pRasterKrnDlg->EnableMethodErrors = FALSE; m_pRasterFileDlg=NULL; hr = CoCreateInstance( CLSID_LEADRasterDlgFile_D, NULL, CLSCTX_ALL, IID_ILEADRasterDlgFile_D, (void**)&m_pRasterFileDlg ); if (FAILED(hr)){DisplayLEADError(ERROR_INV_PARAMETER);exit(0); return FALSE;} m_pRasterFileDlg->EnableMethodErrors = FALSE; return TRUE; // return TRUE unless you set the focus to a control } void COCWarpDlg::SetMasterViewMode(int nViewMode) { CButton *pFit = (CButton*)GetDlgItem(IDC_RADIO_MASTER_FIT_IMAGE); CButton *pNormal = (CButton*)GetDlgItem(IDC_RADIO_MASTER_VIEW_NORMAL); if (nViewMode == PAINTSIZEMODE_FIT) { pFit->SetCheck(1); pNormal->SetCheck(0); OnRadioMasterFitImage(); } else if (nViewMode == PAINTSIZEMODE_NORMAL) { pFit->SetCheck(0); pNormal->SetCheck(1); OnRadioMasterViewNormal(); } } void COCWarpDlg::CreateNewPolygon() { POINT Points[4] = { 50,50, 150,50, 150,150, 50,150 }; m_hObject = m_LEADMaster.AnnCreate(ANNOBJECT_POLYGON, TRUE, TRUE); VARIANT variantX, variantY; SAFEARRAY *ptrsafearrayX, *ptrsafearrayY; SAFEARRAYBOUND arrayboundX, arrayboundY; float *pX, *pY; /* pointer to the data */ /* Set up the VARIANT and the SAFEARRAY structures */ arrayboundX.cElements = 5; arrayboundX.lLbound = 0; arrayboundY.cElements = 5; arrayboundY.lLbound = 0; ptrsafearrayX = SafeArrayCreate( VT_R4, 1, &arrayboundX); ptrsafearrayY = SafeArrayCreate( VT_R4, 1, &arrayboundX); SafeArrayLock( ptrsafearrayX ); SafeArrayLock( ptrsafearrayY ); pX = (float*)ptrsafearrayX->pvData; /* get a pointer to the buffer */ pY = (float*)ptrsafearrayY->pvData; /* get a pointer to the buffer */ V_VT(&variantX) = VT_ARRAY | VT_R4; V_VT(&variantY) = VT_ARRAY | VT_R4; V_ARRAY(&variantX) = ptrsafearrayX; V_ARRAY(&variantY) = ptrsafearrayY; for (int i = 1; i < 5; i++) { pX[i] = (float)Points[i - 1].x; pY[i] = (float)Points[i - 1].y; } m_LEADMaster.AnnSetPoints(m_hObject, variantX, variantY, 4); m_LEADMaster.AnnSetSelected(m_hObject, TRUE, FALSE); m_LEADMaster.AnnSetForeColor(m_hObject, RGB(255, 0, 0), FALSE); m_LEADMaster.SetAnnAutoMenuEnable(FALSE); SafeArrayUnlock( ptrsafearrayX ); SafeArrayDestroy( ptrsafearrayX ); SafeArrayUnlock( ptrsafearrayY ); SafeArrayDestroy( ptrsafearrayY ); OnCheckShowOutline(); } void COCWarpDlg::SetSlaveViewMode(int nViewMode) { CButton *pFit = (CButton*)GetDlgItem(IDC_RADIO_SLAVE_FIT_IMAGE); CButton *pNormal = (CButton*)GetDlgItem(IDC_RADIO_SLAVE_VIEW_NORMAL); if (nViewMode == PAINTSIZEMODE_FIT) { pFit->SetCheck(1); pNormal->SetCheck(0); OnRadioSlaveFitImage(); } else if (nViewMode == PAINTSIZEMODE_NORMAL) { pFit->SetCheck(0); pNormal->SetCheck(1); OnRadioSlaveViewNormal(); } } void COCWarpDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void COCWarpDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR COCWarpDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void COCWarpDlg::OnButtonCombine() { int nRet; VARIANT xPoints; //array for the X coordinates VARIANT yPoints; //array for the Y coordinates VARIANT vValue; long nPoints; VariantInit(&xPoints); VariantInit(&yPoints); VariantInit(&vValue); nPoints = m_LEADMaster.AnnGetPointCount(m_hObject); //get the number of points xPoints = m_LEADMaster.AnnGetPointX(m_hObject); //get the X coordinates yPoints = m_LEADMaster.AnnGetPointY(m_hObject); //get the Y coordinates // Note that the bits per pixel of master and slave must be the same // If palettized, the palettes must be the same UINT uMasterBPP = m_LEADMaster.GetBitmapBits(); UINT uSlaveBPP = m_LEADSlave.GetBitmapBits(); if ((uMasterBPP < 24) || (uSlaveBPP < 24)) { UINT uBitsPerPixel = max(uMasterBPP, uSlaveBPP ); if (uMasterBPP != uBitsPerPixel) m_LEADMaster.ColorRes(uBitsPerPixel, CRP_FIXEDPALETTE | CRP_BYTEORDERBGR, CRD_NODITHERING, 0); if (uSlaveBPP != uBitsPerPixel) m_LEADSlave.ColorRes(uBitsPerPixel, CRP_FIXEDPALETTE | CRP_BYTEORDERBGR, CRD_NODITHERING, 0); } UINT uFlags = m_bBilinearInterpolate ? CBW_BILINEAR | CBW_RESERVED8 : CBW_RESERVED8; BeginWaitCursor(); nRet = m_LEADMaster.CombineBitmapWarp(xPoints, yPoints, 4, m_LEADSlave.GetBitmap(), 0, 0, (long)m_LEADSlave.GetBitmapWidth(), (long)m_LEADSlave.GetBitmapHeight(), (long)uFlags); EndWaitCursor(); VariantClear(&xPoints); VariantClear(&yPoints); if (nRet == ERROR_FEATURE_NOT_SUPPORTED) { MessageBox("Error--Feature not supported"); } else if (nRet != 0) { char *pszMsg = "One of the following caused the error:\n" "1. Polygon must be concave\n" "2. Polygon must lie completely on the master bitmap\n" "3. The bits per pixel of the Master and Slave must be the same\n" "4. Master or slave image not loaded\n"; MessageBox(pszMsg); } else m_LEADMaster.ForceRepaint(); } void COCWarpDlg::OnRadioMasterViewNormal() { CButton *pCheck = (CButton *)GetDlgItem(IDC_RADIO_MASTER_VIEW_NORMAL); if (pCheck->GetCheck()) m_LEADMaster.SetPaintSizeMode(PAINTSIZEMODE_NORMAL); m_LEADMaster.SetEnableScroll(TRUE); } void COCWarpDlg::OnRadioMasterFitImage() { CButton *pCheck = (CButton *)GetDlgItem(IDC_RADIO_MASTER_FIT_IMAGE); if (pCheck->GetCheck()) m_LEADMaster.SetPaintSizeMode(PAINTSIZEMODE_FIT); } void COCWarpDlg::OnButtonZoomin() { float fZoomFactor; fZoomFactor = m_LEADMaster.GetPaintZoomFactor(); if (fZoomFactor < 800) { m_LEADMaster.SetPaintSizeMode(PAINTSIZEMODE_ZOOM); m_LEADMaster.SetPaintZoomFactor((float)(fZoomFactor * 1.3)); DisableMasterRadioButtons(); } } void COCWarpDlg::DisableMasterRadioButtons() { CButton *pCheck = (CButton *)GetDlgItem(IDC_RADIO_MASTER_VIEW_NORMAL); pCheck->SetCheck(0); pCheck = (CButton *)GetDlgItem(IDC_RADIO_MASTER_FIT_IMAGE); pCheck->SetCheck(0); } void COCWarpDlg::OnButtonZoomOut() { float fZoomFactor; fZoomFactor = m_LEADMaster.GetPaintZoomFactor(); if (fZoomFactor > 20) { m_LEADMaster.SetPaintSizeMode(PAINTSIZEMODE_ZOOM); m_LEADMaster.SetPaintZoomFactor((float)(fZoomFactor / 1.3)); DisableMasterRadioButtons(); } } void COCWarpDlg::OnCheckResampleDisplay() { CButton *pCheckBox; int bResampleDisplay; pCheckBox = (CButton*)GetDlgItem(IDC_CHECK_RESAMPLE_DISPLAY); bResampleDisplay = pCheckBox->GetCheck(); if (bResampleDisplay) m_LEADMaster.SetPaintScaling(PAINTSCALING_RESAMPLE); else m_LEADMaster.SetPaintScaling(PAINTSCALING_NORMAL); } void COCWarpDlg::OnCheckShowOutline() { CButton *pCheckBox = (CButton*)GetDlgItem(IDC_CHECK_SHOW_OUTLINE); int nVisible = pCheckBox->GetCheck(); long lCont = m_LEADMaster.GetAnnContainer(); if (lCont > 0) { m_LEADMaster.AnnSetVisible(lCont, nVisible, ANNFLAG_RECURSE | ANNFLAG_NOTCONTAINER, ""); m_LEADMaster.AnnSetSelected(m_hObject, TRUE, FALSE); } } void COCWarpDlg::OnRadioSlaveViewNormal() { CButton *pCheck = (CButton *)GetDlgItem(IDC_RADIO_SLAVE_VIEW_NORMAL); if (pCheck->GetCheck()) m_LEADSlave.SetPaintSizeMode(PAINTSIZEMODE_NORMAL); m_LEADSlave.SetEnableScroll(TRUE); } void COCWarpDlg::OnRadioSlaveFitImage() { CButton *pCheck = (CButton *)GetDlgItem(IDC_RADIO_SLAVE_FIT_IMAGE); if (pCheck->GetCheck()) m_LEADSlave.SetPaintSizeMode(PAINTSIZEMODE_FIT); } void COCWarpDlg::OnButtonLoadMaster() { int nRet; CString sFileName; m_pRasterFileDlg->PutEnableMethodErrors(FALSE); m_pRasterFileDlg->PutFilter(""); m_pRasterFileDlg->PutFileDlgFlags(0); m_pRasterFileDlg->PutDialogTitle("Open Master File"); m_pRasterFileDlg->PutUIFlags( OPEN_LOADBITMAP | OPEN_SHOW_MULTIPAGE | OPEN_SHOW_PREVIEW | OPEN_USEFILESTAMP | OPEN_SHOW_FILEINFO | OPEN_SHOW_LOADOPTIONS | OPEN_SHOW_LOADCOMPRESSED | OPEN_SHOW_LOADROTATED | OPEN_SHOW_DELPAGE | OPEN_SHOW_PDFOPTIONS | OPEN_SHOW_RASTEROPTIONS | OPEN_SHOW_VECTOROPTIONS | OPEN_VIEWTOTALPAGES | OPEN_ENABLESIZING ); nRet = m_pRasterFileDlg->ShowOpenDlg((long)this->m_hWnd); if(nRet == 0 && m_pRasterFileDlg->GetDialogStatus() == DLG_OK) { sFileName = m_pRasterFileDlg->GetFileName().copy(); BeginWaitCursor(); nRet = m_LEADMaster.Load((LPCTSTR)sFileName,24,(short)m_pRasterFileDlg->GetPageNumber(),1); EndWaitCursor(); if(nRet) { GetDlgItem(IDC_BUTTON_COMBINE)->EnableWindow(FALSE); GetDlgItem(IDC_RADIO_MASTER_VIEW_NORMAL)->EnableWindow(FALSE); GetDlgItem(IDC_RADIO_MASTER_FIT_IMAGE)->EnableWindow(FALSE); GetDlgItem(IDC_CHECK_RESAMPLE_DISPLAY)->EnableWindow(FALSE); GetDlgItem(IDC_CHECK_SHOW_OUTLINE)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_ZOOMIN)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_ZOOM_OUT)->EnableWindow(FALSE); MessageBox("Error loading bitmap", "Error"); return; } else { if (m_LEADSlave.GetBitmap() != 0) GetDlgItem(IDC_BUTTON_COMBINE)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_COMBINE)->EnableWindow(FALSE); GetDlgItem(IDC_RADIO_MASTER_VIEW_NORMAL)->EnableWindow(TRUE); GetDlgItem(IDC_RADIO_MASTER_FIT_IMAGE)->EnableWindow(TRUE); GetDlgItem(IDC_CHECK_RESAMPLE_DISPLAY)->EnableWindow(TRUE); GetDlgItem(IDC_CHECK_SHOW_OUTLINE)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_ZOOMIN)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_ZOOM_OUT)->EnableWindow(TRUE); SetMasterViewMode(PAINTSIZEMODE_FIT); CreateNewPolygon(); } } else DisplayLEADError(nRet); return; } void COCWarpDlg::OnButtonLoadSlave() { int nRet; CString sFileName; m_pRasterFileDlg->PutEnableMethodErrors(FALSE); m_pRasterFileDlg->PutFilter(""); m_pRasterFileDlg->PutFileDlgFlags(0); m_pRasterFileDlg->PutDialogTitle("Open Slave File"); m_pRasterFileDlg->PutUIFlags( OPEN_LOADBITMAP | OPEN_SHOW_MULTIPAGE | OPEN_SHOW_PREVIEW | OPEN_USEFILESTAMP | OPEN_SHOW_FILEINFO | OPEN_SHOW_LOADOPTIONS | OPEN_SHOW_LOADCOMPRESSED | OPEN_SHOW_LOADROTATED | OPEN_SHOW_DELPAGE | OPEN_SHOW_PDFOPTIONS | OPEN_SHOW_RASTEROPTIONS | OPEN_SHOW_VECTOROPTIONS | OPEN_VIEWTOTALPAGES | OPEN_ENABLESIZING ); nRet = m_pRasterFileDlg->ShowOpenDlg((long)this->m_hWnd); if(nRet == 0 && m_pRasterFileDlg->GetDialogStatus() == DLG_OK) { sFileName = m_pRasterFileDlg->GetFileName().copy(); BeginWaitCursor(); nRet = m_LEADSlave.Load((LPCTSTR)sFileName,0,(short)m_pRasterFileDlg->GetPageNumber(),1); EndWaitCursor(); if(nRet) { GetDlgItem(IDC_BUTTON_COMBINE)->EnableWindow(FALSE); GetDlgItem(IDC_RADIO_SLAVE_VIEW_NORMAL)->EnableWindow(FALSE); GetDlgItem(IDC_RADIO_SLAVE_FIT_IMAGE)->EnableWindow(FALSE); MessageBox("Error loading bitmap", "Error"); return; } else { if (m_LEADMaster.GetBitmap() != 0) GetDlgItem(IDC_BUTTON_COMBINE)->EnableWindow(TRUE); else GetDlgItem(IDC_BUTTON_COMBINE)->EnableWindow(FALSE); GetDlgItem(IDC_RADIO_SLAVE_VIEW_NORMAL)->EnableWindow(TRUE); GetDlgItem(IDC_RADIO_SLAVE_FIT_IMAGE)->EnableWindow(TRUE); SetSlaveViewMode(PAINTSIZEMODE_FIT); } } else DisplayLEADError(nRet); return; } void COCWarpDlg::OnCheckBilinearInterpolate() { CButton *pCheckBox = (CButton*)GetDlgItem(IDC_CHECK_BILINEAR_INTERPOLATE); m_bBilinearInterpolate = pCheckBox->GetCheck(); } void COCWarpDlg::OnPaletteChanged(CWnd* pFocusWnd) { if (GetSafeHwnd() == pFocusWnd->GetSafeHwnd()) return; m_LEADMaster.SetAutoRepaint(FALSE); m_LEADMaster.SetPaintPalette(PAINTPALETTE_AUTO); m_LEADMaster.SetPaintDither(PAINTDITHER_DIFFUSION); m_LEADSlave.SetAutoRepaint(FALSE); m_LEADSlave.SetPaintPalette(PAINTPALETTE_AUTO); m_LEADSlave.SetPaintDither(PAINTDITHER_DIFFUSION); m_LEADMaster.SetAutoRepaint(TRUE); m_LEADSlave.SetAutoRepaint(TRUE); m_LEADMaster.ForceRepaint(); m_LEADSlave.ForceRepaint(); } BOOL COCWarpDlg::OnQueryNewPalette() { m_LEADMaster.SetPaintPalette(PAINTPALETTE_AUTO); m_LEADMaster.SetPaintDither(PAINTDITHER_DIFFUSION); m_LEADSlave.SetPaintPalette(PAINTPALETTE_AUTO); m_LEADSlave.SetPaintDither(PAINTDITHER_DIFFUSION); return TRUE; } int COCWarpDlg::DisplayLEADError(int nCode) { CString str; if(nCode) { if(nCode == ERROR_PDF_BAD_INITIALIZATION_FILES) { if( IDYES == MessageBox ( TEXT("LEADTOOLS PDF plugin is not found, do you want to download the plugin now?"), TEXT("Open File"),MB_ICONEXCLAMATION | MB_YESNO)) { ShellExecute(AfxGetMainWnd()->m_hWnd, TEXT("open"), TEXT("http://www.leadtools.com/ReleaseDownloads/v14/LEADTOOLSPDFRuntime.exe"), NULL, NULL, SW_SHOWNORMAL); } } else { str.Format("A LEADTOOLS error has occured.\nCODE = %d", nCode); MessageBox(str); } } return(nCode); } void COCWarpDlg::OnDestroy() { CDialog::OnDestroy(); m_pRasterKrnDlg->FreeDlg(); if (m_pRasterKrnDlg != NULL) m_pRasterKrnDlg->Release(); if (m_pRasterFileDlg != NULL) m_pRasterFileDlg->Release(); CoUninitialize(); }