
/***************************************************************************
**
**    $Header:   D:/EPSLDV1/SRC/LOG/SAVECFG.CPP   1.8   20 Jun 1996 09:26:42   ZJRD  $
**
**    $Log:   D:/EPSLDV1/SRC/LOG/SAVECFG.CPP  $
** 
**    Rev 1.8   20 Jun 1996 09:26:42   ZJRD
** EasyPack/SLD Version 1.20a
** 
**    Rev 1.6   10 Jun 1996 10:21:22   ZJRD
** EasyPack/SLD Version 1.20
** 
**    Rev 1.4   29 May 1996 09:31:32   ZJRD
** No change.
** 
**    Rev 1.3   16 May 1996 09:04:48   ZJRD
** No change.
** 
**    Rev 1.2   10 May 1996 09:13:40   ZJRD
** No change.
** 
**    Rev 1.1   02 May 1996 10:24:14   ZJRD
** EasyPack/SLD Version 1.92
** 
**    Rev 1.31   18 Apr 1996 12:53:28   Shirley
** No change.
** 
**    Rev 1.30   12 Apr 1996 10:40:16   Shirley
** EasyPack/SLD Version 1.90
** 
**    Rev 1.28   15 Feb 1996 08:53:56   Shirley
** No change.
** 
**    Rev 1.27   12 Feb 1996 14:09:14   Shirley
** No change.
** 
**    Rev 1.26   06 Feb 1996 15:35:38   Shirley
** No change.
** 
**    Rev 1.25   06 Feb 1996 13:49:54   Shirley
** No change.
** 
**    Rev 1.24   01 Feb 1996 10:14:22   Shirley
** EasyPack/SLD Version 0.35b
** 
**    Rev 1.23   26 Jan 1996 09:20:18   Shirley
** No change.
** 
**    Rev 1.22   25 Jan 1996 13:20:10   Shirley
** No change.
** 
**    Rev 1.21   24 Jan 1996 10:39:02   Shirley
** EasyPack/SLD Version 0.34d
** 
**    Rev 1.20   23 Jan 1996 11:27:52   Shirley
** No change.
** 
**    Rev 1.19   18 Jan 1996 10:09:48   Shirley
** No change.
** 
**    Rev 1.18   15 Jan 1996 16:16:04   Shirley
** No change.
** 
**    Rev 1.17   04 Jan 1996 11:11:36   Shirley
** EasyPack/SLD Version 0.34
** 
**    Rev 1.16   30 Nov 1995 09:08:14   Shirley
** No change.
** 
**    Rev 1.15   28 Nov 1995 15:34:48   Shirley
** No change.
** 
**    Rev 1.14   21 Nov 1995 11:22:30   Shirley
** No change.
** 
**    Rev 1.13   13 Nov 1995 09:27:50   Shirley
** No change.
** 
**    Rev 1.12   12 Nov 1995 11:31:22   Shirley
** No change.
** 
**    Rev 1.11   08 Nov 1995 16:27:56   Shirley
** No change.
** 
**    Rev 1.10   08 Nov 1995 12:41:10   Shirley
** No change.
** 
**    Rev 1.9   02 Nov 1995 10:06:50   Shirley
** No change.
** 
**    Rev 1.8   27 Oct 1995 16:51:16   Shirley
** No change.
** 
**    Rev 1.7   27 Oct 1995 13:44:04   Shirley
** No change.
** 
**    Rev 1.6   25 Oct 1995 14:25:50   Shirley
** No change.
** 
**    Rev 1.5   18 Oct 1995 14:47:26   Shirley
** No change.
** 
**    Rev 1.4   13 Oct 1995 13:23:02   Shirley
** No change.
** 
**    Rev 1.3   29 Sep 1995 09:50:52   Shirley
** No change.
** 
**    Rev 1.2   20 Sep 1995 10:53:02   Shirley
** No change.
** 
**    Rev 1.1   15 Sep 1995 09:48:44   Shirley
** EasyPack/SLDV0.1a 
** 
**    Rev 1.0   07 Sep 1995 09:53:56   Shirley
** Initial revision.
**
****************************************************************************/

/////////////////////////////////////////////////////////////////////////////
//
//  File name:  SAVECFG.CPP
//
//  Description:The implement file for the class: CSavecfgDialog
//
//  Author:     Roger Zhang
//
//  Date:       04/14/95
//
//  Modification:
//
//      1. 04/14/95, Initial version 0.1
//
//      2. 09/08/95 0.1a
//
//          2.1 Fixed bug No.22
//              Modify function: OnInitDialog               
//
//
//  Copyright (C) 1995 Microtek International. All rights reserved.
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"

#include "uicom.h"   
#include "shlcom.h"
#include "savecfg.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
    
/////////////////////////////////////////////////////////////////////////////
static char BASED_CODE szFilter[] = 
    "Config Files(*.cfg)|*.cfg|Event Files(*.evt)|*.evt"
    "|Map Files(*.map)|*.map|Trigger Files(*.trg)|*.trg"
    "|All Files(*.*)|*.*||";    
    
/////////////////////////////////////////////////////////////////////////////
// CSavecfgDialog dialog


/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
CSavecfgDialog::CSavecfgDialog(BOOL isSave)
: CFileDialog(TRUE, ".cfg", "*.cfg", 
  OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, ::szFilter, NULL),
  m_nMap(1), m_nEvent(1), m_nTrigger(1), m_isSave(isSave)
{                  
    m_ofn.lpstrTitle = m_isSave ? "Save Configuration" 
        : "Restore Configuration";
        
    if(isSave)  m_nIDHelp = IDD_SAVE_CONFIG;
    else    m_nIDHelp = IDD_RESTORE_CONFIG;        
    //{{AFX_DATA_INIT(CSavecfgDialog)
        // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
}

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
void CSavecfgDialog::DoDataExchange(CDataExchange* pDX)
{
    CFileDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CSavecfgDialog)
        // NOTE: the ClassWizard will add DDX and DDV calls here
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSavecfgDialog, CFileDialog)
    //{{AFX_MSG_MAP(CSavecfgDialog)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CSavecfgDialog message handlers

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
BOOL CSavecfgDialog::OnInitDialog()
{
    CFileDialog::OnInitDialog();
    
    // TODO: Add extra initialization here 

    CRect rect;
    GetWindowRect(rect);
    VERIFY(SetWindowPos(NULL, 50, 40, rect.Width() + 70, rect.Height() + 20,
        /*SWP_NOMOVE|*/SWP_NOZORDER|SWP_NOREDRAW|SWP_NOACTIVATE));

    CenterWindow();

    CRect rcCancel;
    GetDlgItem(IDCANCEL)->GetWindowRect(rcCancel);
    ScreenToClient(rcCancel);

    //CPoint   pt(rect.Width() - 80, rect.Height() - 100);
    CPoint   pt(rcCancel.left + 10, rect.Height() - 100);
    CRect rect1(pt.x, pt.y, pt.x + 105, pt.y + 20);                 
    CRect rect2(pt.x - 10, pt.y - 5, pt.x + 115, pt.y + 70);                 
    
    if(m_isSave)                                                     
        m_Stc.Create("Save What", WS_CHILD|WS_VISIBLE|SS_BLACKFRAME
            |WS_GROUP, rect2, this, IDC_SAVECFG_STATIC);
    else
        m_Stc.Create("Restore What", WS_CHILD|WS_VISIBLE|SS_BLACKFRAME
            |WS_GROUP, rect2, this, IDC_SAVECFG_STATIC);
                                                             
    m_btnMap.Create("&Map Setting",WS_VISIBLE|WS_TABSTOP|WS_CHILD|WS_GROUP
        |BS_AUTOCHECKBOX, rect1, this, IDC_SAVECFG_MAP);
    m_btnMap.SetFont(GetFont(), TRUE);
    
    rect1.OffsetRect(0, 22);
    m_btnEvent.Create("&Event Setting",WS_VISIBLE|WS_CHILD|WS_TABSTOP
        |WS_GROUP|BS_AUTOCHECKBOX, rect1, this, IDC_SAVECFG_EVENT);
    m_btnEvent.SetFont(GetFont(), TRUE);  
    
    rect1.OffsetRect(0, 22);
    m_btnTrigger.Create("Tr&igger Setting",WS_VISIBLE|WS_CHILD|WS_TABSTOP
        |WS_GROUP|BS_AUTOCHECKBOX, rect1, this, IDC_SAVECFG_TRIGGER);
    m_btnTrigger.SetFont(GetFont(), TRUE);
    
    if(m_nMap)        m_btnMap.SetCheck(1);
    if(m_nEvent)      m_btnEvent.SetCheck(1);    
    if(m_nTrigger)    m_btnTrigger.SetCheck(1);
    
    return TRUE;  // return TRUE  unless you set the focus to a control
}

/////////////////////////////////////////////////////////////////////////////
//
//  Name:   
//
//  Description: 
//
//  Input:  
//
//  Output: 
//
//  Return: 
//
/////////////////////////////////////////////////////////////////////////////
void CSavecfgDialog::OnOK()
{
    // TODO: Add extra validation here
    m_nMap     = m_btnMap.GetCheck();
    m_nEvent   = m_btnEvent.GetCheck();
    m_nTrigger = m_btnTrigger.GetCheck();
    
    CFileDialog::OnOK();
}

///////////////////////////////(EOF)/////////////////////////////////////////
