// Results.cpp : implementation file
//

#include "stdafx.h"
#include "Test.h"
#include "Results.h"
#include "Graf.h"

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

/////////////////////////////////////////////////////////////////////////////
// CResults dialog


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


void CResults::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CResults)
	DDX_Control(pDX, IDC_BUTTON1, m_Graf);
	DDX_Control(pDX, IDC_LIST1, m_list1);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CResults, CDialog)
	//{{AFX_MSG_MAP(CResults)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CResults message handlers



BOOL CResults::OnInitDialog() 
{
	CDialog::OnInitDialog();
    graf=false;

	char	*col_list[7] = { "╧","лернд", "йнк-бн рпюяя", "опнбедемн", "опнжемр",
							"ясл.дкхмю","бпелъ" };
	int		col_width[7] = { 20,60, 100, 90, 70, 80, 70};

	lvcolumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
	for ( int i=0; i<7; i++ )
	{
		lvcolumn.fmt = LVCFMT_CENTER;
		lvcolumn.pszText = col_list[i];
		lvcolumn.iSubItem = i;
		lvcolumn.cx = col_width[i];

		if ( m_list1.InsertColumn(i, &lvcolumn) == -1)
			return NULL;
	}


	ListView_SetExtendedListViewStyle(m_list1, 
			LVS_EX_FULLROWSELECT | 
			LVS_EX_GRIDLINES | 	
			LVS_EX_TRACKSELECT |
			LVS_EX_HEADERDRAGDROP
			);
	lvitem.mask = LVIF_TEXT;
	
	char str[10];
	for(i=0;i<pDoc->StatNo;i++)
	{ lvitem.iItem = i; 
				
				lvitem.iSubItem = 0;
				sprintf(str,"%d",i+1);
				lvitem.pszText = str;
				m_list1.InsertItem(&lvitem);

       for(int j=1;j<7;j++)  
	   {		
		        lvitem.iSubItem = j;
				sprintf(str,"%d",pDoc->StatData[i][j-1]);
				lvitem.pszText = str;
				m_list1.SetItem(&lvitem);
	}  }
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CResults::OnButton1() 
{
	//Graw.DoModal();
	CGraf *Win=new CGraf;
	Win->DoModal();
	delete (Win);
	graf=true;
	OnOK();

}

