// CChooseAreas.cpp : implementation file //

#include "stdafx.h" #include "BsqView.h" #include "ChooseAreas.h" #include "MainFrm.h" #include "BsqViewView.h"

#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = FILE; #endif

///////////////////////////////////////////////////////////////////////////// // CChooseAreas dialog

CChooseAreas::CChooseAreas(CWnd* pParent /=NULL/) : CDialog(CChooseAreas::IDD, pParent) { //{{AFX_DATA_INIT(CChooseAreas) //}}AFX_DATA_INIT }

void CChooseAreas::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CChooseAreas) DDX_Control(pDX, IDC_LIST1, m_list); //}}AFX_DATA_MAP }

BEGIN_MESSAGE_MAP(CChooseAreas, CDialog) //{{AFX_MSG_MAP(CChooseAreas) ON_BN_CLICKED(IDC_CHOOSE_NEW, OnChooseNew) ON_BN_CLICKED(IDC_CHOOSE_DEL, OnChooseDel) ON_WM_CLOSE() ON_BN_CLICKED(IDC_CHOOSE_ERASE, OnChooseErase) //}}AFX_MSG_MAP END_MESSAGE_MAP()

///////////////////////////////////////////////////////////////////////////// // CChooseAreas message handlers

void CChooseAreas::OnChooseNew() { // 添加新区域 Areas++; // 区域数加1 CString str; str.Format("区域 #%d [%s] 0个点",Areas,ColorString[Areas]); // 格式化字符串 m_list.AddString(str); // 添加到列表框中 }

void CChooseAreas::OnChooseDel() { // 删除选中的区域 int nIndex; nIndex=m_list.GetCurSel(); // 获取当前选中项的索引

CString string; m_list.GetText(nIndex,string); // 获取选中项的文本内容 CString str="123456789"; CString str1=""; int n=string.FindOneOf(str); while(string.GetAt(n)!='[') {
str1+=string.GetAt(n); string.Delete(n,1); }

CMainFrame* pframe = (CMainFrame )AfxGetApp()->GetMainWnd(); // 获取主窗口指针 CMDIChildWnd pChildWnd = pframe->MDIGetActive(); // 获取当前活动的子窗口 CBsqViewView* pView = (CBsqViewView *) pChildWnd->GetActiveView(); // 获取当前活动的视图

pView->bigdlg->DelAreas=atoi(str1); // 将要删除的区域编号存储到对话框的成员变量中 pView->bigdlg->AreasBool[pView->bigdlg->DelAreas]=false; // 将要删除的区域的标记设置为false m_list.DeleteString(nIndex); // 从列表框中删除选中项 pView->bigdlg->Invalidate(); // 重绘大图 }

void CChooseAreas::OnClose() { // 关闭对话框 CMainFrame* pframe = (CMainFrame )AfxGetApp()->GetMainWnd(); // 获取主窗口指针 CMDIChildWnd pChildWnd = pframe->MDIGetActive(); // 获取当前活动的子窗口 CBsqViewView* pView = (CBsqViewView *) pChildWnd->GetActiveView(); // 获取当前活动的视图

pView->bigdlg->bChooseAreas = false; // 将选择区域模式标记设置为false pView->bigdlg->workmode= pView->bigdlg->CommonMode; // 将工作模式设置为常规模式 pView->bigdlg->Invalidate(); // 重绘大图 CDialog::OnClose(); // 关闭对话框 }

void CChooseAreas::PostNcDestroy() { // 销毁对话框 delete this; // 释放对话框内存 CDialog::PostNcDestroy(); // 调用基类函数 }

void CChooseAreas::OnChooseErase() { // 退出选择区域模式 CMainFrame* pframe = (CMainFrame )AfxGetApp()->GetMainWnd(); // 获取主窗口指针 CMDIChildWnd pChildWnd = pframe->MDIGetActive(); // 获取当前活动的子窗口 CBsqViewView* pView = (CBsqViewView *) pChildWnd->GetActiveView(); // 获取当前活动的视图

pView->bigdlg->bChooseAreas = false; // 将选择区域模式标记设置为false pView->bigdlg->Invalidate(); // 重绘大图

void CChooseAreasDoDataExchangeCDataExchange pDX	CDialogDoDataExchangepDX;	AFX_DATA_MAPCChooseAreas	DDX_ControlpDX IDC_LIST1 m_list;	AFX_DATA_MAPBEGIN_MESSAGE_MAPCChooseAreas CDialog	AFX_MSG_MAPCChoos

原文地址: https://www.cveoy.top/t/topic/fp7a 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录