/***************************************************************************
**
**    $Header:   D:/EPSLDV1/SRC/LOG/DIAGNRES.CPP   1.8   20 Jun 1996 09:30:10   ZJRD  $
**
**    $Log:   D:/EPSLDV1/SRC/LOG/DIAGNRES.CPP  $
** 
**    Rev 1.8   20 Jun 1996 09:30:10   ZJRD
** EasyPack/SLD Version 1.20a
** 
**    Rev 1.6   10 Jun 1996 10:24:48   ZJRD
** EasyPack/SLD Version 1.20
** 
**    Rev 1.4   29 May 1996 09:37:22   ZJRD
** No change.
** 
**    Rev 1.3   16 May 1996 09:02:00   ZJRD
** No change.
** 
**    Rev 1.2   10 May 1996 09:16:50   ZJRD
** No change.
** 
**    Rev 1.1   02 May 1996 10:31:12   ZJRD
** EasyPack/SLD Version 1.92
** 
**    Rev 1.1   18 Apr 1996 12:56:38   Shirley
** No change.
** 
**    Rev 1.0   12 Apr 1996 10:36:02   Shirley
** Initial revision.
** 
****************************************************************************/
// diagnres.cpp : implementation file
//
//john chow 96.3
#include "stdafx.h"
//#include "ep-sld.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_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 Diagnosis Detail Information";
    if (tmpDialog->DoModal() == IDOK) {
        CString pFileName = tmpDialog->GetPathName();
        
        CFile saveFile;                   
        //OPEN FILE
        if( !saveFile.Open( pFileName, CFile::modeCreate ) ) {
            AfxMessageBox("Diagnosis Save File Creating Error!");
            return;	
	    }          
        saveFile.Close();           
        if( !saveFile.Open( pFileName, CFile::modeReadWrite ) ) {
            AfxMessageBox("Diagnosis 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();
	
//	UpdateData(FALSE);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}
