/***************************************************************************
**
**    $Header:   D:/ECB2S/SRC/LOG/DIAGNO/DIAGNRES.CPP   1.7   17 Apr 1997 16:36:08   ZJRD  $
**
**    $Log:   D:/ECB2S/SRC/LOG/DIAGNO/DIAGNRES.CPP  $
** 
**    Rev 1.7   17 Apr 1997 16:36:08   ZJRD
** No change.
** 
**    Rev 1.6   16 Apr 1997 11:13:10   ZJRD
** No change.
** 
**    Rev 1.5   10 Apr 1997 15:58:00   ZJRD
** 2.09F
** 
**    Rev 1.3   03 Apr 1997 15:35:24   ZJRD
** No change.
** 
**    Rev 1.2   27 Mar 1997 15:19:30   ZJRD
** No change.
** 
**    Rev 1.1   19 Mar 1997 11:48:20   ZJRD
** No change.
** 
**    Rev 1.0   12 Mar 1997 15:01:22   ZJRD
** Initial revision.
** 
**    Rev 1.4.1.0.1.2   09 Dec 1996 10:24:44   ZJRD
** EasyPack/SLD Version 2.0P
** 
**    Rev 1.4.1.0.1.0   11 Nov 1996 13:04:48   ZJRD
** EasyPack/SLD Version 2.01
** 
**    Rev 1.4.1.4   09 Sep 1996 13:49:06   ZJRD
** No change.
** 
**    Rev 1.4.1.3   05 Sep 1996 11:39:42   ZJRD
** No change.
** 
**    Rev 1.4.1.2   02 Sep 1996 10:04:36   ZJRD
** EasyPack/SLD Version 1.9d
** 
**    Rev 1.4.1.0   12 Aug 1996 11:06:20   ZJRD
** EasyPack/SLD Version 1.98
** 
**    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
}
