Скачиваний:
19
Добавлен:
01.05.2014
Размер:
2.97 Кб
Скачать
// DlgRect.cpp : implementation file
//
#include <string.h>

#include "stdafx.h"
#include "QTree.h"
#include "QTreeView.h"
#include "MainFrm.h"	

#include "DlgRect.h"

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

int X1,Y1,X2,Y2;
/////////////////////////////////////////////////////////////////////////////
// CDlgRect dialog


CDlgRect::CDlgRect(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgRect::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgRect)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CDlgRect::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgRect)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgRect, CDialog)
	//{{AFX_MSG_MAP(CDlgRect)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgRect message handlers

BOOL CDlgRect::OnInitDialog() 
{
	CDialog::OnInitDialog();

	//получаем указатель на объект "представление"
	CMainFrame *pMainFrame=(CMainFrame*)AfxGetApp()->GetMainWnd();
	CQTreeView *pView=(CQTreeView*)pMainFrame->GetActiveView();

	char str[10];
	//настраиваем указатель на поле редактирования X1
	CEdit *edit=(CEdit*)GetDlgItem(IDC_EDIT1);
	int len=wsprintf(str,"%i",X1);
	edit->SetWindowText(str);
	edit->SetFocus();
	edit->SetSel(0,len);
	
	//настраиваем указатель на поле редактирования Y1
	edit=(CEdit*)GetDlgItem(IDC_EDIT2);
	wsprintf(str,"%i",Y1);
	edit->SetWindowText(str);

	//настраиваем указатель на поле редактирования X2
	edit=(CEdit*)GetDlgItem(IDC_EDIT3);
	wsprintf(str,"%i",X2);
	edit->SetWindowText(str);

	//настраиваем указатель на поле редактирования Y2
	edit=(CEdit*)GetDlgItem(IDC_EDIT4);
	wsprintf(str,"%i",Y2);
	edit->SetWindowText(str);

	return FALSE;  
}

void CDlgRect::OnOK() 
{
	//получаем указатель на объект "представление"
	CMainFrame *pMainFrame=(CMainFrame*)AfxGetApp()->GetMainWnd();
	CQTreeView *pView=(CQTreeView*)pMainFrame->GetActiveView();

	char str[10];
	//настраиваем указатель на поле редактирования X1
	CEdit *edit=(CEdit*)GetDlgItem(IDC_EDIT1);
	edit->GetLine(0,str);
	X1=atoi(str);
		
	//настраиваем указатель на поле редактирования Y1
	edit=(CEdit*)GetDlgItem(IDC_EDIT2);
	edit->GetLine(0,str);
	Y1=atoi(str);

	//настраиваем указатель на поле редактирования X2
	edit=(CEdit*)GetDlgItem(IDC_EDIT3);
	edit->GetLine(0,str);
	X2=atoi(str);

	//настраиваем указатель на поле редактирования Y2
	edit=(CEdit*)GetDlgItem(IDC_EDIT4);
	edit->GetLine(0,str);
	Y2=atoi(str);

	pView->m_ChangeRange=TRUE;
	//удаляем результаты последнего поиска
	while(pView->listPointsInRect.Lenght()>0)
	{
		pView->listPointsInRect.First();
		pView->listPointsInRect.Remove();
	}

	pView->Invalidate();
		
	CDialog::OnOK();
}
Соседние файлы в папке src