www.gusucode.com > VC++遥感原理与数字摄影测量实习源码程序 > VC++遥感原理与数字摄影测量实习源码程序\code\ImageProcess\ImageDlg.cpp
// ImageDlg.cpp : implementation file // Download by http://www.NewXing.com #include "stdafx.h" #include "ImageProcess.h" #include "ImageDlg.h" #include "NDVIDlg.h" #include "ChangeDtc.h" #include "RVIDlg.h" #include "DVIDlg.h" #include "BMPDlg.h" #include "MoravecDlg.h" #include "ImgMatchDlg.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() ///////////////////////////////////////////////////////////////////////////// // CImageDlg dialog CImageDlg::CImageDlg(CWnd* pParent /*=NULL*/) : CDialog(CImageDlg::IDD, pParent) { //{{AFX_DATA_INIT(CImageDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CImageDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CImageDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CImageDlg, CDialog) //{{AFX_MSG_MAP(CImageDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_COMMAND(IDM_NDVI, OnNDVI) ON_COMMAND(IDM_CHANGE_SPEC, OnChangeSpec) ON_COMMAND(ID_ABOUT, OnAbout) ON_COMMAND(IDM_RVI, OnRVI) ON_COMMAND(IDM_DVI, OnDVI) ON_COMMAND(ID_OPEN_BMP, OnOpenBmp) ON_COMMAND(IDM_MORAVEC, OnMoravec) ON_COMMAND(IDM_IMGMATCH, OnImgmatch) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CImageDlg message handlers BOOL CImageDlg::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 SetWindowPos(&wndTop,300,150,400,50,SWP_SHOWWINDOW); char current[MAX_PATH] = {0}; GetCurrentDirectory(MAX_PATH, current); m_sModuleDirectory.Format("%s",current); return TRUE; // return TRUE unless you set the focus to a control } void CImageDlg::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 CImageDlg::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 CImageDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CImageDlg::OnAbout() { // TODO: Add your command handler code here CAboutDlg* pDlg = new CAboutDlg; pDlg->Create(IDD_ABOUTBOX); pDlg->ShowWindow(SW_SHOWNORMAL); } void CImageDlg::OnNDVI() { // TODO: Add your command handler code here if (GetFileAttributes(m_sModuleDirectory + "\\NDVI.exe") == -1) { //the module does not exist CString err; err.LoadString(IDS_NDVIMODULE_NOTEXIST); ::MessageBox(NULL, err, "Error", MB_ICONERROR); return; } CNDVIDlg* pDlg1 = new CNDVIDlg; pDlg1->Create(IDD_NDVI_DLG); pDlg1->ShowWindow(SW_SHOWNORMAL); pDlg1->SetWindowPos(&wndTop,500,220,0,0,SWP_NOSIZE); } void CImageDlg::OnRVI() { // TODO: Add your command handler code here if (GetFileAttributes(m_sModuleDirectory + "\\RVI.exe") == -1) { //the module does not exist CString err; err.LoadString(IDS_RVIMODULE_NOTEXIST); ::MessageBox(NULL, err, "Error", MB_ICONERROR); return; } CRVIDlg* pDlg2 = new CRVIDlg; pDlg2->Create(IDD_RVI_DLG); pDlg2->ShowWindow(SW_SHOWNORMAL); pDlg2->SetWindowPos(&wndTop,550,270,0,0,SWP_NOSIZE); } void CImageDlg::OnDVI() { // TODO: Add your command handler code here if (GetFileAttributes(m_sModuleDirectory + "\\DVI.exe") == -1) { //the module does not exist CString err; err.LoadString(IDS_RVIMODULE_NOTEXIST); ::MessageBox(NULL, err, "Error", MB_ICONERROR); return; } CDVIDlg* pDlg3 = new CDVIDlg; pDlg3->Create(IDD_DVI_DLG); pDlg3->ShowWindow(SW_SHOWNORMAL); pDlg3->SetWindowPos(&wndTop,600,320,0,0,SWP_NOSIZE); } void CImageDlg::OnChangeSpec() { // TODO: Add your command handler code here if (GetFileAttributes(m_sModuleDirectory + "\\ChangeDetection.exe") == -1) { //the module does not exist CString err; err.LoadString(IDS_CHANGESPECMODULE_NOTEXIST); ::MessageBox(NULL, err, "Error", MB_ICONERROR); return; } CChangeDtc* pDlg4 = new CChangeDtc; pDlg4->Create(IDD_CHANGEDTC_DLG); pDlg4->ShowWindow(SW_SHOWNORMAL); pDlg4->SetWindowPos(&wndTop,650,370,0,0,SWP_NOSIZE); } void CImageDlg::OnOpenBmp() { // TODO: Add your command handler code here CFileDialog dlg(TRUE, NULL, NULL, OFN_EXPLORER); dlg.m_ofn.lpstrTitle = "Choose the BMP image\0"; dlg.m_ofn.lpstrFilter = "BMP files\0*.bmp\0"; dlg.m_ofn.lStructSize = 88; CString FilePath; if (dlg.DoModal() == IDOK) FilePath = dlg.GetPathName(); else return; CBMPDlg* pDlg = new CBMPDlg; pDlg->Create(IDD_BMP_DLG); pDlg->ShowWindow(SW_SHOWNORMAL); pDlg->SetWindowPos(&wndTop,300,220,0,0,SWP_NOSIZE); pDlg->LoadBitmap(FilePath); } void CImageDlg::OnMoravec() { // TODO: Add your command handler code here if (GetFileAttributes(m_sModuleDirectory + "\\Moravec.exe") == -1) { //the module does not exist CString err; err.LoadString(IDS_CHANGESPECMODULE_NOTEXIST); ::MessageBox(NULL, err, "Error", MB_ICONERROR); return; } CMoravecDlg* pDlg5 = new CMoravecDlg; pDlg5->Create(IDD_MORAVEC_DLG); pDlg5->ShowWindow(SW_SHOWNORMAL); pDlg5->SetWindowPos(&wndTop,580,220,0,0,SWP_NOSIZE); } void CImageDlg::OnImgmatch() { // TODO: Add your command handler code here if (GetFileAttributes(m_sModuleDirectory + "\\ImgMatch.exe") == -1) { //the module does not exist CString err; err.LoadString(IDS_CHANGESPECMODULE_NOTEXIST); ::MessageBox(NULL, err, "Error", MB_ICONERROR); return; } CImgMatchDlg* pDlg6 = new CImgMatchDlg; pDlg6->Create(IDD_IMGMATCH_DLG); pDlg6->ShowWindow(SW_SHOWNORMAL); pDlg6->SetWindowPos(&wndTop,650,240,0,0,SWP_NOSIZE); }