// RFIDTestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "RFIDTest.h"
#include "RFIDTestDlg.h"
#include "../../../SDK/Include/DT_rfid_export.h"
#pragma comment(lib,"../../../SDK/lib/DT_rfid.lib")
int m_handle = 0;
int m_bconncet = 0;
int mBlocknum = 28,mBlocksize = 4;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
TCHAR UIDData[80] = _T(""),BLOCKData[1024] = _T(""),TempBLOCKData[1024] = _T("");
HANDLE g_hThread;
BOOL IsDisplayfnExit = false;
int startflag = 0;
void CRFIDTestDlg::Displayfn()
{
	memset(BLOCKData,'\0',sizeof(BLOCKData));
	memset(TempBLOCKData,'\0',sizeof(TempBLOCKData));
	while(!IsDisplayfnExit)
	{
		if((wcscmp(TempBLOCKData,BLOCKData) != 0))
		{
			SetDlgItemText(IDC_EDIT6,BLOCKData);
			wcscpy(TempBLOCKData,BLOCKData);
		}
		Sleep(100);
	}	
}
int   PosiInt(TCHAR*   Tstr) 
{ 

	char str[10] = "";
	char *p=str;
	if(Tstr[0] == 0)
		return 0;
	DWORD dwNum = WideCharToMultiByte(CP_OEMCP,NULL,Tstr,-1,NULL,0,NULL,FALSE);
	WideCharToMultiByte(CP_OEMCP,NULL,Tstr,-1,(LPSTR)str,dwNum,NULL,FALSE);
	
	int i=0; 
	while(i<(dwNum-1))
	{
		if((*p <=57)&&(*p>=48))
		{
		}
		else 
		{
			return 0; 
		}
		p++;
		i++; 
	} 
	
	return 1; 
}
void ReceiveBlockData(const TCHAR* pszUidArray, unsigned int nCount)
{
	memset(BLOCKData,'\0',sizeof(BLOCKData));
	wcscpy(BLOCKData,pszUidArray);
//	CRFIDTestDlg p;
//	p.Displayfn(pszUidArray);
	//memset(pszUidArray,'\0',strlen(pszUidArray));
}/*
void ReceiveUidData(const TCHAR* pszUidArray, unsigned int nCount)
{
	wcscpy(UIDData,pszUidArray);
	//memset(pszUidArray,'\0',strlen(pszUidArray));
}*/
// CRFIDTestDlg dialog

CRFIDTestDlg::CRFIDTestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CRFIDTestDlg::IDD, pParent)
	//, m_val(0)
	//, m_Block(0)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CRFIDTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//DDX_Text(pDX, IDC_EDIT3, m_val);
	//DDX_Text(pDX, IDC_EDIT7, m_Block);
}

BEGIN_MESSAGE_MAP(CRFIDTestDlg, CDialog)
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
	ON_WM_SIZE()
#endif
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BUTTON1, &CRFIDTestDlg::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON3, &CRFIDTestDlg::OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON2, &CRFIDTestDlg::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON4, &CRFIDTestDlg::OnBnClickedButton4)
	ON_BN_CLICKED(IDC_BUTTON5, &CRFIDTestDlg::OnBnClickedButton5)
	ON_BN_CLICKED(IDC_BUTTON6, &CRFIDTestDlg::OnBnClickedButton6)
	ON_BN_CLICKED(IDC_BUTTON7, &CRFIDTestDlg::OnBnClickedButton7)
	ON_BN_CLICKED(IDC_BUTTON8, &CRFIDTestDlg::OnBnClickedButton8)
	ON_WM_VSCROLL()
END_MESSAGE_MAP()


// CRFIDTestDlg message handlers

BOOL CRFIDTestDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	GetDlgItem(IDC_BUTTON4)->EnableWindow(false);
	// TODO: Add extra initialization here
	//
	GetDlgItem(IDC_BUTTON2)->EnableWindow(false);
	GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
	GetDlgItem(IDC_BUTTON4)->EnableWindow(false);
	GetDlgItem(IDC_BUTTON5)->EnableWindow(false);
	GetDlgItem(IDC_BUTTON6)->EnableWindow(false);
	GetDlgItem(IDC_BUTTON7)->EnableWindow(false);
	GetDlgItem(IDC_BUTTON8)->EnableWindow(false);
	SetDlgItemInt(IDC_EDIT7,0);
	SetDlgItemInt(IDC_EDIT3,0);
//	PaintWindow();
	return TRUE;  // return TRUE  unless you set the focus to a control
}

#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CRFIDTestDlg::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
{
	if (AfxIsDRAEnabled())
	{
		DRA::RelayoutDialog(
			AfxGetResourceHandle(), 
			this->m_hWnd, 
			DRA::GetDisplayMode() != DRA::Portrait ? 
			MAKEINTRESOURCE(IDD_RFIDTEST_DIALOG_WIDE) : 
			MAKEINTRESOURCE(IDD_RFIDTEST_DIALOG));
	}
}
#endif


void CRFIDTestDlg::OnBnClickedButton1()
{
	// TODO: Add your control notification handler code here
	CString str;

	GetDlgItemText(IDC_BUTTON1,str);
	if (str.Compare(_T("Connect"))==0)
	{
		m_handle = RFID_Connect(4);
		if(m_handle==0)
		{
			MessageBox(L"Interface port not available",L"Warning",MB_OKCANCEL);
		}
		else
		{
			GetDlgItem(IDC_BUTTON2)->EnableWindow(true);
			GetDlgItem(IDC_BUTTON3)->EnableWindow(true);
			GetDlgItem(IDC_BUTTON4)->EnableWindow(true);
			GetDlgItem(IDC_BUTTON5)->EnableWindow(true);
			GetDlgItem(IDC_BUTTON6)->EnableWindow(true);
			GetDlgItem(IDC_BUTTON7)->EnableWindow(true);
			GetDlgItem(IDC_BUTTON8)->EnableWindow(true);
			//SetDlgItemText(IDC_EDIT4,L"");
			//SetDlgItemText(IDC_EDIT1,L"");
			//SetDlgItemText(IDC_EDIT2,L"");
			//SetDlgItemText(IDC_EDIT5,L"");
			//SetDlgItemText(IDC_EDIT6,L"");
			//SetDlgItemInt(IDC_EDIT7,0);
		//	SetDlgItemInt(IDC_EDIT3,0);
			m_bconncet = true;
			//RETAILMSG(1,(_T("m_handle = %d"),m_handle));
			GetDlgItem(IDC_BUTTON1)->SetWindowText(_T("Disconnect"));
			if(0 == RFID_GetBlockinfo(mBlocknum, mBlocksize))
			{
				SetDlgItemInt(IDC_EDIT8,mBlocknum);
				SetDlgItemInt(IDC_EDIT9,mBlocksize);
			}
			else
			{
				mBlocknum = 28;
				mBlocksize = 4;
			}
			RFID_SetBlockReceiverCallback(&ReceiveBlockData);
		}
		//RFID_SetUidReceiverCallback(&ReceiveUidData);
	}
	else
	{
		if(1 == startflag)
		{
			IsDisplayfnExit = true;
			SetDlgItemText(IDC_EDIT6,_T(""));
			memset(BLOCKData,'\0',sizeof(BLOCKData));
			RFID_StopReadBlock();
			startflag = 0;
			GetDlgItem(IDC_BUTTON8)->SetWindowText(_T("StartRead"));
			WaitForSingleObject(g_hThread, INFINITE);
			CloseHandle(g_hThread);
			g_hThread = NULL;
		}
		GetDlgItem(IDC_BUTTON2)->EnableWindow(false);
		GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
		GetDlgItem(IDC_BUTTON4)->EnableWindow(false);
		GetDlgItem(IDC_BUTTON5)->EnableWindow(false);
		GetDlgItem(IDC_BUTTON6)->EnableWindow(false);
		GetDlgItem(IDC_BUTTON7)->EnableWindow(false);
		GetDlgItem(IDC_BUTTON8)->EnableWindow(false);
		SetDlgItemText(IDC_EDIT4,L"");
		SetDlgItemText(IDC_EDIT1,L"");
		SetDlgItemText(IDC_EDIT2,L"");
		SetDlgItemText(IDC_EDIT5,L"");
		SetDlgItemText(IDC_EDIT6,L"");
		SetDlgItemInt(IDC_EDIT7,0);
		SetDlgItemInt(IDC_EDIT3,0);
		RFID_Disconnect();
		GetDlgItem(IDC_BUTTON4)->EnableWindow(false);
		m_bconncet = false;
		GetDlgItem(IDC_BUTTON1)->SetWindowText(_T("Connect"));
	}
}

void CRFIDTestDlg::OnBnClickedButton3()
{
	// TODO: Add your control notification handler code here
	if(m_bconncet)
	{
		
		SetDlgItemText(IDC_EDIT1,_T(""));
		TCHAR m_Data[9] = _T("12345678");
		TCHAR m_Disdata[100] = _T("");
		CString csText=L"12";
		GetDlgItemText(IDC_EDIT7, csText);
		//MessageBox(L"11", L"Error", MB_OKCANCEL);
		if(PosiInt(csText.GetBuffer(csText.GetLength())) == 0)
		{
			MessageBox(L"Please enter a positive integer.", L"Error", MB_OKCANCEL);
			return;
		}
		//MessageBox(L"12", L"Error", MB_OKCANCEL);
		m_Block = _ttoi(csText.GetBuffer(csText.GetLength()));
		//UpdateData();
		//MessageBox(L"2", L"Error", MB_OKCANCEL);
		if(0 == RFID_GetBlockinfo(mBlocknum, mBlocksize))
		{
			SetDlgItemInt(IDC_EDIT8,mBlocknum);
			SetDlgItemInt(IDC_EDIT9,mBlocksize);
		}
		if((m_Block>=mBlocknum) || (m_Block < 0))
		{
			MessageBox(L"Please select the correct Block!", L"Warning", MB_OKCANCEL);
			return;
		}
		if(0 != RFID_GetBlockData(m_Data, m_Block))
		{
			SetDlgItemText(IDC_EDIT1,_T("No tag in the field!")); 
			return;
		}
		_tcscat(m_Disdata,m_Data);
		//}	
		
		
		SetDlgItemText(IDC_EDIT1,m_Disdata);
	}
	
}

void CRFIDTestDlg::OnBnClickedButton2()
{
	// TODO: Add your control notification handler code here
	int val;
	if(m_bconncet)
	{
		if(0 == RFID_GetBlockinfo(mBlocknum, mBlocksize))
		{
			SetDlgItemInt(IDC_EDIT8,mBlocknum);
			SetDlgItemInt(IDC_EDIT9,mBlocksize);
		}
		CString csText;
		GetDlgItemText(IDC_EDIT3, csText);
		if(PosiInt(csText.GetBuffer(csText.GetLength())) == 0)
		{
			MessageBox(L"Please enter a positive integer.", L"Error", MB_OKCANCEL);
			return;
		}
		//UpdateData();
		m_val = _ttoi(csText.GetBuffer(csText.GetLength()));
		//RETAILMSG(1,(_T("m_val = %d\r\n"),m_val));
		if((m_val>=mBlocknum) || (m_val < 0))
		{
			//AfxMessageBox(L"Please select the correct Block");
			MessageBox(L"Please select the correct Block!", L"Warning", MB_OKCANCEL);
			return;
		}
		TCHAR sDate[100]=_T("");
		
		GetDlgItemText(IDC_EDIT2,sDate,100);
		RETAILMSG(1,(_T("len = %d"),_tcslen(sDate)));
		if(_tcslen(sDate)==0)
		{
			MessageBox(L"Input Block or Data!", L"Warning", MB_OKCANCEL);
			return;
		}
		//RETAILMSG(1,(_T("m_val = %d\r\n"),m_val));
		//AfxMessageBox(L"55555555");
		val = RFID_WriteBlockData(sDate,m_val);
		//AfxMessageBox(L"zhang");
		if(0 == val)
		{
			//AfxMessageBox(L"Please enter the characters less than or equal to the contents of the four");
			MessageBox(L"Please enter the eight characters!", L"Warning", MB_OKCANCEL);
		}
		else if(-1 == val)
		{
			SetDlgItemText(IDC_EDIT2,_T("No tag in the field!")); 
		}
		else if(-2 == val)
		{
			MessageBox(L"Please enter the correct character!", L"Warning", MB_OKCANCEL);
		}
	}
}

void CRFIDTestDlg::OnBnClickedButton4()
{
	// TODO: Add your control notification handler code here
	if (m_handle == 1)
	{
		if(0 == RFID_GetBlockinfo(mBlocknum, mBlocksize))
		{
			SetDlgItemInt(IDC_EDIT8,mBlocknum);
			SetDlgItemInt(IDC_EDIT9,mBlocksize);
		}
		SetDlgItemText(IDC_EDIT4,_T(""));
		RFID_GetUID(UIDData);
		SetDlgItemText(IDC_EDIT4,UIDData);
		memset(UIDData,'\0',sizeof(UIDData));
	}
}

void CRFIDTestDlg::OnBnClickedButton5()
{
	// TODO: Add your control notification handler code here
	if(m_bconncet)
	{
		SetDlgItemText(IDC_EDIT4,_T(""));
	}
}

void CRFIDTestDlg::OnBnClickedButton6()
{
	// TODO: Add your control notification handler code here
	int val;
	if (m_bconncet)
	{
		if(0 == RFID_GetBlockinfo(mBlocknum, mBlocksize))
		{
			SetDlgItemInt(IDC_EDIT8,mBlocknum);
			SetDlgItemInt(IDC_EDIT9,mBlocksize);
		}
		TCHAR sDate[1024]=_T("");

		GetDlgItemText(IDC_EDIT5,sDate,1024);
		if(_tcslen(sDate)==0)
		{
			MessageBox(L"Input Data!", L"Warning", MB_OKCANCEL);
			return;
		}
		val = RFID_AddOrClrWriteBlockData(sDate, 1);
		
		if(-1 == val)
		{
			SetDlgItemText(IDC_EDIT5,_T("No tag in the field!")); 
		}
		else if(0 == val)
		{
			//AfxMessageBox(L"Write Overflow!");
			MessageBox(L"Write Overflow!", L"Warning", MB_OKCANCEL);
		}
		else if(-2 == val)
		{
			MessageBox(L"Please enter the correct character!", L"Warning", MB_OKCANCEL);
		}
		else if(-3 == val)
		{
			MessageBox(L"Please enter the number of characters is a multiple of eight characters!", L"Warning", MB_OKCANCEL);
		}
	}
}

void CRFIDTestDlg::OnBnClickedButton7()
{
	// TODO: Add your control notification handler code here
	int val;
	if (m_bconncet)
	{
		if(0 == RFID_GetBlockinfo(mBlocknum, mBlocksize))
		{
			SetDlgItemInt(IDC_EDIT8,mBlocknum);
			SetDlgItemInt(IDC_EDIT9,mBlocksize);
		}
		TCHAR sDate[1024]=_T("");

		GetDlgItemText(IDC_EDIT5,sDate,1024);
		if(_tcslen(sDate)==0)
		{
			MessageBox(L"Input Data!", L"Warning", MB_OKCANCEL);
			return;
		}
		val = RFID_AddOrClrWriteBlockData(sDate, 0);
		
		if(-1 == val)
		{
			SetDlgItemText(IDC_EDIT5,_T("No tag in the field!")); 
		}
		else if(0 == val)
		{
			//AfxMessageBox(L"Write Overflow!");
			MessageBox(L"Write Overflow!", L"Warning", MB_OKCANCEL);
		}
		else if(-2 == val)
		{
			MessageBox(L"Please enter the correct character!", L"Warning", MB_OKCANCEL);
		}
		else if(-3 == val)
		{
			MessageBox(L"Please enter the number of characters is a multiple of eight characters!", L"Warning", MB_OKCANCEL);
		}
	}
}

DWORD WINAPI FRIDDisplayfn( LPVOID lpParameter )
{
	CRFIDTestDlg *papp = (CRFIDTestDlg*)(lpParameter);
	papp->Displayfn();
	return 1;
}
void CRFIDTestDlg::OnBnClickedButton8()
{
	// TODO: Add your control notification handler code here
	CString str;
	if (m_bconncet)
	{
		//Hedit = GetDlgItem(IDC_EDIT6);
		GetDlgItemText(IDC_BUTTON8,str);
		if (str.Compare(_T("StartRead"))==0)
		{
			if(0 == RFID_GetBlockinfo(mBlocknum, mBlocksize))
			{
				SetDlgItemInt(IDC_EDIT8,mBlocknum);
				SetDlgItemInt(IDC_EDIT9,mBlocksize);
			}
			//SetDlgItemText(IDC_EDIT6,_T(""));
			IsDisplayfnExit = false;
			g_hThread = ::CreateThread(NULL,0,FRIDDisplayfn,this,0,NULL);
			startflag = 1;
			RFID_StartReadBlock();
			GetDlgItem(IDC_BUTTON8)->SetWindowText(_T("EndRead"));
		}
		else
		{	
			if(0 == RFID_GetBlockinfo(mBlocknum, mBlocksize))
			{
				SetDlgItemInt(IDC_EDIT8,mBlocknum);
				SetDlgItemInt(IDC_EDIT9,mBlocksize);
			}
			IsDisplayfnExit = true;
			SetDlgItemText(IDC_EDIT6,_T(""));
			memset(BLOCKData,'\0',sizeof(BLOCKData));
			RFID_StopReadBlock();
			startflag = 0;
			GetDlgItem(IDC_BUTTON8)->SetWindowText(_T("StartRead"));
		}
		//SetDlgItemText(IDC_EDIT6,BLOCKData);
		
	}
}

void CRFIDTestDlg::PaintWindow()
{
	SCROLLINFO info;
	info.cbSize = sizeof(SCROLLINFO);     
	info.fMask = SIF_ALL;     
	info.nMin = 0;     
	info.nMax = 0; 
	info.nPage = 250;     
	info.nPos = 0;    
	info.nTrackPos = 2; 
	SetScrollInfo(SB_VERT,&info,true);

	int nWidth = GetSystemMetrics(SM_CXSCREEN);
	int nHeigth = GetSystemMetrics(SM_CYSCREEN);
	
	//RETAILMSG(1, (_T("nWidth %d,nHeigth %d\r\n"),nWidth,nHeigth));
	if (( nWidth >= 272 ) && ( nHeigth >= 480))
	{
		//AfxMessageBox(L"zzzzz");
		return;
	}
	else if( nHeigth < 480 )
	{
		MoveWindow( 0, 0, nWidth, nHeigth, true );
		SCROLLINFO info;
		info.cbSize = sizeof(SCROLLINFO);     
		info.fMask = SIF_ALL;     
		info.nMin = 0;     
		info.nMax = 350; 
		info.nPage = 240;     
		info.nPos = 0;    
		info.nTrackPos = 2; 
		SetScrollInfo(SB_VERT,&info,true);

		float multiplex = float(nWidth - 10)/float(272);
		float multipley = 1;

		for ( int n = 1000; n <= 1022; n++ )
		{
			PainControl( n, multiplex, multipley );
		}

	}
	else
	{
		float multiplex = float(nWidth)/272;
		float multipley = float(nHeigth)/480;
		//RETAILMSG(1, (_T("multiplex %d,multipley %d\r\n"),multiplex,multipley));
		/*multiplex = float(multiplex) * float(96)/float(143);
		multipley = float(multipley) * float(14)/float(24);*/
		//RETAILMSG(1, (_T("multiplex %f,multipley %f\r\n"),multiplex,multipley));
		for ( int n = 1000; n <= 1022; n++ )
		{
			PainControl( n, multiplex, multipley );
		}
	}

}


void CRFIDTestDlg::PainControl( int controlID, float multiplex, float multipley)
{ 
	HWND hwnd = ::GetDlgItem(m_hWnd,controlID);
	if( hwnd == NULL )
	{
		//CString cs;
		//cs.Format( _T("%d"),controlID);
		//MessageBox(cs, NULL, MB_OK);
		//RETAILMSG(1, (_T("pwnd is null,controlID %d\r\n"),controlID));
		//return;
	}
	//RETAILMSG(1, (_T("controlID %d\r\n"),controlID));
	CRect rect;
	::GetWindowRect(hwnd,&rect);
	int newHeight = rect.Height() * multipley;
	int newWeight = rect.Width() * multiplex;
	int newx = rect.left * multiplex;
	int newy = rect.top * multipley - 20;

	// 	RETAILMSG(1, (_T("newHeight %d,newWeight %d,newx %d,newy %d\r\n"),
	//  		newHeight,newWeight,newx,newy));
	//if(( controlID >= 1005 ) && ( controlID <= 1009 ))
	//{
	//	//::SetWindowPos(hwnd,HWND_TOP,newx, newy,newWeight,newHeight,SWP_NOSIZE); 
	//	::MoveWindow(hwnd,newx,newy,newWeight,500,TRUE);

	//}else
	{
		::MoveWindow(hwnd,newx,newy,newWeight,newHeight,TRUE);
	}
}
void CRFIDTestDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	// TODO: Add your message handler code here and/or call default
	static SCROLLINFO si;
	static bool bfirst = false;
	if( ! bfirst )
	{
		GetScrollInfo(SB_VERT,&si,SIF_ALL); 
		bfirst = true;
	}
	RETAILMSG(1, (_T(" si.nPos %d,nPos %d\r\n"),si.nPos,nPos));
	int noldPos = si.nPos;
	int h = 1;

	switch(nSBCode)   
	{   
	case   SB_LINEDOWN:   
		si.nPos   =   min(si.nPos+h,   si.nMax);  
		RETAILMSG(1, (_T("SB_LINEDOWN si.nPos %d\r\n"),si.nPos));
		break;   
	case   SB_PAGEDOWN:   
		si.nPos   =   min(si.nPos+h*10,   si.nMax); 
		RETAILMSG(1, (_T("SB_PAGEDOWN si.nPos %d\r\n"),si.nPos));
		break;   
	case   SB_LINEUP:   
		si.nPos   =   max(si.nPos-h,   si.nMin); 
		RETAILMSG(1, (_T("SB_LINEUP si.nPos %d\r\n"),si.nPos));
		break;   
	case   SB_PAGEUP:   
		si.nPos   =   max(si.nPos-h*10,   si.nMin);  
		RETAILMSG(1, (_T("SB_PAGEUP si.nPos %d\r\n"),si.nPos));
		break;   
	case   SB_THUMBPOSITION:  
		RETAILMSG(1, (_T("SB_THUMBPOSITION si.nPos %d\r\n"),si.nPos));
		break;
	case   SB_THUMBTRACK:   
		si.nPos   =   /*si.nTrackPos*/nPos;  
		RETAILMSG(1, (_T("SB_THUMBTRACK si.nPos %d,\r\n"),si.nPos));
		break;   
	case   SB_TOP:   
		si.nPos   =   si.nMin; 
		RETAILMSG(1, (_T("SB_TOP si.nPos %d\r\n"),si.nPos));
		break;   
	case   SB_BOTTOM:   
		si.nPos   =   si.nMax; 
		RETAILMSG(1, (_T("SB_BOTTOM si.nPos %d\r\n"),si.nPos));
		break;   
	} 
	RETAILMSG(1, (_T("SetScrollInfo si.nPos %d,noldPos %d\r\n"),si.nPos,noldPos));

	SetScrollInfo(SB_VERT,&si);
	ScrollWindowEx(0,   noldPos - si.nPos,NULL,NULL,NULL,NULL,SW_INVALIDATE|SW_SCROLLCHILDREN);

	CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}