/***************************************************************************
**
**    $Header:   D:/EPSLDV1/SRC/LOG/PERWIN.CPP   1.7.1.6   18 Oct 1996 09:46:32   ZJRD  $
**
**    $Log:   D:/EPSLDV1/SRC/LOG/PERWIN.CPP  $
** 
**    Rev 1.7.1.6   18 Oct 1996 09:46:32   ZJRD
** EasyPack/SLD Version 2.00
** 
**    Rev 1.7.1.4   09 Sep 1996 13:13:38   ZJRD
** No change.
** 
**    Rev 1.7.1.3   05 Sep 1996 11:25:10   ZJRD
** No change.
** 
**    Rev 1.7.1.2   02 Sep 1996 09:52:16   ZJRD
** No change.
** 
**    Rev 1.7.1.1   28 Aug 1996 15:44:44   ZJRD
** No change.
** 
**    Rev 1.7.1.0   12 Aug 1996 10:49:58   ZJRD
** EasyPack/SLD Version 1.98
** 
**    Rev 1.5   05 Jun 1996 14:52:08   ZJRD
** No change.
** 
**    Rev 1.4   29 May 1996 09:28:12   ZJRD
** No change.
** 
**    Rev 1.3   16 May 1996 09:08:34   ZJRD
** No change.
** 
**    Rev 1.2   10 May 1996 09:09:04   ZJRD
** No change.
** 
**    Rev 1.1   02 May 1996 10:25:00   ZJRD
** EasyPack/SLD Version 1.92
** 
**    Rev 1.29   18 Apr 1996 13:01:42   Shirley
** No change.
** 
**    Rev 1.28   12 Apr 1996 10:38:42   Shirley
** EasyPack/SLD Version 1.90
** 
**    Rev 1.26   15 Feb 1996 08:51:38   Shirley
** No change.
** 
**    Rev 1.25   12 Feb 1996 14:06:06   Shirley
** No change.
** 
**    Rev 1.24   06 Feb 1996 15:32:38   Shirley
** No change.
** 
**    Rev 1.23   06 Feb 1996 13:46:52   Shirley
** No change.
** 
**    Rev 1.22   01 Feb 1996 10:13:24   Shirley
** No change.
** 
**    Rev 1.21   26 Jan 1996 09:17:36   Shirley
** No change.
** 
**    Rev 1.20   25 Jan 1996 13:17:36   Shirley
** No change.
** 
**    Rev 1.19   24 Jan 1996 10:37:02   Shirley
** No change.
** 
**    Rev 1.18   23 Jan 1996 11:27:32   Shirley
** No change.
** 
**    Rev 1.17   18 Jan 1996 10:10:48   Shirley
** No change.
** 
**    Rev 1.16   15 Jan 1996 16:11:48   Shirley
** No change.
** 
**    Rev 1.15   04 Jan 1996 11:12:48   Shirley
** No change.
** 
**    Rev 1.14   30 Nov 1995 09:12:06   Shirley
** No change.
** 
**    Rev 1.13   28 Nov 1995 15:34:08   Shirley
** No change.
** 
**    Rev 1.12   21 Nov 1995 11:19:54   Shirley
** No change.
** 
**    Rev 1.11   13 Nov 1995 09:22:36   Shirley
** No change.
** 
**    Rev 1.10   12 Nov 1995 11:33:08   Shirley
** No change.
** 
**    Rev 1.9   08 Nov 1995 16:29:38   Shirley
** No change.
** 
**    Rev 1.8   08 Nov 1995 12:40:08   Shirley
** No change.
** 
**    Rev 1.7   02 Nov 1995 10:08:30   Shirley
** No change.
** 
**    Rev 1.6   27 Oct 1995 16:45:58   Shirley
** No change.
** 
**    Rev 1.5   27 Oct 1995 13:48:06   Shirley
** No change.
** 
**    Rev 1.4   25 Oct 1995 14:29:22   Shirley
** EasyPack/SLD Version 0.1f
** 
**    Rev 1.2   13 Oct 1995 13:22:38   Shirley
** No change.
** 
**    Rev 1.1   29 Sep 1995 09:53:12   Shirley
** No change.
** 
**    Rev 1.0   20 Sep 1995 10:56:24   Shirley
** Initial revision.
** 
**    
** 
** 
**
**
**
****************************************************************************/

/////////////////////////////////////////////////////////////////////////////
//
//  File name:  PERWIN.CPP
//
//  Description:The implementation file of CPerWin class for Peripheral window
//
//  Author:     Jerry Yan
//
//  Date:       09/18/95
//
//  Modification:
//
//      1. 09/18/95, Initial version 
//
//
//  Copyright (C) 1995 Microtek International. All rights reserved.
//
/////////////////////////////////////////////////////////////////////////////


// perwin.cpp : implementation file
//

#include "stdafx.h"
#include "resource.h"
//#include "xview.h"
#include "perwin.h"
#include "flttool.h"
#include "listcol.h"
#include "mylist.h"

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

BOOL gb_isPeriOn;
CMDIChildWnd* 	gp_PeriWnd; 
CMultiDocTemplate* pPeriDocTemplate;

void PeriOpenWindow(CMDIFrameWnd * /*pParentWnd*/)
{
    if (gb_isPeriOn) return;
    pPeriDocTemplate->OpenDocumentFile(NULL);
}     

void FreshPer() 
{
	if(AfxGetMainWnd()->GetDescendantWindow(IDC_LIST1))
    {   
//         int i;
 /*        for (i=0;i<ITEMRANGE;i++) 
           { 
      		  AbiGetOneReg(RegVal[i].id,&(RegVal[i].value) );
    		}   
*/    		
    	((CMyList*)(AfxGetMainWnd()->GetDescendantWindow(IDC_LIST1)))->ResetContent();
	    ((CMyList*)(AfxGetMainWnd()->GetDescendantWindow(IDC_LIST1)))->InitList();
	}
}	       


/////////////////////////////////////////////////////////////////////////////
// CPerWin

IMPLEMENT_DYNCREATE(CPerWin, CMDIChildWnd)

CPerWin::CPerWin()
{                 
    gb_isPeriOn = TRUE;
    gp_PeriWnd = this;
}

CPerWin::~CPerWin()
{                   
    gb_isPeriOn = FALSE;
    gp_PeriWnd = 0;
}


BEGIN_MESSAGE_MAP(CPerWin, CMDIChildWnd)
    //{{AFX_MSG_MAP(CPerWin)
    ON_WM_MDIACTIVATE()
    ON_WM_SETCURSOR()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CPerWin message handlers


void CPerWin::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
{
    CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
    
    // TODO: Add your message handler code here
    if(bActivate && pActivateWnd == this){
        GetMDIFrame()->SendMessage(XM_MDIACTIVE, WORD(bActivate), 
            LONG(WID_PERI));              
//    	AfxGetMainWnd()->GetDescendantWindow(IDC_LIST1)->SetFocus();
    }
    else if(!bActivate && !pActivateWnd)
        GetMDIFrame()->SendMessage(XM_MDIACTIVE, WORD(bActivate)); 
}

BOOL CPerWin::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
    // TODO: Add your message handler code here and/or call default
    
    if(message == WM_RBUTTONDOWN){
       return FALSE;
    }
    return CMDIChildWnd::OnSetCursor(pWnd, nHitTest, message);
}
