/***************************************************************************
**
**    $Header:   D:/EPSLDV1/SRC/LOG/DIAGNO/DIAGNRES.CPP   1.5   20 Jun 1996 09:34:26   ZJRD  $
**
**    $Log:   D:/EPSLDV1/SRC/LOG/DIAGNO/DIAGNRES.CPP  $
** 
**    Rev 1.5   20 Jun 1996 09:34:26   ZJRD
** No change.
** 
**    Rev 1.4   11 Jun 1996 10:33:26   ZJRD
** EasyPack/SLD Version 1.97
** 
**    Rev 1.2   05 Jun 1996 15:01:02   ZJRD
** No change.
** 
**    Rev 1.1   29 May 1996 09:43:02   ZJRD
** EasyPack/SLD Version 1.95
** 
**    Rev 1.0   16 May 1996 09:12:44   ZJRD
** Initial revision.
** 
****************************************************************************/
// diagnres.cpp : implementation file
//
//john chow 96.3
#include "stdafx.h"
#include "diagnres.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDiagnResultBox dialog


CDiagnResultBox::CDiagnResultBox(CWnd* pParent /*=NULL*/)
	: CDialog(CDiagnResultBox::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDiagnResultBox)
	m_ShowInfo = "";
	//}}AFX_DATA_INIT
}

void CDiagnResultBox::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDiagnResultBox)
	DDX_Control(pDX, IDC_EDIT_SHOWINFO, m_controlShowInfo);
	DDX_Text(pDX, IDC_EDIT_SHOWINFO, m_ShowInfo);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDiagnResultBox, CDialog)
	//{{AFX_MSG_MAP(CDiagnResultBox)
	ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CDiagnResultBox message handlers

void CDiagnResultBox::OnButtonSave()
{
	// TODO: Add your control notification handler code here
	static char BASED_CODE szFilter[] = "Normal Files (*.dgn) |*.dgn | All Files"
	                                    " (*.*) | *.*||";
	
    CFileDialog* tmpDialog = new CFileDialog(FALSE,"dgn",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
     										 szFilter,NULL);
    tmpDialog->m_ofn.lpstrTitle = "Save Diagnostics Detail Information";
    if (tmpDialog->DoModal() == IDOK) {
        CString pFileName = tmpDialog->GetPathName();
        
        CFile saveFile;                   
        //OPEN FILE
        if( !saveFile.Open( pFileName, CFile::modeCreate ) ) {
            AfxMessageBox("Diagnostics Save File Creating Error!");
            return;	
	    }          
        saveFile.Close();           
        if( !saveFile.Open( pFileName, CFile::modeReadWrite ) ) {
            AfxMessageBox("Diagnostics Save File Openning Error!"); 
            return;	
        }    
        //save information
        saveFile.Write( m_ShowInfo.GetBuffer(m_ShowInfo.GetLength()),
                        m_ShowInfo.GetLength());
        m_ShowInfo.ReleaseBuffer();    
        saveFile.Close(); 
    }        
    delete tmpDialog;
	
}

BOOL CDiagnResultBox::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	CenterWindow();
	HFONT hFont = (HFONT)::GetStockObject(ANSI_FIXED_FONT);
	CFont font;
	m_controlShowInfo.SetFont(font.FromHandle(hFont));
	
//	UpdateData(FALSE);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}
