// ChoosePhotoSkin2.cpp : implementation file
//

#include "stdafx.h"
#include "ChoosePhotoSkin2.h"
#include "YLGL.h"
#include "./helper/ffsco.h"
#include ".\MenuBarXP\MenuXP.h"
#include "ChoosePhotoSkin3.h"
#include "ShowPic22.h"
#include "ClientRequirement.h"
#include "MyLock.h"
#include "Time5.h"
#include "ComparePhoto.h"
#include "ReplaceDesignNo.h"
#include "Login2.h"
#include "TimeOutDlg.h"
#include "ShowEffect.h"
#include "SelBrunDevice.h"
#include "ProductChooseFilter.h"
#define	THUMBNAIL_WIDTH		100
#define	THUMBNAIL_HEIGHT	90

extern HCURSOR g_cursorhand;
//mode
//0 ȫ��
//1 ѡ��
//2 δѡ
//3 ɾ��
//4 ���
//5 ���
/////////////////////////////////////////////////////////////////////////////

// ChoosePhotoSkin2 dialog IDC_EDITzs
ChoosePhotoSkin2::ChoosePhotoSkin2(CWnd* pParent /*=NULL*/)	: CDialog(ChoosePhotoSkin2::IDD, pParent)
{
	m_pBk = NULL;
	m_pParent = NULL;
	m_name1 = _T("");
	m_name2 = _T("");
	m_time4 = g_date;
	m_waiter3 = _T("");
	m_takezs = _T("");
	m_taoxizs = _T("");
	m_choosezs = _T("");
	m_strOrderNumber = _T("");
	m_money3 = _T("");
	m_bz3 = _T("");
	//}}AFX_DATA_INIT
	m_bTerminate = false;
	m_bRunning = false;
	m_hThread = NULL;
	m_bSave = 0;
	m_bModify = 0;
	m_SelectCategory = 0;
	m_showpichwd = NULL;
	m_Runingmode = 0;
	g_pMainWnd->GetSkin();
	m_bSort = 0;
	m_bHide = atoi(g_cominfoarray.ElementAt(0).ElementAt(59));
	m_pInputArray = NULL;
	m_bShowTimeOut = 1;
	m_bCanSave = 1;
	m_bGrowthTX = 0;
	m_nChoosePhotoType = 0;
	m_bChooseBig = 0;
	m_bFromLocal = 0;
	m_strStatusOfChoosePhoto = "δѡ";
}

ChoosePhotoSkin2::ChoosePhotoSkin2(DWORD id, CWnd* pParent)	: CDialog(id, pParent)
{
	m_pBk = NULL;
	m_pParent = NULL;
}

void ChoosePhotoSkin2::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(ChoosePhotoSkin2)
	DDX_Control(pDX, IDC_COMBO1, m_combo1);
	DDX_Control(pDX, IDC_EDITzs3, m_editnum4);
	DDX_Control(pDX, IDC_EDITzs2, m_editnum3);
	DDX_Control(pDX, IDC_EDITzs, m_editnum2);
	DDX_Control(pDX, IDC_EDITmoney3, m_editnum1);
	DDX_Control(pDX, IDC_LIST3, m_List3);
	DDX_Control(pDX, IDC_LIST2, m_List2);
	DDX_Control(pDX, IDC_LIST1, m_List1);
	DDX_Text(pDX, IDC_EDITname1, m_name1);
	DDX_Text(pDX, IDC_EDITname2, m_name2);
	DDX_Text(pDX, IDC_EDITtime4, m_time4);
	DDX_Text(pDX, IDC_EDITwaiter3, m_waiter3);
	DDX_Text(pDX, IDC_EDITzs, m_takezs);
	DDX_Text(pDX, IDC_EDITzs2, m_taoxizs);
	DDX_Text(pDX, IDC_EDITzs3, m_choosezs);
	DDX_Text(pDX, IDC_EDITmoney3, m_money3);
	DDX_Text(pDX, IDC_EDITid, m_strOrderNumber);
	DDX_Text(pDX, IDC_EDITbz3, m_bz3);
	//}}AFX_DATA_MAP}
}

BEGIN_MESSAGE_MAP(ChoosePhotoSkin2, CDialog)
	//{{AFX_MSG_MAP(ChoosePhotoSkin2)
	ON_WM_PAINT()
	ON_WM_DESTROY()
	ON_WM_ERASEBKGND()
	ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
	ON_WM_CLOSE()
	ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnRclickList1)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_USER + 1101, OnBtnClick)
	ON_COMMAND_RANGE(IDM_MENUsp1 - 1, IDM_MENUsp1 + 200, OnCommandMenu)
	ON_MESSAGE(WM_USER + 200, UpdateTakeZS)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// ChoosePhotoSkin2 message handlers
extern void SizeToContent(HWND hwnd, Image *img);

void ChoosePhotoSkin2::OnBtnClick(WPARAM wParam, LPARAM lParam) 
{
	// WM_USER + 1101
	// F5��������ʾɾ����Ƭ
	int id = lParam;
	id -= 99;
	switch (id)
	{
	case 1:		// �鿴ȫ����Ƭ��ť�¼�;
	case 2:		// �鿴ѡ�е���Ƭ��ť�¼�;
	case 4:		// F5�鿴ɾ������Ƭ;
		if (m_SelectCategory == id - 1 && m_SelectCategory != 1)return;
		m_SelectCategory = id - 1;
		LoadPhotos();
		break;
	case 3://�鿴δѡ��ť�¼�;
		if (m_SelectCategory == id - 1)return;
		m_sChooseFilter = "";
		UpdateChooseZS();
		GetNoSelPhoto();
		m_SelectCategory = id - 1;
		LoadPhotos();
		break;
	case 13:	// �鿴�����Ƭ��ť�¼�;
		GetAlbumPhoto();
		break;
	case 14:	// �鿴�����Ƭ��ť�¼�;
		GetDiskPhoto();
		break;
	case 15:		// Ч��ͼ��ť�¼�;
		{
			ShowEffectDlg dlg;
			dlg.m_pPhotopatharray = this->GetCurArray();
			dlg.DoModal();
		}
		break;
	case 5:		// ���水ť�¼�;
		OnButton4();
		break;
	case 9:
		{
			if (((MyBmpButton2*)m_picarray.ElementAt(8))->GetPushDown())
				((MyBmpButton2*)m_picarray.ElementAt(8))->SetPushDown(0);
			else
				((MyBmpButton2*)m_picarray.ElementAt(8))->SetPushDown(1);

			ReLoadPhoto();
		}
		break;
	case 10:
		{
			POSITION pos;
			pos = m_List1.GetFirstSelectedItemPosition();
			if (pos == NULL)
			{
				AfxMessageBox("����ѡ����Ҫɾ������Ƭ!", MB_ICONINFORMATION);
				return;
			}
			if (AfxMessageBox("ɾ�����޷��ָ�, ȷ��ɾ����?", MB_YESNO | MB_ICONSTOP) != IDYES)return;

			while (pos)
			{
				int iItem = m_List1.GetNextSelectedItem(pos);
				CString title = m_List1.GetItemText(iItem, 0);
				int pos = title.Find("\r\n");
				if (pos != -1)title = title.Left(pos);
				if (m_Runingmode == 1)//�����
				{
					if (title.Find("Flash") != -1)
					{
						title.Replace("Flash", "delgabook");
						CString str = m_path + title;
						DeleteDirectory(str);	// �ݹ�ɾ��delgabook��FlashĿ¼;
						GetPhotos();
						LoadPhotos();
						return;
					}
				}
				::DeleteFile(m_path + title + ".jpg");				// ɾ��ѡ�е���Ƭ;
				::DeleteFile(m_path + "s" + title + ".jpg");		// ɾ���ȸ�����Ƭ��sСͼ;
				////////////////
				CStringArray *pArray = GetCurArray();
				CString path = pArray->ElementAt(iItem);
				path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
				path = path.Left(path.ReverseFind('.'));
				if (CheckName(path))
				{
					path = "," + path + ",";
					for (int i = 0; i < m_List2.GetItemCount(); i++)
					{
						CString no = m_noarray.ElementAt(i);
						if (no.Find(path) != -1)
						{
							path.TrimRight(",");
							no.Delete(no.Find(path), path.GetLength());
							no.TrimLeft(","); no.TrimRight(",");
							m_List2.SetItemText(i, 4, no);
							no = "," + no + ",";
							m_noarray.SetAt(i, no);
						}
					}
				}
			}
			GetPhotos();
			LoadPhotos();
		}
		break;
	case 6:		// �رհ�ť�¼� ;
		if (m_bModify && m_bCanSave)
		{
			if (AfxMessageBox("����, ѡƬ�޸�δ����, �Ƿ񱣴�����˳�?", MB_YESNO | MB_ICONINFORMATION) == IDYES)
			{
				OnButton4();
				if (m_bSaveFail)
				{
					AfxMessageBox("���ӷ�����ʧ��, ����ʧ��, �������ڱ��������½���ѡƬ�ָ���ѡ��״̬!");
					CDialog::OnCancel(); return;
				}
				return;
			}
			else
			{
				CString savepath;
				savepath.Format("%s\\%s.dat", g_mainpath, m_strOrderNumber);
				if (m_Runingmode)savepath.Format("%s\\%s-2.dat", g_mainpath, m_strOrderNumber);
				::DeleteFile(savepath);		// ɾ��*.dat�ļ�; 
			}
		}
		CDialog::OnCancel();
		break;
	case 11:
		if (m_selphotownd.GetSafeHwnd() == NULL)
		{
			m_selphotownd.m_id = m_strOrderNumber;
			m_selphotownd.m_rc = m_rcarray.ElementAt(6);
			m_selphotownd.Create(IDD_DLGShowSelPhoto, this);
		}
		m_selphotownd.ShowWindow(1);
		break;
	case 12:
		if (m_Runingmode)
		{
			ReplaceDesignNo dlg;
			dlg.m_id = this->m_strOrderNumber;
			dlg.DoModal();
		}
		/*	if(m_selphotownd2.GetSafeHwnd ()==NULL)
		{
		m_selphotownd2.m_id=m_id;
		m_selphotownd2.m_rc=m_rcarray.ElementAt (6);
		m_selphotownd2.Create (IDD_DLGShowSelPhoto2, this);
		}
		m_selphotownd2.ShowWindow  (1);*/
		break;
	}
}

BOOL ChoosePhotoSkin2::OnInitDialog() //��ʼ��ѡƬ*�����
{
	CDialog::OnInitDialog();

#if 1
	// 1.����liaƤ����Ϣ;
	g_bInSkin = 1;
	m_ticks = ::GetTickCount();
	if (g_cursorhand == NULL)
		g_cursorhand = AfxGetApp()->LoadCursor(IDC_CURSORHAND);
	BYTE *pData = NULL;
	BYTE *pDataBegin;

	//printf("Jeff:loadLia·��:%s\n\n",g_mainpath+"\\skin\\"+m_liapath);//Jeff Printf;
	if (!LoadLia(g_mainpath + "\\skin\\" + m_liapath, &pData, &pDataBegin, &m_pBk, m_hWnd))
	{
		EndDialog(0);
		return false;
	}

	//printf("Jeff:g_resdata2.nPicCount=%d\n\n",g_resdata2.nPicCount); // Jeff Printf,���nPicCount����һֱ��15;
	for (int i = 0; i < g_resdata2.nPicCount; i++)
	{
		g_resdata2.rect[i].left *= g_fscalex;
		g_resdata2.rect[i].right *= g_fscalex;
		g_resdata2.rect[i].top *= g_fscaley;
		g_resdata2.rect[i].bottom *= g_fscaley;

		if (i == 8)
			g_resdata2.rect[i] = g_resdata2.rect[2];
		else if (i == 9)
			g_resdata2.rect[i] = g_resdata2.rect[3];
		else if (i == 10)
			g_resdata2.rect[i] = g_resdata2.rect[1];
		if (g_resdata2.nPicBmpCount[i])
		{
			MyBmpButton2 *pic = new MyBmpButton2;
			m_picarray.Add((DWORD)pic);
			CRect rc = g_resdata2.rect[i];
			CString str;
			str.Format(_T("%d"), i + 1);
			pic->Create(str, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, i + 100);
			pic->m_bmpcount = g_resdata2.nPicBmpCount[i];
			pic->ReadBmp(&pData, NULL, this);
#ifdef SZWNS_VERSION
			if(i==3 && m_mode2==0)
			{
				Image *img=NULL;
				LoadImageFromRes(&img, MAKEINTRESOURCE(IDR_JPG6), _T("JPG") );
				delete pic->m_bmp;
				pic->m_bmp=img->Clone();
				delete img;

				img=NULL;
				LoadImageFromRes(&img, MAKEINTRESOURCE(IDR_JPG7), _T("JPG") );
				delete pic->m_bmpfocus;
				pic->m_bmpfocus=img->Clone();
				delete img;

				img=NULL;
				LoadImageFromRes(&img, MAKEINTRESOURCE(IDR_JPG8), _T("JPG") );
				delete pic->m_bmpfocused;
				pic->m_bmpfocused=img->Clone();
				delete img;
			}
#endif
		}
		else
			m_picarray.Add(NULL);
		m_rcarray.Add(g_resdata2.rect[i]);
	}
	delete[]pDataBegin;


	if (m_Runingmode)//�����
	{
		m_bHide = 0;
		//		printf("Jeff:g_cominfoarray.ElementAt(0).ElementAt(86)=%s\n\n",g_cominfoarray.ElementAt(0).ElementAt(86)); // Jeff Printf;
		if (atoi(g_cominfoarray.ElementAt(0).ElementAt(86)))
		{
			((MyBmpButton2*)m_picarray.ElementAt(3))->ShowWindow(SW_HIDE);
			CRect rc, rc2;
			((MyBmpButton2*)m_picarray.ElementAt(3))->GetWindowRect(rc);
			((MyBmpButton2*)m_picarray.ElementAt(1))->GetWindowRect(rc2);
			int dtx = rc.right - rc2.right;
			ScreenToClient(rc2);
			rc2.left += dtx;
			rc2.right += dtx;
			((MyBmpButton2*)m_picarray.ElementAt(1))->MoveWindow(rc2);
			((MyBmpButton2*)m_picarray.ElementAt(0))->GetWindowRect(rc2);
			ScreenToClient(rc2);
			rc2.left += dtx;
			rc2.right += dtx;
			((MyBmpButton2*)m_picarray.ElementAt(0))->MoveWindow(rc2);
		}

		CRect rc, rc2;
		((MyBmpButton2*)m_picarray.ElementAt(5))->GetWindowRect(rc);
		((MyBmpButton2*)m_picarray.ElementAt(4))->GetWindowRect(rc2);
		int dtx = rc.right - rc2.right;
		rc2 = rc;
		//	if(atoi(g_cominfoarray.ElementAt(0).ElementAt(86))==0)
		{
			float scale = 0.9;
			dtx *= scale;
			int wid = rc2.Width()*scale;
			int hei = rc2.Height()*scale;
			int dty = rc2.Height() - hei;
			dty /= 2;
			rc2.left = rc2.right - wid;
			rc2.top += dty;
			rc2.bottom = rc2.top + hei;
		}

		ScreenToClient(rc2);
		((MyBmpButton2*)m_picarray.ElementAt(5))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(4))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(14))->MoveWindow(rc2);

		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(2))->MoveWindow(rc2);
		if (atoi(g_cominfoarray.ElementAt(0).ElementAt(86)) == 0)
		{
			rc2.left -= dtx;
			rc2.right -= dtx;
			((MyBmpButton2*)m_picarray.ElementAt(3))->MoveWindow(rc2);
		}

		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(1))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(0))->MoveWindow(rc2);

		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(8))->MoveWindow(rc2);

		((MyBmpButton2*)m_picarray.ElementAt(11))->ShowWindow(SW_HIDE);
	}
	else
	{
		if (atoi(g_cominfoarray.ElementAt(0).ElementAt(86)))
		{
			((MyBmpButton2*)m_picarray.ElementAt(3))->ShowWindow(SW_HIDE);
			CRect rc, rc2;
			((MyBmpButton2*)m_picarray.ElementAt(3))->GetWindowRect(rc);
			((MyBmpButton2*)m_picarray.ElementAt(1))->GetWindowRect(rc2);
			int dtx = rc.right - rc2.right;
			ScreenToClient(rc2);
			rc2.left += dtx;
			rc2.right += dtx;
			((MyBmpButton2*)m_picarray.ElementAt(1))->MoveWindow(rc2);
			((MyBmpButton2*)m_picarray.ElementAt(0))->GetWindowRect(rc2);
			ScreenToClient(rc2);
			rc2.left += dtx;
			rc2.right += dtx;
			((MyBmpButton2*)m_picarray.ElementAt(0))->MoveWindow(rc2);
		}
	}

	if (1)//m_mode2==0)
	{
		((MyBmpButton2*)m_picarray.ElementAt(7))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(8))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(9))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(10))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(11))->ShowWindow(SW_HIDE);
	}
	else
	{
		((MyBmpButton2*)m_picarray.ElementAt(7))->EnableWindow(0);
		((MyBmpButton2*)m_picarray.ElementAt(0))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(1))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(2))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(3))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(11))->ShowWindow(SW_HIDE);

		if (IsHasRights2new(37) == 0)
		{
			((MyBmpButton2*)m_picarray.ElementAt(8))->ShowWindow(SW_HIDE);
			((MyBmpButton2*)m_picarray.ElementAt(9))->ShowWindow(SW_HIDE);
		}
	}
	if (m_Runingmode)
	{
		((MyBmpButton2*)m_picarray.ElementAt(8))->ShowWindow(SW_SHOW);
		//	((MyBmpButton2*)m_picarray.ElementAt (8))->SetPushDown (1);
		((MyBmpButton2*)m_picarray.ElementAt(12))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(13))->ShowWindow(SW_HIDE);
	}
	else//�ư�ťλ��
	{
		CRect rc, rc2;
		((MyBmpButton2*)m_picarray.ElementAt(5))->GetWindowRect(rc);
		((MyBmpButton2*)m_picarray.ElementAt(4))->GetWindowRect(rc2);
		int dtx = rc.right - rc2.right;
		rc2 = rc;
		//	if(atoi(g_cominfoarray.ElementAt(0).ElementAt(86))==0)
		{
			float scale = 0.9;
			dtx *= scale;
			int wid = rc2.Width()*scale;
			int hei = rc2.Height()*scale;
			int dty = rc2.Height() - hei;
			dty /= 2;
			rc2.left = rc2.right - wid;
			rc2.top += dty;
			rc2.bottom = rc2.top + hei;
		}

		ScreenToClient(rc2);
		((MyBmpButton2*)m_picarray.ElementAt(5))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(4))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(14))->MoveWindow(rc2);


		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(2))->MoveWindow(rc2);
		if (atoi(g_cominfoarray.ElementAt(0).ElementAt(86)) == 0)
		{
			rc2.left -= dtx;
			rc2.right -= dtx;
			((MyBmpButton2*)m_picarray.ElementAt(3))->MoveWindow(rc2);
		}

		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(12))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(13))->MoveWindow(rc2);

		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(1))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(0))->MoveWindow(rc2);
	}

#ifndef MNLS_VERSION
	((MyBmpButton2*)m_picarray.ElementAt(7))->ShowWindow(SW_HIDE);
	((MyBmpButton2*)m_picarray.ElementAt(7))->EnableWindow(0);
	Graphics graph(m_pBk);
	Image *img = NULL;
	if (m_Runingmode == 0)
		::LoadImageFromBuf(&img, g_mainpath + "\\ͼƬ\\����-ѡƬ.jpg");
	else
		::LoadImageFromBuf(&img, g_mainpath + "\\ͼƬ\\����-�����.jpg");
	if (img)
	{
		if (img->GetWidth() == 2000)
		{
			graph.SetSmoothingMode(SmoothingModeHighQuality);
			graph.DrawImage(img, 0, 0);
		}
		delete img;
	}
#endif

	CRect listrc = m_rcarray.ElementAt(6);
	CRect rc;
	GetClientRect(rc);
	rc.top = listrc.top;
	m_List1.MoveWindow(rc);

	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Jeff���Ͼ�Ϊ���沼��,���ڻ���;
	// ����Ĵ���������ݴ���;
	//----------------------------------------------------------------------------------------------------------------------------------------
	//----------------------------------------------------------------------------------------------------------------------------------------
	//----------------------------------------------------------------------------------------------------------------------------------------

	CString path, str;
	if (m_Runingmode)
	{
		m_path = g_path3 + "\\";
		m_path += m_strOrderNumber;
		m_path += "\\";
		//		printf("Jeff:m_path=%s\n\n",m_path); // Jeff Printf;
	}

	if (m_Runingmode)//�����
	{
		GetPhotos();
	}
	else	// ��ʼѡƬ
	{
		IsGrowthTx growthtxdlg;
		growthtxdlg.m_mode = 1;
		growthtxdlg.m_strOrderNumber = m_strOrderNumber;
		growthtxdlg.DoModal();
		m_bGrowthTX = growthtxdlg.m_bGrowthTx;
		m_seltxname = growthtxdlg.m_seltxname;
		/*if(!growthtxdlg.m_seltxname.IsEmpty ())
		{
		if(growthtxdlg.m_seltxname!="ȫ��")
		{
		path+=growthtxdlg.m_seltxname;
		path+="\\";
		}
		}*/

		// HC:����,checkHC����ڱ����Ƿ���ڻ������Ƭ;
		if (CheckHC()) // (һ�㷵��0)��һ���Dz鿴C:\WINDOWS\System32\��û��lyfz���ļ���,�Լ����ļ������Ƿ��ж������ļ��к���Ƭ;
		{
			m_bFromLocal = 1;
			char path[MAX_PATH];
			::GetSystemDirectory(path, MAX_PATH);
			CString sysdir = path;
			sysdir += "\\lyfz";
			::CreateDirectory(sysdir, NULL);
			sysdir += "\\";
			sysdir += m_strOrderNumber;
			using namespace helper_coffs;
			ffsco o;
			o.dirs(1);
			o.find(LPCSTR(sysdir), LPCSTR("*.jpg"));
			ffsco::typeT coo;
			ffsco::typeT::iterator it;
			coo = o.co_file();
			for (it = coo.begin(); coo.end() != it; it++)
			{
				str = (*it).c_str();
				//printf("Jeff:str=%s\n\n",str);// Jeff Printf
				if (str.GetAt(str.ReverseFind('\\') + 1) != 's' && str.GetAt(str.ReverseFind('\\') + 1) != 'm')
				{
					m_patharray1.Add(str);
				}
			}
		}

		//printf("Jeff:m_patharray1.GetSize()=%d\n\n",m_patharray1.GetSize());// Jeff Printf;
		if (m_patharray1.GetSize() == 0) // m_patharray1���鿴ȫ����Ƭ.
		{
			if (IsPhoto2Exist())//��������ļ��д���;
			{
				SelBrunDevice dlg;
				dlg.m_mode = 1;
				if (dlg.DoModal() == IDOK)  // m_nChoosePhotoType=0:ԭƬ+��Ƭ; =1����Ƭ; =2��ԭƬ
					m_nChoosePhotoType = dlg.m_sel;
				else
					m_nChoosePhotoType = 0;
				//m_nChoosePhotoType = 2;
			}
			else AfxMessageBox("��ܰ��ʾ��\r\nδ�ҵ�����Ƭ����ʹ��ԭƬѡƬ", MB_ICONINFORMATION);


			CString path2;
			m_path = g_path1 + "\\";
			m_path += m_strOrderNumber;
			m_path += "\\";

			if (m_seltxname != "" && m_seltxname != "ȫ��")
			{
				m_path += m_seltxname;
				m_path += "\\";
			}
			if (m_nChoosePhotoType == 1) // ѡƬ:ѡ����Ƭ�ļ���;
			{
				m_path = g_path2 + "\\";
				m_path += m_strOrderNumber;
				m_path += "\\";

#if JEFF_TEST_ON	// �ɳ���ϵѡ���޺õ�Ƭʱ��Ҫ; [3/25/2015 lyfz]
				if (m_seltxname != "" && m_seltxname != "ȫ��")
				{
					m_path += m_seltxname;
					m_path += "\\";
				}
#endif
			}

			//AfxMessageBox(m_path);

			// ����m_path�������ļ�o.find(...);
			CString filename;
			using namespace helper_coffs;
			ffsco o;
			o.dirs(1);
			o.find(LPCSTR(m_path), LPCSTR("*.*"));
			ffsco::typeT coo;
			ffsco::typeT::iterator it;
			coo = o.co_file();
			for (it = coo.begin(); coo.end() != it; it++)	// �������;
			{
				path = (*it).c_str();
				if (path.GetAt(path.ReverseFind('\\') + 1) != 's' && path.GetAt(path.ReverseFind('\\') + 1) != 'm')
				{
					path.MakeLower();

					filename = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
					if (filename.Find(".") != -1)
						filename = filename.Left(filename.Find("."));
					if (!myisdigit(filename))continue;

					if (m_nChoosePhotoType == 1)	// m_patharray1ֻ������Ƭ�ļ���;
					{
#if JEFF_TEST_ON
						if(PathFileExists(path))
							m_patharray1.Add(path);
#endif
					}
					//else // m_nChoosePhotoType=0,2
					else if (m_nChoosePhotoType == 0 || m_nChoosePhotoType == 2)
					{
						path2 = path;
						if (m_nChoosePhotoType == 0)	// ԭƬ+��Ƭ;
						{
							path2.Replace("�ͻ�ԭƬ", "�޺õ�Ƭ");
							//printf("Jeff:ԭƬ+��Ƭ path2=%s\n\n",path2); // Jeff Printf;
						}

						if (m_bGrowthTX == 0)
						{
							int pos = path2.Find(m_strOrderNumber);
							pos += m_strOrderNumber.GetLength();
							int pos2 = path2.ReverseFind('\\');
							path2 = path2.Left(pos) + path2.Right(path2.GetLength() - pos2);
						}

						if (m_nChoosePhotoType == 0 && PathFileExists(path2))	// ԭƬ+��Ƭ;
						{
							m_patharray1.Add(path2);

						}
						else // ����ԭƬ
						{
							path2.Replace(".raw", ".jpg");
							if (PathFileExists(path2))
							{
								m_patharray1.Add(path2); 
								continue;
							}
							path2.Replace(".nef", ".jpg");
							if (PathFileExists(path2))
							{
								m_patharray1.Add(path2); 
								continue;
							}
							path2.Replace(".cr2", ".jpg");
							if (PathFileExists(path2))
							{
								m_patharray1.Add(path2); 
								continue;
							}
							else
							{
								if (path.Right(3) != "jpg")
									continue;
#if JEFF_TEST_ON
								if (PathFileExists(path))
									m_patharray1.Add(path);
#else
								m_patharray1.Add(path);
#endif
							}
						}
					}
				}
			}


			if (m_nChoosePhotoType != 2)	// Jeff:�������ֻ�鿴ԭƬ ,ֻ�г���Ƭ����ж���Ч��;
				//if (m_nChoosePhotoType != 0)	// Jeff:�������ֻ�鿴ԭƬ;
			{//�����޺õ�Ч��
				CString path2;
				path2 = g_path2 + "\\";
				path2 += m_strOrderNumber;
				path2 += "\\";					//printf("Jeff:****paht2=%s\n\n",path2);//Jeff Printf;path2="�޺õ�Ƭ"
				using namespace helper_coffs;
				ffsco o;
				o.dirs(0);
				o.find(LPCSTR(path2), LPCSTR("*.jpg"));
				ffsco::typeT coo;
				ffsco::typeT::iterator it;
				coo = o.co_file();
				for (it = coo.begin(); coo.end() != it; it++)
				{
					path = (*it).c_str();
					if (path.GetAt(path.ReverseFind('\\') + 1) != 's' && path.GetAt(path.ReverseFind('\\') + 1) != 'm')
					{
						path.MakeLower();
						path2 = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
						if (path2.Find("-") != -1)
						{
#if JEFF_TEST_ON
							if(PathFileExists(path))
								m_patharray1.Add(path);
#else
							m_patharray1.Add(path);
#endif
						}
					}
				}
			}
		}
		if (m_patharray1.GetSize() && atoi(g_cominfoarray.ElementAt(0).ElementAt(61)))
		{
			int size = m_patharray1.GetSize() - 1;
			CString sTemp;
			int nPos;
			for (int i = 0; i < size; i++)
			{
				nPos = rand() % (size - i);
				sTemp = m_patharray1.ElementAt(size - i);
				m_patharray1.SetAt(size - i, m_patharray1.ElementAt(nPos));
				m_patharray1.SetAt(nPos, sTemp);
			}
		}
	}

	m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
	m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);

	m_List2.InitStyle();
	m_List2.InsertColumn(0, _T("���"), LVCFMT_LEFT, 45);
	m_List2.InsertColumn(1, _T("��Ʒ����"), LVCFMT_LEFT, 150);
	m_List2.InsertColumn(2, _T("����"), LVCFMT_LEFT, 45);

	m_List3.InitStyle();
	m_List3.InsertColumn(0, _T("autoid"), LVCFMT_LEFT, 0);
	m_List3.InsertColumn(1, _T("���"), LVCFMT_LEFT, 45);
	m_List3.InsertColumn(2, _T("��Ʒ����"), LVCFMT_LEFT, 150);
	m_List3.InsertColumn(3, _T("�۸�"), LVCFMT_LEFT, 45);
	m_List3.InsertColumn(4, _T("����"), LVCFMT_LEFT, 45);
#ifdef LKAY_VERSION
	m_List3.InsertColumn(5,_T("P��"),LVCFMT_LEFT,55);
	m_List3.InsertColumn(6,_T("����"),LVCFMT_LEFT,55);
	m_List3.InsertColumn(7,_T("��Ƭ���"),LVCFMT_LEFT,365);
#else
	m_List3.InsertColumn(5, _T("��Ƭ���"), LVCFMT_LEFT, 365);
#endif	

#else
	if( FALSE==InitializeUI() ) return FALSE;
#endif

	if (m_Runingmode == 0)
	{
		GetData();
		if (m_checkstatus == "OK")
		{
			if (atoi(g_cominfoarray.ElementAt(0).ElementAt(85)) && IsHasRights2new(20) == 0)
			{
				Login2 dlg;
				if (dlg.DoModal() != IDOK)
				{
					MyBmpButton2 *btn = ((MyBmpButton2*)m_picarray.ElementAt(4));
					btn->m_bmpdisable = btn->m_bmp->Clone();

					Graphics graph(btn->m_bmpdisable);
					CPoint pt1, pt2, pt3;
					pt1.x = 0;
					pt1.y = 0;
					pt2.x = btn->m_bmp->GetWidth();
					pt2.y = 0;
					pt3.x = 0;
					pt3.y = btn->m_bmp->GetHeight();
					Point destinationPoints[] = {
						Point(pt1.x, pt1.y),   // destination for upper-left point of original
						Point(pt2.x, pt2.y),  // destination for upper-right point of original
						Point(pt3.x, pt3.y) };  // destination for lower-left point of original
						ColorMatrix colorMatrix = \
						{0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
						0.0f, 0.0f, 0.0f, 0.0f, 1.0f};

						ImageAttributes imageAtt;
						imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
						graph.DrawImage(btn->m_bmp,
							destinationPoints,
							3,
							0,
							0,
							btn->m_bmp->GetWidth(),
							btn->m_bmp->GetHeight(),
							UnitPixel,
							&imageAtt);
						btn->EnableWindow(0);
						m_bCanSave = 0;
						//		CDialog::OnCancel ();
						//		return 1;
				}
				else if (IsHasRightsnew2(20, dlg.m_rights) == 0)
				{
					MyBmpButton2 *btn = ((MyBmpButton2*)m_picarray.ElementAt(4));
					btn->m_bmpdisable = btn->m_bmp->Clone();

					Graphics graph(btn->m_bmpdisable);
					CPoint pt1, pt2, pt3;
					pt1.x = 0;
					pt1.y = 0;
					pt2.x = btn->m_bmp->GetWidth();
					pt2.y = 0;
					pt3.x = 0;
					pt3.y = btn->m_bmp->GetHeight();
					Point destinationPoints[] = {
						Point(pt1.x, pt1.y),   // destination for upper-left point of original
						Point(pt2.x, pt2.y),  // destination for upper-right point of original
						Point(pt3.x, pt3.y) };  // destination for lower-left point of original
						ColorMatrix colorMatrix = \
						{0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
						0.0f, 0.0f, 0.0f, 0.0f, 1.0f};

						ImageAttributes imageAtt;
						imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
						graph.DrawImage(btn->m_bmp,
							destinationPoints,
							3,
							0,
							0,
							btn->m_bmp->GetWidth(),
							btn->m_bmp->GetHeight(),
							UnitPixel,
							&imageAtt);
						btn->EnableWindow(0); m_bCanSave = 0;
						//	CDialog::OnCancel ();
						//	return 1;
				}
			}
		}

		if (!m_delphotos.IsEmpty())
		{
			m_delphotos.TrimLeft(";");
			m_delphotos.TrimRight(";");
			m_delphotos = ";" + m_delphotos;
			m_delphotos += ";";
			for (int i = m_patharray1.GetSize() - 1; i >= 0; i--)
			{
				CString no;
				no = m_patharray1.ElementAt(i);
				no = no.Right(no.GetLength() - no.ReverseFind('\\') - 1);
				no = no.Left(no.Find('.'));
				no = ";" + no;
				no += ";";
				if (m_delphotos.Find(no) != -1)
				{
					no = m_patharray1.ElementAt(i);
					m_patharray1.RemoveAt(i);
#if JEFF_TEST_ON
					if(PathFileExists(no))
						m_patharray4.Add(no);
#else
					m_patharray4.Add(no);
#endif
				}
			}
		}

		if (m_pInputArray)
		{
			for (int i = 0; i < m_pInputArray->GetSize(); i += 2)
			{
				for (int j = 0; j < m_List2.GetItemCount(); j++)
				{
					if (m_pInputArray->ElementAt(i) == m_List2.GetItemText(j, 0))
					{
						CString name = m_pInputArray->ElementAt(i + 1);
						int pos = name.Find("$");
						if (pos != 0)continue;
						name.Delete(0, 1);
						pos = name.Find(".");
						while (pos != -1)
						{
							if (CheckOK(name.Left(pos)))
							{
								CString str = m_noarray.ElementAt(j);
								CString temp = name.Left(pos);
								temp = "," + temp + ",";
								if (str.Find(temp) == -1)
								{
									str += name.Left(pos);
									str.TrimLeft(","); str = "," + str + ",";
									m_noarray.SetAt(j, str);
									str.TrimLeft(",");
									str.TrimRight(",");
									m_List2.SetItemText(j, 4, str);
								}
							}
							name = name.Right(name.GetLength() - pos - 1);
							pos = name.Find(".");
						}
						if (CheckOK(name))
						{
							CString str = m_noarray.ElementAt(j);
							CString temp = name;
							temp = "," + temp + ",";
							if (str.Find(temp) == -1)
							{
								str += name;
								str.TrimLeft(","); str = "," + str + ",";
								m_noarray.SetAt(j, str);
								str.TrimLeft(",");
								str.TrimRight(",");
								m_List2.SetItemText(j, 4, str);
							}
						}
					}
				}
				for (j = 0; j < m_List3.GetItemCount(); j++)
				{
					if (m_pInputArray->ElementAt(i) == m_List3.GetItemText(j, 0))
					{
						CString name = m_pInputArray->ElementAt(i + 1);
						int pos = name.Find("$");
						if (pos != 0)continue;
						name.Delete(0, 1);
						pos = name.Find(".");
						while (pos != -1)
						{
							if (CheckOK(name.Left(pos)))
							{
								CString str = m_no2array.ElementAt(j);
								CString temp = name.Left(pos);
								temp = "," + temp + ",";
								if (str.Find(temp) == -1)
								{
									str += name.Left(pos);
									str.TrimLeft(","); str = "," + str + ",";
									m_no2array.SetAt(j, str);
									str.TrimLeft(",");
									str.TrimRight(",");
#ifdef LKAY_VERSION
									m_List3.SetItemText (j, 7, str);
#else
									m_List3.SetItemText(j, 5, str);
#endif
								}
							}
							name = name.Right(name.GetLength() - pos - 1);
							pos = name.Find(".");
						}
						if (CheckOK(name))
						{
							CString str = m_no2array.ElementAt(j);
							CString temp = name;
							temp = "," + temp + ",";
							if (str.Find(temp) == -1)
							{
								str += name;
								str.TrimLeft(","); str = "," + str + ",";
								m_no2array.SetAt(j, str);
								str.TrimLeft(",");
								str.TrimRight(",");
#ifdef LKAY_VERSION
								m_List3.SetItemText (j, 7, str);
#else
								m_List3.SetItemText(j, 5, str);
#endif
							}
						}
					}
				}
			}
		}
	}
	else
	{
		GetData2();
		if (m_checkstatus != "�")
		{
			if (atoi(g_cominfoarray.ElementAt(0).ElementAt(85)) && IsHasRights2new(20) == 0)
			{
				Login2 dlg;
				if (dlg.DoModal() != IDOK)
				{
					MyBmpButton2 *btn = ((MyBmpButton2*)m_picarray.ElementAt(4));
					btn->m_bmpdisable = btn->m_bmp->Clone();

					Graphics graph(btn->m_bmpdisable);
					CPoint pt1, pt2, pt3;
					pt1.x = 0;
					pt1.y = 0;
					pt2.x = btn->m_bmp->GetWidth();
					pt2.y = 0;
					pt3.x = 0;
					pt3.y = btn->m_bmp->GetHeight();
					Point destinationPoints[] = {
						Point(pt1.x, pt1.y),   // destination for upper-left point of original
						Point(pt2.x, pt2.y),  // destination for upper-right point of original
						Point(pt3.x, pt3.y) };  // destination for lower-left point of original
						ColorMatrix colorMatrix = \
						{0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
						0.0f, 0.0f, 0.0f, 0.0f, 1.0f};

						ImageAttributes imageAtt;
						imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
						graph.DrawImage(btn->m_bmp,
							destinationPoints,
							3,
							0,
							0,
							btn->m_bmp->GetWidth(),
							btn->m_bmp->GetHeight(),
							UnitPixel,
							&imageAtt);
						btn->EnableWindow(0);
						m_bCanSave = 0;
						//		CDialog::OnCancel ();
						//		return 1;
				}
				else if (IsHasRightsnew2(20, dlg.m_rights) == 0)
				{
					MyBmpButton2 *btn = ((MyBmpButton2*)m_picarray.ElementAt(4));
					btn->m_bmpdisable = btn->m_bmp->Clone();

					Graphics graph(btn->m_bmpdisable);
					CPoint pt1, pt2, pt3;
					pt1.x = 0;
					pt1.y = 0;
					pt2.x = btn->m_bmp->GetWidth();
					pt2.y = 0;
					pt3.x = 0;
					pt3.y = btn->m_bmp->GetHeight();
					Point destinationPoints[] = {
						Point(pt1.x, pt1.y),   // destination for upper-left point of original
						Point(pt2.x, pt2.y),  // destination for upper-right point of original
						Point(pt3.x, pt3.y) };  // destination for lower-left point of original
						ColorMatrix colorMatrix = \
						{0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.33f, 0.33f, 0.33f, 0.0f, 0.0f,
						0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
						0.0f, 0.0f, 0.0f, 0.0f, 1.0f};

						ImageAttributes imageAtt;
						imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
						graph.DrawImage(btn->m_bmp,
							destinationPoints,
							3,
							0,
							0,
							btn->m_bmp->GetWidth(),
							btn->m_bmp->GetHeight(),
							UnitPixel,
							&imageAtt);
						btn->EnableWindow(0); m_bCanSave = 0;
						//	CDialog::OnCancel ();
						//	return 1;
				}
			}
		}

		if (!m_delphotos.IsEmpty())		// add by Jeff:�ڼ���ʱ,�Ƚ���ɾ������Ƭ�����鿴����Ƭ��ɾ��;
		{
			m_delphotos.TrimLeft(";");
			m_delphotos.TrimRight(";");
			m_delphotos = ";" + m_delphotos;
			m_delphotos += ";";
			for (int i = m_patharray1.GetSize() - 1; i >= 0; i--)
			{
				CString no;
				no = m_patharray1.ElementAt(i);
				no = no.Right(no.GetLength() - no.ReverseFind('\\') - 1);
				no = no.Left(no.Find('.'));
				no = ";" + no;
				no += ";";
				if (m_delphotos.Find(no) != -1)
				{
					no = m_patharray1.ElementAt(i);
					m_patharray1.RemoveAt(i);
#if JEFF_TEST_ON
					if (PathFileExists(no))
						m_patharray4.Add(no);
#else
					m_patharray4.Add(no);
#endif
				}
			}
		}
	}

	LoadPhotos();//�ڽ�������ʾͼƬ;

	if (atoi(g_cominfoarray.ElementAt(0).ElementAt(95)) || g_cominfoarray.ElementAt(0).ElementAt(95) == "")
	{
		int timer1 = atoi(g_cominfoarray.ElementAt(0).ElementAt(96));
		m_timer = atoi(g_cominfoarray.ElementAt(0).ElementAt(97));
		if (timer1 == 0)timer1 = 60;
		if (m_timer == 0)m_timer = 20;
		SetTimer(1, timer1 * 60000, NULL);
	}
	return false;  
}

BOOL ChoosePhotoSkin2::InitializeUI()
{
	g_bInSkin = 1;
	m_ticks = ::GetTickCount();
	if (g_cursorhand == NULL)
		g_cursorhand = AfxGetApp()->LoadCursor(IDC_CURSORHAND);
	BYTE *pData = NULL;
	BYTE *pDataBegin;

	//printf("Jeff:loadLia·��:%s\n\n",g_mainpath+"\\skin\\"+m_liapath);//Jeff Printf;
	if (!LoadLia(g_mainpath + "\\skin\\" + m_liapath, &pData, &pDataBegin, &m_pBk, m_hWnd))
	{
		EndDialog(0);
		return false;
	}

	//printf("Jeff:g_resdata2.nPicCount=%d\n\n",g_resdata2.nPicCount); // Jeff Printf,���nPicCount����һֱ��15;
	for (int i = 0; i < g_resdata2.nPicCount; i++)
	{
		g_resdata2.rect[i].left *= g_fscalex;
		g_resdata2.rect[i].right *= g_fscalex;
		g_resdata2.rect[i].top *= g_fscaley;
		g_resdata2.rect[i].bottom *= g_fscaley;

		if (i == 8)
			g_resdata2.rect[i] = g_resdata2.rect[2];
		else if (i == 9)
			g_resdata2.rect[i] = g_resdata2.rect[3];
		else if (i == 10)
			g_resdata2.rect[i] = g_resdata2.rect[1];
		if (g_resdata2.nPicBmpCount[i])
		{
			MyBmpButton2 *pic = new MyBmpButton2;
			m_picarray.Add((DWORD)pic);
			CRect rc = g_resdata2.rect[i];
			CString str;
			str.Format(_T("%d"), i + 1);
			pic->Create(str, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, i + 100);
			pic->m_bmpcount = g_resdata2.nPicBmpCount[i];
			pic->ReadBmp(&pData, NULL, this);
#ifdef SZWNS_VERSION
			if(i==3 && m_mode2==0)
			{
				Image *img=NULL;
				LoadImageFromRes(&img, MAKEINTRESOURCE(IDR_JPG6), _T("JPG") );
				delete pic->m_bmp;
				pic->m_bmp=img->Clone();
				delete img;

				img=NULL;
				LoadImageFromRes(&img, MAKEINTRESOURCE(IDR_JPG7), _T("JPG") );
				delete pic->m_bmpfocus;
				pic->m_bmpfocus=img->Clone();
				delete img;

				img=NULL;
				LoadImageFromRes(&img, MAKEINTRESOURCE(IDR_JPG8), _T("JPG") );
				delete pic->m_bmpfocused;
				pic->m_bmpfocused=img->Clone();
				delete img;
			}
#endif
		}
		else
			m_picarray.Add(NULL);
		m_rcarray.Add(g_resdata2.rect[i]);
	}
	delete[]pDataBegin;


	if (m_Runingmode)//�����
	{
		m_bHide = 0;

		//		printf("Jeff:g_cominfoarray.ElementAt(0).ElementAt(86)=%s\n\n",g_cominfoarray.ElementAt(0).ElementAt(86)); // Jeff Printf;
		if (atoi(g_cominfoarray.ElementAt(0).ElementAt(86)))
		{
			((MyBmpButton2*)m_picarray.ElementAt(3))->ShowWindow(SW_HIDE);
			CRect rc, rc2;
			((MyBmpButton2*)m_picarray.ElementAt(3))->GetWindowRect(rc);
			((MyBmpButton2*)m_picarray.ElementAt(1))->GetWindowRect(rc2);
			int dtx = rc.right - rc2.right;
			ScreenToClient(rc2);
			rc2.left += dtx;
			rc2.right += dtx;
			((MyBmpButton2*)m_picarray.ElementAt(1))->MoveWindow(rc2);
			((MyBmpButton2*)m_picarray.ElementAt(0))->GetWindowRect(rc2);
			ScreenToClient(rc2);
			rc2.left += dtx;
			rc2.right += dtx;
			((MyBmpButton2*)m_picarray.ElementAt(0))->MoveWindow(rc2);
		}

		CRect rc, rc2;
		((MyBmpButton2*)m_picarray.ElementAt(5))->GetWindowRect(rc);
		((MyBmpButton2*)m_picarray.ElementAt(4))->GetWindowRect(rc2);
		int dtx = rc.right - rc2.right;
		rc2 = rc;
		//	if(atoi(g_cominfoarray.ElementAt(0).ElementAt(86))==0)
		{
			float scale = 0.9;
			dtx *= scale;
			int wid = rc2.Width()*scale;
			int hei = rc2.Height()*scale;
			int dty = rc2.Height() - hei;
			dty /= 2;
			rc2.left = rc2.right - wid;
			rc2.top += dty;
			rc2.bottom = rc2.top + hei;
		}

		ScreenToClient(rc2);
		((MyBmpButton2*)m_picarray.ElementAt(5))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(4))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(14))->MoveWindow(rc2);

		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(2))->MoveWindow(rc2);
		if (atoi(g_cominfoarray.ElementAt(0).ElementAt(86)) == 0)
		{
			rc2.left -= dtx;
			rc2.right -= dtx;
			((MyBmpButton2*)m_picarray.ElementAt(3))->MoveWindow(rc2);
		}

		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(1))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(0))->MoveWindow(rc2);

		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(8))->MoveWindow(rc2);

		((MyBmpButton2*)m_picarray.ElementAt(11))->ShowWindow(SW_HIDE);
	}
	else
	{
		if (atoi(g_cominfoarray.ElementAt(0).ElementAt(86)))
		{
			((MyBmpButton2*)m_picarray.ElementAt(3))->ShowWindow(SW_HIDE);
			CRect rc, rc2;
			((MyBmpButton2*)m_picarray.ElementAt(3))->GetWindowRect(rc);
			((MyBmpButton2*)m_picarray.ElementAt(1))->GetWindowRect(rc2);
			int dtx = rc.right - rc2.right;
			ScreenToClient(rc2);
			rc2.left += dtx;
			rc2.right += dtx;
			((MyBmpButton2*)m_picarray.ElementAt(1))->MoveWindow(rc2);
			((MyBmpButton2*)m_picarray.ElementAt(0))->GetWindowRect(rc2);
			ScreenToClient(rc2);
			rc2.left += dtx;
			rc2.right += dtx;
			((MyBmpButton2*)m_picarray.ElementAt(0))->MoveWindow(rc2);
		}
	}

	if (1)//m_mode2==0)
	{
		((MyBmpButton2*)m_picarray.ElementAt(7))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(8))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(9))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(10))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(11))->ShowWindow(SW_HIDE);
	}
	else
	{
		((MyBmpButton2*)m_picarray.ElementAt(7))->EnableWindow(0);
		((MyBmpButton2*)m_picarray.ElementAt(0))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(1))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(2))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(3))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(11))->ShowWindow(SW_HIDE);

		if (IsHasRights2new(37) == 0)
		{
			((MyBmpButton2*)m_picarray.ElementAt(8))->ShowWindow(SW_HIDE);
			((MyBmpButton2*)m_picarray.ElementAt(9))->ShowWindow(SW_HIDE);
		}
	}
	if (m_Runingmode)
	{
		((MyBmpButton2*)m_picarray.ElementAt(8))->ShowWindow(SW_SHOW);
		//	((MyBmpButton2*)m_picarray.ElementAt (8))->SetPushDown (1);
		((MyBmpButton2*)m_picarray.ElementAt(12))->ShowWindow(SW_HIDE);
		((MyBmpButton2*)m_picarray.ElementAt(13))->ShowWindow(SW_HIDE);
	}
	else//�ư�ťλ��
	{
		CRect rc, rc2;
		((MyBmpButton2*)m_picarray.ElementAt(5))->GetWindowRect(rc);
		((MyBmpButton2*)m_picarray.ElementAt(4))->GetWindowRect(rc2);
		int dtx = rc.right - rc2.right;
		rc2 = rc;
		//	if(atoi(g_cominfoarray.ElementAt(0).ElementAt(86))==0)
		{
			float scale = 0.9;
			dtx *= scale;
			int wid = rc2.Width()*scale;
			int hei = rc2.Height()*scale;
			int dty = rc2.Height() - hei;
			dty /= 2;
			rc2.left = rc2.right - wid;
			rc2.top += dty;
			rc2.bottom = rc2.top + hei;
		}

		ScreenToClient(rc2);
		((MyBmpButton2*)m_picarray.ElementAt(5))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(4))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(14))->MoveWindow(rc2);


		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(2))->MoveWindow(rc2);
		if (atoi(g_cominfoarray.ElementAt(0).ElementAt(86)) == 0)
		{
			rc2.left -= dtx;
			rc2.right -= dtx;
			((MyBmpButton2*)m_picarray.ElementAt(3))->MoveWindow(rc2);
		}

		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(12))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(13))->MoveWindow(rc2);

		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(1))->MoveWindow(rc2);
		rc2.left -= dtx;
		rc2.right -= dtx;
		((MyBmpButton2*)m_picarray.ElementAt(0))->MoveWindow(rc2);
	}

#ifndef MNLS_VERSION
	((MyBmpButton2*)m_picarray.ElementAt(7))->ShowWindow(SW_HIDE);
	((MyBmpButton2*)m_picarray.ElementAt(7))->EnableWindow(0);
	Graphics graph(m_pBk);
	Image *img = NULL;
	if (m_Runingmode == 0)
		::LoadImageFromBuf(&img, g_mainpath + "\\ͼƬ\\����-ѡƬ.jpg");
	else
		::LoadImageFromBuf(&img, g_mainpath + "\\ͼƬ\\����-�����.jpg");
	if (img)
	{
		if (img->GetWidth() == 2000)
		{
			graph.SetSmoothingMode(SmoothingModeHighQuality);
			graph.DrawImage(img, 0, 0);
		}
		delete img;
	}
#endif

	CRect listrc = m_rcarray.ElementAt(6);
	CRect rc;
	GetClientRect(rc);
	rc.top = listrc.top;
	m_List1.MoveWindow(rc);

	CString path, str;
	if (m_Runingmode)
	{
		m_path = g_path3 + "\\";
		m_path += m_strOrderNumber;
		m_path += "\\";
		//		printf("Jeff:m_path=%s\n\n",m_path); // Jeff Printf;
	}

	if (m_Runingmode)//�����
	{
		GetPhotos();
	}
	else
	{
		IsGrowthTx growthtxdlg;
		growthtxdlg.m_mode = 1;
		growthtxdlg.m_strOrderNumber = m_strOrderNumber;
		growthtxdlg.DoModal();
		m_bGrowthTX = growthtxdlg.m_bGrowthTx;
		m_seltxname = growthtxdlg.m_seltxname;
		/*if(!growthtxdlg.m_seltxname.IsEmpty ())
		{
		if(growthtxdlg.m_seltxname!="ȫ��")
		{
		path+=growthtxdlg.m_seltxname;
		path+="\\";
		}
		}*/

		if (CheckHC())
		{
			m_bFromLocal = 1;
			char path[MAX_PATH];
			::GetSystemDirectory(path, MAX_PATH);
			CString sysdir = path;
			sysdir += "\\lyfz";
			::CreateDirectory(sysdir, NULL);
			sysdir += "\\";
			sysdir += m_strOrderNumber;
			using namespace helper_coffs;
			ffsco o;
			o.dirs(1);
			o.find(LPCSTR(sysdir), LPCSTR("*.jpg"));
			ffsco::typeT coo;
			ffsco::typeT::iterator it;
			coo = o.co_file();
			for (it = coo.begin(); coo.end() != it; it++)
			{
				str = (*it).c_str();
				//				printf("Jeff:str=%s\n\n",str);// Jeff Printf
				if (str.GetAt(str.ReverseFind('\\') + 1) != 's' && str.GetAt(str.ReverseFind('\\') + 1) != 'm')
				{
					m_patharray1.Add(str);
				}
			}
		}
		if (m_patharray1.GetSize() == 0)
		{
			if (IsPhoto2Exist())
			{
				SelBrunDevice dlg;
				dlg.m_mode = 1;
				if (dlg.DoModal() == IDOK)
					m_nChoosePhotoType = dlg.m_sel;
				else
					m_nChoosePhotoType = 0;
				//m_nChoosePhotoType=0 ԭƬ+��Ƭ 1����Ƭ 2��ԭƬ
			}
			else
				AfxMessageBox("��ܰ��ʾ��\r\nδ�ҵ�����Ƭ����ʹ��ԭƬѡƬ", MB_ICONINFORMATION);

			{
				CString path2;
				m_path = g_path1 + "\\";
				m_path += m_strOrderNumber;
				m_path += "\\";
				if (m_seltxname != "" && m_seltxname != "ȫ��")
				{
					m_path += m_seltxname; m_path += "\\";
				}
				if (m_nChoosePhotoType == 1)
				{
					m_path = g_path2 + "\\";
					m_path += m_strOrderNumber;
					m_path += "\\";
				}
				CString filename;
				using namespace helper_coffs;
				ffsco o;
				o.dirs(1);
				o.find(LPCSTR(m_path), LPCSTR("*.*"));
				ffsco::typeT coo;
				ffsco::typeT::iterator it;
				coo = o.co_file();
				for (it = coo.begin(); coo.end() != it; it++)
				{
					path = (*it).c_str();
					if (path.GetAt(path.ReverseFind('\\') + 1) != 's' && path.GetAt(path.ReverseFind('\\') + 1) != 'm')
					{
						path.MakeLower();

						filename = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
						if (filename.Find(".") != -1)
							filename = filename.Left(filename.Find("."));
						if (!myisdigit(filename))continue;

						if (m_nChoosePhotoType == 1)
						{
#if JEFF_TEST_ON
							if (PathFileExists(path))
								m_patharray1.Add(path);
#else
							m_patharray1.Add(path);
#endif
						}
						else
						{
							path2 = path;

							if (m_nChoosePhotoType == 0)
								path2.Replace("�ͻ�ԭƬ", "�޺õ�Ƭ");
							if (m_bGrowthTX == 0)
							{
								int pos = path2.Find(m_strOrderNumber);
								pos += m_strOrderNumber.GetLength();
								int pos2 = path2.ReverseFind('\\');
								path2 = path2.Left(pos) + path2.Right(path2.GetLength() - pos2);
							}

							if (m_nChoosePhotoType == 0 && ::PathFileExists(path2))
							{
								m_patharray1.Add(path2);
							}
							else
							{
								path2.Replace(".raw", ".jpg");
								if (::PathFileExists(path2))
								{
									m_patharray1.Add(path2); continue;
								}
								path2.Replace(".nef", ".jpg");
								if (PathFileExists(path2))
								{
									m_patharray1.Add(path2); continue;
								}
								path2.Replace(".cr2", ".jpg");
								if (PathFileExists(path2))
								{
									m_patharray1.Add(path2); 
									continue;
								}
								else
								{
									if (path.Right(3) != "jpg")
										continue;
#if JEFF_TEST_ON
									if (PathFileExists(path))
										m_patharray1.Add(path);
#else
									m_patharray1.Add(path);
#endif
								}
							}
						}
					}
				}
			}

			//	if(0)
			{//�����޺õ�Ч��
				CString path2;
				path2 = g_path2 + "\\";
				path2 += m_strOrderNumber;
				path2 += "\\";
				using namespace helper_coffs;
				ffsco o;
				o.dirs(0);
				o.find(LPCSTR(path2), LPCSTR("*.jpg"));
				ffsco::typeT coo;
				ffsco::typeT::iterator it;
				coo = o.co_file();
				for (it = coo.begin();
					coo.end() != it;
					it++)
				{
					path = (*it).c_str();
					if (path.GetAt(path.ReverseFind('\\') + 1) != 's' && path.GetAt(path.ReverseFind('\\') + 1) != 'm')
					{
						path.MakeLower();
						path2 = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
						if (path2.Find("-") != -1)
						{
#if JEFF_TEST_ON
							if (PathFileExists(path))
								m_patharray1.Add(path);
#else
							m_patharray1.Add(path);
#endif
						}
					}
				}
			}
		}
		if (m_patharray1.GetSize() && atoi(g_cominfoarray.ElementAt(0).ElementAt(61)))
		{
			int size = m_patharray1.GetSize() - 1;
			CString sTemp;
			int nPos;
			for (int i = 0; i < size; i++)
			{
				nPos = rand() % (size - i);
				sTemp = m_patharray1.ElementAt(size - i);
				m_patharray1.SetAt(size - i, m_patharray1.ElementAt(nPos));
				m_patharray1.SetAt(nPos, sTemp);
			}
		}
	}

	m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
	m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);

	m_List2.InitStyle();
	m_List2.InsertColumn(0, _T("���"), LVCFMT_LEFT, 45);
	m_List2.InsertColumn(1, _T("��Ʒ����"), LVCFMT_LEFT, 150);
	m_List2.InsertColumn(2, _T("����"), LVCFMT_LEFT, 45);

	m_List3.InitStyle();
	m_List3.InsertColumn(0, _T("autoid"), LVCFMT_LEFT, 0);
	m_List3.InsertColumn(1, _T("���"), LVCFMT_LEFT, 45);
	m_List3.InsertColumn(2, _T("��Ʒ����"), LVCFMT_LEFT, 150);
	m_List3.InsertColumn(3, _T("�۸�"), LVCFMT_LEFT, 45);
	m_List3.InsertColumn(4, _T("����"), LVCFMT_LEFT, 45);
#ifdef LKAY_VERSION
	m_List3.InsertColumn(5,_T("P��"),LVCFMT_LEFT,55);
	m_List3.InsertColumn(6,_T("����"),LVCFMT_LEFT,55);
	m_List3.InsertColumn(7,_T("��Ƭ���"),LVCFMT_LEFT,365);
#else
	m_List3.InsertColumn(5, _T("��Ƭ���"), LVCFMT_LEFT, 365);
#endif	
}

void ChoosePhotoSkin2::OnPaint()
{
	try
	{
		CPaintDC dc(this); // device context for painting
		// TODO: Add your message handler code here
		if (m_pBk == NULL)
		{
			return;
		}
		CRect rc;
		GetClientRect(rc);
		Graphics graph(dc.GetSafeHdc());
		Rect destinationRect(0, 0, rc.Width(), rc.Height());
		int width = m_pBk->GetWidth();
		int height = m_pBk->GetHeight();
		graph.SetSmoothingMode(SmoothingModeHighQuality);
		graph.DrawImage(m_pBk, destinationRect, 0, 0, width, height, UnitPixel);
		// Do not call CDialog::OnPaint() for painting messages
	}
	catch (...)
	{
	}
}

void ChoosePhotoSkin2::OnPaint2(CWnd *pWnd)
{
	try
	{
		CPaintDC dc(pWnd); // device context for painting
		// TODO: Add your message handler code here

		CRect rc;
		GetClientRect(rc);
		if (m_pBk == NULL)
		{
			return;
		}
		int width = m_pBk->GetWidth();
		int height = m_pBk->GetHeight();
		Graphics graph(dc.GetSafeHdc());
		Rect destinationRect(0, 0, rc.Width(), rc.Height());
		graph.SetSmoothingMode(SmoothingModeHighQuality);
		graph.DrawImage(m_pBk, destinationRect, 0, 0, width, height, UnitPixel);
	}
	catch (...)
	{
	}
}

void ChoosePhotoSkin2::OnDestroy()
{
	try
	{
		TerminateThread();
		if (m_pBk)delete m_pBk;
		MyBmpButton2 *pic = NULL;
		for (int i = 0; i < m_picarray.GetSize(); i++)
		{
			pic = (MyBmpButton2*)m_picarray.ElementAt(i);
			if (pic)
			{
				pic->DestroyWindow();
				delete pic;
			}
		}
		m_picarray.RemoveAll();
		if (m_selphotownd.GetSafeHwnd())
		{
			m_selphotownd.DestroyWindow();
		}
		if (m_selphotownd2.GetSafeHwnd())
		{
			m_selphotownd2.DestroyWindow();
		}

		CDialog::OnDestroy();
	}
	catch (...)
	{
	}
}

BOOL ChoosePhotoSkin2::OnEraseBkgnd(CDC* pDC)
{
	return 1;
}

void ChoosePhotoSkin2::SetLiaPath(CString path)
{
	m_liapath = path;
}


BEGIN_EVENTSINK_MAP(ChoosePhotoSkin2, CDialog)
	ON_EVENT(ChoosePhotoSkin2, 100, 150 /* FSCommand */, OnFSCommandShockwaveflash1, VTS_BSTR VTS_BSTR)
END_EVENTSINK_MAP()

void ChoosePhotoSkin2::OnFSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args)
{
}

//extern void LoadImageFromFile(Image **img, CString path);
unsigned __stdcall LoadThumbNail3(LPVOID lpParam)
{
	ChoosePhotoSkin2 *pDlg = (ChoosePhotoSkin2*)lpParam;
	CListCtrl   *ListCtrl = &pDlg->m_List1;

	try
	{
		CImageList* pImgList = &pDlg->m_ImageListThumb;

		// reset our image list
		for (int i = 0; i < pImgList->GetImageCount(); i++)
			pImgList->Remove(i);

		// remove all items from list view
		ListCtrl->DeleteAllItems();

		pImgList->SetImageCount(pDlg->m_vFileName.size());

		//	TCHAR path[MAX_PATH];
		vector<CString>::iterator iter;

		// Set redraw to FALSE to avoid flickering during adding new items
		ListCtrl->SetRedraw(FALSE);
		int nIndex = 0;
		CString str, spath;

		if (pDlg->m_Runingmode == 0) // ѡƬ;
		{
			for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
			{
				str = *iter;
				str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
				str = str.Left(str.Find('.'));
				str += pDlg->GetSelName(str);
				ListCtrl->InsertItem(nIndex, str, nIndex);
			}
		}
		else // �����;
		{
			for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
			{
				str = *iter;
				spath.Empty();
				if (str.Left(str.ReverseFind('\\') + 1) != pDlg->m_path)
				{
					spath = str.Left(str.ReverseFind('\\') + 1);
					spath = spath.Right(spath.GetLength() - pDlg->m_path.GetLength());
				}

				str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);


				if (str.Find("delgabook") != -1)
				{
					str.TrimRight("\\");
					str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
					str.Replace("delgabook", "Flash");
					ListCtrl->InsertItem(nIndex, str, nIndex);
				}
				else
				{
					str = spath + str.Left(str.GetLength() - 4);
					CString temp = pDlg->GetSelName(str);
					ListCtrl->InsertItem(nIndex, str + temp, nIndex);
				}
			}
		}

		ListCtrl->SetRedraw(TRUE);
		ListCtrl->Invalidate();


		const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;

		int XDest, YDest, nDestWidth, nDestHeight;
		nIndex = 0;

		SolidBrush whitebrush(Color(255, 255, 255, 255));
		Image *pHideImg = NULL;

		Bitmap *pNULLBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
		Graphics graph2(pNULLBmp);
		graph2.Clear(Color(255, 0, 0, 0));

		for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
		{
			// Load Image File 
			Image *image = NULL;
			Bitmap *pBmp = NULL;

			str = *iter;
			spath = str.Left(str.ReverseFind('\\') + 1);
			spath += "s";
			spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);

			//	if(pDlg->m_mode2==0 && pDlg->m_bHide && pHideImg==NULL)
			if (pDlg->m_bHide && pHideImg == NULL)
			{
				LoadImageFromRes(&pHideImg, MAKEINTRESOURCE(IDR_JPG5), _T("JPG"));
			}

			BOOL bNullimg = 0;
			if (pHideImg == NULL)
			{
				//	if(atoi(g_cominfoarray.ElementAt(0).ElementAt(109))==0 && pDlg->m_mode2==0)
				if (0)//pDlg->m_bFromLocal && pDlg->m_mode2==0)
				{
					spath = spath.Right(spath.GetLength() - spath.ReverseFind('\\'));
					CString stemp;
					stemp = g_path2 + "\\";
					stemp += pDlg->m_strOrderNumber;
					stemp += "\\";
					stemp += spath;
					if (PathFileExists(stemp))
						spath = stemp;
					else
					{
						stemp = g_path1 + "\\";
						stemp += pDlg->m_strOrderNumber;
						stemp += "\\";
						stemp += spath;
						spath = stemp;
					}
				}

				if (PathFileExists(spath))
				{
					::LoadImageFromBuf(&image, spath);
				}
				else if (PathFileExists(str))
					::LoadImageFromBuf(&image, str);
				else
				{
					bNullimg = 1;
					image = pNULLBmp;
				}

				if (image == NULL)continue;
				if (image->GetWidth() == 0)
					continue;

				int orientation = GetOrientation(image);
				if (orientation == 8)
					image->RotateFlip(Rotate270FlipNone);
				else if (orientation == 6)
					image->RotateFlip(Rotate90FlipNone);
			}
			else
				image = pHideImg;


			// Calculate Rect to fit to canvas
			const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
			if (fImgRatio > fRatio)
			{
				nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
				XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
				YDest = 0;
				nDestHeight = THUMBNAIL_HEIGHT;
			}
			else
			{
				XDest = 0;
				nDestWidth = THUMBNAIL_WIDTH;
				nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
				YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
			}
			pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
			Graphics graph2(pBmp);
			graph2.Clear(Color(255, 192, 192, 192));

			graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);

			Graphics graph(pBmp);
			Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
			// Draw Image

			graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);

			if (pHideImg == NULL && bNullimg == 0)
				delete image;

			// Attach to Bitmap and Replace image in CImageList
			CBitmap bitmap;
			HBITMAP hbmp;
			pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
			bitmap.Attach(hbmp);
			pImgList->Replace(nIndex, &bitmap, NULL);
			delete pBmp;
			// Redraw only a current item for removing flickering and fast speed.
			ListCtrl->RedrawItems(nIndex, nIndex);
			// Release used DC and Object
		}
		delete pNULLBmp;
		if (pHideImg)delete pHideImg;
		ListCtrl->Invalidate();
		pDlg->m_bRunning = false;
		pDlg->m_bTerminate = false;
		pDlg->PostMessage(WM_USER + 200, 0, 0);
		_endthreadex(0);

		return 0;
	}
	catch (...)
	{
		ListCtrl->Invalidate();
		pDlg->m_bRunning = false;
		pDlg->m_bTerminate = false;
		pDlg->PostMessage(WM_USER + 200, 0, 0);
		_endthreadex(0);
	}
}

void ChoosePhotoSkin2::LoadThumbImages()
{
	TerminateThread();
	m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail3, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
	m_bRunning = true;
}

BOOL ChoosePhotoSkin2::TerminateThread()
{
	if (!m_bRunning)
		return TRUE;

	m_bTerminate = true;

	for (;;)
	{
		if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
			break;

		MSG msg;
		while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
		{
			if (!AfxGetApp()->PumpMessage())
				break;
		}
	}
	::CloseHandle(m_hThread);
	return TRUE;
}

//------------------------------------------------------------------
// Remark by Jeff 2014.11.03
// ������OnDblclkList1
// ����������˫���ͻس�ʱ��ͼƬ��ʾЧ��;�뺯���������ı������岻һ�£��������壡
// ������
// ���أ�
//------------------------------------------------------------------
void ChoosePhotoSkin2::OnDblclkList1()
{
	// 1.��˫���е��б����л�ȡ��Ƭ��;
	POSITION pos;
	pos = m_List1.GetFirstSelectedItemPosition();
	if (pos == NULL)
	{
		return;
	}
	int iItem = m_List1.GetNextSelectedItem(pos);
#if JEFF_TEST_OFF
	// ˫���б������Ͳ���������ѡ���,˫��ֻ��ѡ��һ������GetNextSelectedItem(pos)��pos=NULL
	// ����������������ò����Ǹ�������һ�£��������ط��õ���
#else	// ��һ����������ڴ����س���;
	CArray<int, int>posarray;
	posarray.Add(iItem);
	// ��ȡʣ�µ�ͼƬλ��;
	while (pos)
	{
		int iItem = m_List1.GetNextSelectedItem(pos);
		posarray.Add(iItem);
		if (posarray.GetSize() > 3)break;
	}
	if (posarray.GetSize() >= 2)
	{
		CStringArray *m_pPtahArray = GetCurArray();
		CComparePhoto dlg;
		dlg.m_path1 = m_pPtahArray->ElementAt(posarray.ElementAt(0));
		dlg.m_path2 = m_pPtahArray->ElementAt(posarray.ElementAt(1));

		if (posarray.GetSize() > 2)
			dlg.m_path3 = m_pPtahArray->ElementAt(posarray.ElementAt(2));
		if (posarray.GetSize() > 3)
			dlg.m_path4 = m_pPtahArray->ElementAt(posarray.ElementAt(3));
		dlg.DoModal();
		return;
	}
#endif

	if (m_Runingmode == 1)//�����
	{
		CString title = m_List1.GetItemText(iItem, 0);
		if (title.Find("Flash") != -1)
		{
			title.Replace("Flash", "delgabook");
			CString str = m_path + title + "\\delgaBook.exe";
			ShellExecute(NULL, _T("open"), str, NULL, NULL, SW_SHOWNORMAL);
			return;
		}
	}
	m_showpichwd = NULL;

	// ˫��Сͼ�鿴��ͼ;
	ShowPic22 dlg;
	if (m_Runingmode == 1)	// ==1 �����;
		dlg.m_bShowName = 1;
	dlg.m_pParent = this;
	dlg.m_pos = iItem;

	if (m_Runingmode == 0 && atoi(g_cominfoarray.ElementAt(0).ElementAt(100)))
	{
		CStringArray saCurrentImagePath;	// ��ǰ�б���Ƭ;
		CStringArray arraymsize;			// ��Ӧ��"m"��Ƭ·��;
		CStringArray *pArray = GetCurArray();
		saCurrentImagePath.Copy(*pArray);

		for (int i = 0; i < saCurrentImagePath.GetSize(); i++)
		{
			CString str = saCurrentImagePath.ElementAt(i);
			CString spath = str.Left(str.ReverseFind('\\') + 1);
			spath += "m";
			spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
			if (::PathFileExists(spath))
				arraymsize.Add(spath);
			else
				arraymsize.Add(str);
		}
		dlg.m_pPathArray = &arraymsize;
		dlg.m_pPathArrayBigsize = &saCurrentImagePath;
		dlg.DoModal();
	}
	else
	{
		dlg.m_pPathArray = GetCurArray();
		dlg.DoModal();
	}
	m_showpichwd = NULL;
}

void ChoosePhotoSkin2::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)	// ˫��ͼƬ�б���
{
	OnDblclkList1();
	*pResult = 0;
}

CString GetModifyTime2(CString path)
{
	HANDLE   hFile;
	WIN32_FIND_DATA   wfd;
	SYSTEMTIME   systime;
	FILETIME   localtime;
	CString   stime;     //���ʱ��   
	memset(&wfd, 0, sizeof(wfd));
	if ((hFile = FindFirstFile(path, &wfd)) == INVALID_HANDLE_VALUE)
		return "";
	//ok,ת��ʱ��
	FileTimeToLocalFileTime(&wfd.ftLastWriteTime, &localtime);

	FileTimeToSystemTime(&localtime, &systime);
	stime.Format("%4d%02d%02d",
		systime.wYear, systime.wMonth, systime.wDay);
	return stime;
}

BOOL ChoosePhotoSkin2::GetData()//ѡƬģʽ;
{
	m_List2.DeleteAllItems();
	m_List3.DeleteAllItems();
	m_noarray.RemoveAll();
	m_no2array.RemoveAll();
#ifdef CHILD_VERSION
	CString filter = "id='" + m_strOrderNumber + "';id='" + m_strOrderNumber + "';;id='" + m_strOrderNumber + "'";
	if (m_seltxname != "" && m_seltxname != "ȫ��")
	{
		filter = "id='" + m_strOrderNumber + "' and growthtxname='" + m_seltxname + "';id='" + m_strOrderNumber + "';;id='" + m_strOrderNumber + "'";
	}
#else
	CString filter = "id='" + m_strOrderNumber + "' and kind<>'2';id='" + m_strOrderNumber + "';;id='" + m_strOrderNumber + "'";
#endif
	g_sendhead.code[0] = 50;	// dindansp;
	g_sendhead.code[1] = 11;	// dindan
	g_sendhead.code[2] = 4;		// shangpin
	g_sendhead.code[3] = 182;	// dindansp3
	g_sendhead.tabcount = 4;
	g_sendhead.bsql = 0;

	g_pMainWnd->ProcessChatMessageRequest2(filter); 
	if (g_bSendOK == 0)return 0;

	CArray<CStringArray, CStringArray>sparray;
	DataToArray(&sparray, &g_List1array, &m_sparray, &oldsparray);

	m_patharray2.RemoveAll();

	CString str, kind;
	int nchoosezs = 0;
	int list2pos = 0;
	int list3pos = 0;

	CString savepath;
	savepath.Format("%s\\%s.dat", g_mainpath, m_strOrderNumber);
	CString stm1 = GetModifyTime2(savepath);
	CTime tm1 = CTime::GetCurrentTime();
	tm1 -= CTimeSpan(2, 0, 0, 0);
	CString stm2 = tm1.Format("%Y%m%d");
	BOOL bLoadHistory = 0;
	if (PathFileExists(savepath) && stm1 > stm2)
	{
		if (AfxMessageBox("���ѣ����������\r\n�ϴ�ѡƬδ�����˳�, �Ƿ�ԭ���ϴ�ѡƬ״̬?", MB_YESNO | MB_ICONINFORMATION) == IDYES)
			bLoadHistory = 1;
	}
	if (bLoadHistory)
	{
		CArray<CStringArray, CStringArray>List1array;
		CFile fp;
		fp.Open(savepath, CFile::modeRead);
		DWORD nMessageLen = fp.GetLength();
		BYTE *szChatMessage = new BYTE[nMessageLen];
		fp.Read(szChatMessage, nMessageLen);
		fp.Close();
		int count;
		memcpy(&count, szChatMessage + (nMessageLen - sizeof(int)), sizeof(int));
		CMemFile memfile;
		memfile.Attach(szChatMessage, nMessageLen);
		CArchive ar(&memfile, CArchive::load);
		List1array.SetSize(count);
		for (int i = 0; i < List1array.GetSize(); i++)
		{
			List1array.ElementAt(i).Serialize(ar);
		}
		ar.Close();
		memfile.Detach();
		delete[]szChatMessage;

		list2pos = 0;
		list3pos = 0;
		for (i = 0; i < List1array.GetSize(); i++)
		{
			if (0)//List1array.ElementAt (i).GetSize ()==6)
			{
				kind = "0";
				m_List2.InsertItem(list2pos, List1array.ElementAt(i).ElementAt(1));
				m_List2.SetItemText(list2pos, 1, List1array.ElementAt(i).ElementAt(2));
				m_List2.SetItemText(list2pos, 2, List1array.ElementAt(i).ElementAt(3));
				m_List2.SetItemText(list2pos, 3, List1array.ElementAt(i).ElementAt(4));
				m_List2.SetItemText(list2pos, 4, List1array.ElementAt(i).ElementAt(5));
				str = List1array.ElementAt(i).ElementAt(5);
				list2pos++;

			}
			else
			{
				kind = "4";
				m_List3.InsertItem(list3pos, List1array.ElementAt(i).ElementAt(1));
				m_List3.SetItemText(list3pos, 1, List1array.ElementAt(i).ElementAt(2));
				m_List3.SetItemText(list3pos, 2, List1array.ElementAt(i).ElementAt(3));
				m_List3.SetItemText(list3pos, 3, List1array.ElementAt(i).ElementAt(4));
				m_List3.SetItemText(list3pos, 4, List1array.ElementAt(i).ElementAt(5));
				m_List3.SetItemText(list3pos, 5, List1array.ElementAt(i).ElementAt(6));
#ifdef LKAY_VERSION
				m_List3.SetItemText(list3pos, 6, List1array.ElementAt (i).ElementAt (7));
				m_List3.SetItemText(list3pos, 7, List1array.ElementAt (i).ElementAt (8));
				str=List1array.ElementAt (i).ElementAt (8);
#else
				str = List1array.ElementAt(i).ElementAt(6);
#endif
				list3pos++;
			}

			nchoosezs += GetZS(str);
			GetPath(str);

			if (!str.IsEmpty())
				str = "," + str + ",";
			str.MakeLower();
			if (kind == "4")
				m_no2array.Add(str);
			else
				m_noarray.Add(str);
		}
	}
	else
	{
		for (int i = 0; i < sparray.GetSize(); i++)
		{
			kind = "4";//sparray.ElementAt (i).ElementAt (4);
			if (kind == "4")
			{
				m_List3.InsertItem(list3pos, sparray.ElementAt(i).ElementAt(7));
				m_List3.SetItemText(list3pos, 1, sparray.ElementAt(i).ElementAt(1));
				m_List3.SetItemText(list3pos, 2, sparray.ElementAt(i).ElementAt(5));
				m_List3.SetItemText(list3pos, 3, sparray.ElementAt(i).ElementAt(2));
				m_List3.SetItemText(list3pos, 4, sparray.ElementAt(i).ElementAt(3));
#ifdef LKAY_VERSION
				m_List3.SetItemText(list3pos, 5, sparray.ElementAt (i).ElementAt (9));
				m_List3.SetItemText(list3pos, 6, sparray.ElementAt (i).ElementAt (10));
				m_List3.SetItemText(list3pos, 7, sparray.ElementAt (i).ElementAt (6));
#else
				m_List3.SetItemText(list3pos, 5, sparray.ElementAt(i).ElementAt(6));
#endif
				list3pos++;
			}
			else
			{
				m_List2.InsertItem(list2pos, sparray.ElementAt(i).ElementAt(7));
				m_List2.SetItemText(list2pos, 1, sparray.ElementAt(i).ElementAt(1));
				m_List2.SetItemText(list2pos, 2, sparray.ElementAt(i).ElementAt(5));
				m_List2.SetItemText(list2pos, 3, sparray.ElementAt(i).ElementAt(3));
				m_List2.SetItemText(list2pos, 4, sparray.ElementAt(i).ElementAt(6));

				list2pos++;
			}

			str = sparray.ElementAt(i).ElementAt(6);
			str.MakeLower();
			nchoosezs += GetZS(str);
			GetPath(str);
			if (!str.IsEmpty())
				str = "," + str + ",";
			if (kind == "4")
				m_no2array.Add(str);
			else
				m_noarray.Add(str);
		}

		CheckForAlbum();
		CheckForDisk();
	}


	if (g_List1array.GetSize())
	{
		m_name1 = g_List1array.ElementAt(0).ElementAt(4);
		m_name2 = g_List1array.ElementAt(0).ElementAt(5);

		m_phone1 = g_List1array.ElementAt(0).ElementAt(61);
		m_phone2 = g_List1array.ElementAt(0).ElementAt(62);

		if (!m_name1.IsEmpty())
			m_name = m_name1 + ",";
		m_name += m_name2;
		m_name.TrimRight(",");


		m_waiter3 = g_user.name;
		m_taoxizs = g_List1array.ElementAt(0).ElementAt(9);
		m_time5 = g_List1array.ElementAt(0).ElementAt(22);
		m_takezs = g_List1array.ElementAt(0).ElementAt(23);
		m_choosezs = g_List1array.ElementAt(0).ElementAt(24);
		m_money3 = g_List1array.ElementAt(0).ElementAt(3);
		m_oldmoney3 = m_money3;
		m_bz3 = g_List1array.ElementAt(0).ElementAt(39);
		m_bz4 = g_List1array.ElementAt(0).ElementAt(75);

		m_urgent = g_List1array.ElementAt(0).ElementAt(40);
		m_delphotos = g_List1array.ElementAt(0).ElementAt(53);		// Jeff��ʼѡƬʱ����ȡdindan�����ֶ�delphotos.��ȡ������
		m_time6 = g_List1array.ElementAt(0).ElementAt(48);

		m_time5old = m_time5;
		m_time6old = m_time6;

		taoxiname = g_List1array.ElementAt(0).ElementAt(7);
		m_taoxijiage = g_List1array.ElementAt(0).ElementAt(8);
		m_waiter1 = g_List1array.ElementAt(0).ElementAt(34);
		m_waiter2 = g_List1array.ElementAt(0).ElementAt(35);
		m_clothescount = g_List1array.ElementAt(0).ElementAt(26);
		ren = g_List1array.ElementAt(0).ElementAt(14);

		m_size = g_List1array.ElementAt(0).ElementAt(60);

		m_checkstatus = g_List1array.ElementAt(0).ElementAt(32);
		UpdateData(false);
	}
	else
	{
		m_name1 = "";
		m_name2 = "";
		m_waiter3 = "";
		m_taoxizs = "";
		m_time5 = "";
		m_takezs = "";
		m_choosezs = "";
		m_money3 = "";
		m_bz3 = "";
		m_bz4 = "";
		m_urgent = "";
		UpdateData(false);
	}
	return 1;
}

void ChoosePhotoSkin2::OnOK()
{
}

void ChoosePhotoSkin2::OnCancel()
{
}

void ChoosePhotoSkin2::OnClose()
{
	if (m_bModify)
	{
		if (AfxMessageBox("����, ѡƬ�޸�δ����, �Ƿ񱣴�����˳�?", MB_YESNO | MB_ICONINFORMATION) == IDYES)
		{
			OnButton4();
		}
	}
	CDialog::OnCancel();
}

BOOL ChoosePhotoSkin2::PreTranslateMessage(MSG* pMsg)
{
	if (pMsg->message == WM_LBUTTONDOWN)
	{
		g_bNeedDrawParent = 2;
		if (0)
		{//list3
			CPoint pt;
			CRect rc, rc2;
			::GetCursorPos(&pt);
			m_List3.GetWindowRect(rc2);
			if (rc2.PtInRect(pt) == 0)	return CDialog::PreTranslateMessage(pMsg);
			SetTimer(3, 300, NULL);
		}
	}
	/*	else if(pMsg->message==WM_PAINT && pMsg->hwnd ==this->m_hWnd )
	{
	SetTimer(1, 100, NULL);
	}
	else if(pMsg->message==WM_TIMER&& pMsg->hwnd ==this->m_hWnd)
	{
	KillTimer(1);
	DrawLogin();
	}*/
	else if (0)//pMsg->message==WM_LBUTTONDBLCLK)
	{
		{//list1
			CPoint pt;
			CRect rc, rc2;
			::GetCursorPos(&pt);
			m_List2.GetWindowRect(rc2);
			if (rc2.PtInRect(pt))
				return 1;
		}
		{//list3
			CPoint pt;
			CRect rc, rc2;
			::GetCursorPos(&pt);
			m_List3.GetWindowRect(rc2);
			if (rc2.PtInRect(pt) == 0)return CDialog::PreTranslateMessage(pMsg);
			pt.x -= rc2.left;
			pt.y -= rc2.top;
			int iItem = m_List3.GetItemCount() - 1;
			if (iItem < 0)
			{
				m_List3.GetHeaderCtrl()->GetItemRect(0, rc);
				int hei = rc.Height();
				rc.top += hei;
				rc.bottom += hei;
				if (rc.PtInRect(pt))
				{
					m_List3.InsertItem(m_List3.GetItemCount(), "");
				}
			}
			else
			{
				m_List3.GetSubItemRect(iItem, 0, LVIR_BOUNDS, rc);
				int hei = rc.Height();
				rc.top += hei;
				rc.bottom += hei;
				if (rc.PtInRect(pt))
				{
					if (m_List3.GetItemText(iItem, 1).IsEmpty() && m_List3.GetItemText(iItem, 2).IsEmpty())
						return CDialog::PreTranslateMessage(pMsg);
					m_List3.InsertItem(m_List3.GetItemCount(), "");
				}
				POSITION pos;
				pos = m_List3.GetFirstSelectedItemPosition();
				if (pos)
				{
					iItem = m_List3.GetNextSelectedItem(pos);
					m_List3.GetSubItemRect(iItem, 4, LVIR_BOUNDS, rc);
					if (rc.PtInRect(pt))return 1;
				}
			}
		}
	}
	else if (pMsg->message == WM_KEYDOWN)
	{
		if (m_showpichwd)return 1;
		switch (pMsg->wParam)
		{
		case VK_DELETE:
			OnDel();
			return 1;
		case VK_RETURN:
			OnDblclkList1();
			return 1;
		case VK_F4:
			if (m_Runingmode && m_bChooseBig == 0)return 1;
			if (atoi(g_cominfoarray.ElementAt(0).ElementAt(62)))
			{
				if (m_SelectCategory == 1)UpdateChooseZS();
				SortArray();
			}
			return 1;
		case VK_F5:
			if (atoi(g_cominfoarray.ElementAt(0).ElementAt(86)))
			{
				OnBtnClick(0, 99 + 4);
			}
			/*	if(m_mode2==0)return 1;
			{
			ReplaceDesignNo dlg;
			dlg.m_id=this->m_id ;
			dlg.DoModal ();
			}*/
			return 1;
		case VK_F1:
			{
				if (m_selphotownd2.GetSafeHwnd() == NULL)
				{
					m_selphotownd2.m_id = m_strOrderNumber;
					m_selphotownd2.m_rc = m_rcarray.ElementAt(6);
					m_selphotownd2.Create(IDD_DLGShowSelPhoto2, this);
				}
				m_selphotownd2.ShowWindow(1);
			}
			return 1;
		case VK_F2:
			if (m_Runingmode && m_bChooseBig == 0)return 1;
			if (0)
			{
				return 1;
				CStringArray array;
				for (int i = 0; i < m_List2.GetItemCount(); i++)
				{
					if (m_List2.GetItemText(i, 4).IsEmpty() == 0)
					{
						array.Add(m_List2.GetItemText(i, 0));
						array.Add(m_List2.GetItemText(i, 4));
					}
				}
				if (array.GetSize() == 0)return 1;
				ChoosePhotoSkin2 dlg;
				dlg.SetLiaPath("3.lia");
				dlg.m_strOrderNumber = m_strOrderNumber;
				dlg.m_pInputArray = &array;
				dlg.m_path = g_path2 + "\\";
				dlg.m_path += dlg.m_strOrderNumber;
				dlg.m_path += "\\";
				dlg.DoModal();
				return 1;
			}
			if (atoi(g_cominfoarray.ElementAt(0).ElementAt(60)))
			{
				m_bHide = !m_bHide;
				LoadPhotos();
			}
			return 1;
		case VK_F6:
			{
				if (m_Runingmode)
				{
					ReplaceDesignNo dlg;
					dlg.m_id = this->m_strOrderNumber;
					dlg.DoModal();
				}
			}
			return 1;
		}
	}
	return CDialog::PreTranslateMessage(pMsg);
}

void ChoosePhotoSkin2::OnRclickList1()// �Ҽ�ѡƬģʽ;
{
	// 1.Jeff:�����ģʽ;
	if (m_Runingmode)
	{
		OnRclickList2();
		return;
	}

	// 2.Jeff:��ʼѡƬģʽ;
	if (m_bRunning)return;
	POSITION pos;
	pos = m_List1.GetFirstSelectedItemPosition();
	if (pos == NULL)
	{
		return;
	}
	int iItem = m_List1.GetNextSelectedItem(pos);
	CString scount;

	// .��ȡ��ǰ�鿴����Ƭ;
	CStringArray *pArray = GetCurArray();
	CString path = pArray->ElementAt(iItem);
	path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
	path = path.Left(path.ReverseFind('.'));
	if (m_Runingmode)// Jeff:��1��ʱ���˳���,�����ж�������????? ��һ�δ�����Զ����ִ��;
	{
		if (!CheckName(path))
		{
			CMenuXP	*pPopup;
			pPopup = new CMenuXP;
			pPopup->CYBUTTONMARGIN = 3;
			pPopup->CreatePopupMenu();
			pPopup->SetMenuStyle(CMenuXP::STYLE_XP);
			pPopup->AppendODMenu2(0, new CMenuXPText(32794, "�޸�Ҫ��", NULL));

			CPoint pt;
			::GetCursorPos(&pt);
			pPopup->TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this, 0);
			delete pPopup;
			return;
		}
	}

	path = "," + path + ",";

	CMenuXP	*pPopup;
	pPopup = new CMenuXP;
	pPopup->CYBUTTONMARGIN = 3;
	pPopup->CreatePopupMenu();
	pPopup->SetMenuStyle(CMenuXP::STYLE_XP);


	int maxleng = 1;
	{
		CString name, no;
		int count = 0;
		for (int i = 0; i < m_List2.GetItemCount(); i++)
		{
			name = m_List2.GetItemText(i, 2);
			// Jeff,no��Ϊ��Ʒ����ѡ�е���Ƭ
			no = m_noarray.ElementAt(i);
			maxleng = max(maxleng, name.GetLength());
		}
		count = i;
		for (; i < count + m_no2array.GetSize(); i++)
		{
			name = m_List3.GetItemText(i - count, 2);
			maxleng = max(maxleng, name.GetLength());
		}
	}
	maxleng += 3;

	CString name, no;
	int count = 0;
	for (int i = 0; i < m_List2.GetItemCount(); i++)
	{
		name = m_List2.GetItemText(i, 2);
		::FillLength(name, maxleng);
		// Jeff,no��Ϊ��Ʒ����ѡ�е���Ƭ
		no = m_noarray.ElementAt(i);
		GetSelCountFromName(no, scount);
		pPopup->AppendODMenu2(0, new CMenuXPText(IDM_MENUsp1 + i, name + scount, NULL));
		if (no.Find(path) != -1)
			pPopup->CheckMenuItem(IDM_MENUsp1 + i, MF_BYCOMMAND | MF_CHECKED);
	}

	count = i;
	for (; i < count + m_no2array.GetSize(); i++)
	{
		name = m_List3.GetItemText(i - count, 2);
		::FillLength(name, maxleng);
		no = m_no2array.ElementAt(i - count);
		GetSelCountFromName(no, scount);
		pPopup->AppendODMenu2(0, new CMenuXPText(IDM_MENUsp1 + i, name + scount, NULL));
		if (no.Find(path) != -1)
			pPopup->CheckMenuItem(IDM_MENUsp1 + i, MF_BYCOMMAND | MF_CHECKED);
	}

	pPopup->AppendODMenu2(0, new CMenuXPText(32794, "�޸�Ҫ��", NULL));


	CPoint pt;
	::GetCursorPos(&pt);
	pPopup->TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this, 0);
	delete pPopup;
}

void ChoosePhotoSkin2::OnRclickList2()// �Ҽ������ģʽ;
{
	if (m_bRunning)return;
	POSITION pos;
	pos = m_List1.GetFirstSelectedItemPosition();
	if (pos == NULL)
	{
		return;
	}
	int iItem = m_List1.GetNextSelectedItem(pos);
	CString scount;

	CStringArray *pArray = GetCurArray();		//��ȡ��ǰ�鿴������;
	CString path = pArray->ElementAt(iItem);	//path//��ӡ����Ƭ����·����;
	if (m_bChooseBig)//ѡ�Ŵ�
		path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
	else//ѡ���
		path = path.Right(path.GetLength() - m_path.GetLength());
	path = path.Left(path.ReverseFind('.'));
	path = "," + path + ","; // 

	// TODO: Add your control notification handler code here
	// 1.�����˵�����;
	CMenuXP	*pPopup;
	pPopup = new CMenuXP;
	pPopup->CYBUTTONMARGIN = 3;				// 1.0.��ť��Χ0~3; 4���˵�;
	pPopup->CreatePopupMenu();				// 1.1.����ʽ�˵�;
	pPopup->SetMenuStyle(CMenuXP::STYLE_XP);// 1.2.�����˵���ʽ;	

	// Jeff:m_List2������ͷ����š���Ʒ���ơ���Ʒ����;
	int maxleng = 1;
	{
		CString name, no;
		int count = 0;
		for (int i = 0; i < m_List2.GetItemCount(); i++)
		{
			// name��Ʒ����
			name = m_List2.GetItemText(i, 2);
			no = m_noarray.ElementAt(i);
			maxleng = max(maxleng, name.GetLength());
		}
		count = i;
		for (; i < count + m_no2array.GetSize(); i++)
		{
			name = m_List3.GetItemText(i - count, 2);
			maxleng = max(maxleng, name.GetLength());
		}
	}
	maxleng += 3;
	// Jeff:m_List2������ͷ����š���Ʒ���ơ���Ʒ����;
	CString name, no;
	int count = 0;
	for (int i = 0; i < m_List2.GetItemCount(); i++)
	{
		name = m_List2.GetItemText(i, 2);
		::FillLength(name, maxleng);// Jeff����������API����ô???��ô��Ҳ�鲻��
		no = m_noarray.ElementAt(i);
		GetSelCountFromName(no, scount);
		pPopup->AppendODMenu2(0, new CMenuXPText(IDM_MENUsp1 + i, name + scount, NULL));// 2.ʹ��AppendODMenu2�����Ӳ˵���;
		if (no.Find(path) != -1)
			pPopup->CheckMenuItem(IDM_MENUsp1 + i, MF_BYCOMMAND | MF_CHECKED);
	}

	count = i;
	for (; i < count + m_no2array.GetSize(); i++)
	{
		name = m_List3.GetItemText(i - count, 2);
		::FillLength(name, maxleng);
		no = m_no2array.ElementAt(i - count);
		GetSelCountFromName(no, scount);
		pPopup->AppendODMenu2(0, new CMenuXPText(IDM_MENUsp1 + i, name + scount, NULL));
		if (no.Find(path) != -1)
			pPopup->CheckMenuItem(IDM_MENUsp1 + i, MF_BYCOMMAND | MF_CHECKED);
	}

	pPopup->AppendODMenu2(0, new CMenuXPText(32794, "�޸�Ҫ��", NULL));

	CPoint pt;
	::GetCursorPos(&pt);
	pPopup->TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this, 0);// 3.ʹ��TrackPopupMenu�����������˵�;
	delete pPopup;
}

void ChoosePhotoSkin2::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
	if (m_showpichwd)return;
	OnRclickList1();
	*pResult = 0;
}

void SortArray2(CArray<int, int>&datearray)
{
	int  strtemp;
	int last = datearray.GetSize() - 1;
	bool sorted = true;

	do {
		sorted = true;
		for (int i = 0; i < last; i++)
		{
			if (datearray[i] < datearray[i + 1])
			{
				strtemp = datearray[i];
				datearray[i] = datearray[i + 1];
				datearray[i + 1] = strtemp;
				sorted = false;
			}
		}
		last--;
	} while (!sorted);
}

void ChoosePhotoSkin2::OnCommandMenu(UINT nID)//�����˵�����;
{
	if (m_Runingmode)//�����;
	{
		OnCommandMenu2(nID);
		return;
	}

	if (32794 == nID)
	{
		if (m_Runingmode)//Jeff����ִ�еĴ���;
		{
			OnButton4();
		}
		else
		{
			POSITION pos;
			pos = m_List1.GetFirstSelectedItemPosition();
			if (pos == NULL)
			{
				return;
			}
			int iItem = m_List1.GetNextSelectedItem(pos);
			CStringArray *pArray = GetCurArray();
			CString path = pArray->ElementAt(iItem);
			path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
			path = path.Left(path.Find('.'));

			if (m_bz4.GetLength() > 4080)
			{
				AfxMessageBox("��ע̫�������ڱ������ѡ�б�ע���ݣ���Delete�����");
				return;
			}

			UpdateData();
			CClientRequirement dlg;
			dlg.m_no = "��ǰ��Ƭ:" + path;
			//	dlg.m_bz2=m_bz3;

			CString header, left, right, cur;
			header = path + ":";
			int pos2 = m_bz4.Find(header);
			if (pos2 != -1)
			{
				left = m_bz4.Left(pos2);
				m_bz4 = m_bz4.Right(m_bz4.GetLength() - pos2);
				pos2 = m_bz4.Find("  ");
				if (pos2 != -1)
				{
					cur = m_bz4.Left(pos2);
					int pos3 = cur.Find(":");
					if (pos3 != -1)
						cur = cur.Right(cur.GetLength() - pos3 - 1);
					right = m_bz4.Right(m_bz4.GetLength() - pos2 - 2);
				}
			}
			else
				left = m_bz4;


			dlg.m_bz2 = cur;
			dlg.m_bSave = 0;
			dlg.m_nMode = 2;
			if (dlg.DoModal() == IDOK)
			{
				//	m_bz3=dlg.m_bz2 ; 
				dlg.m_bz2.TrimLeft();
				dlg.m_bz2.TrimRight();
				if (dlg.m_bz2 != "")
					cur = header + dlg.m_bz2 + "  ";
				else
					cur = "";
				m_bz4 = left + cur + right;
				UpdateData(false);
			}
			else
			{
				if (cur != "")
					m_bz4 = left + header + cur + "  " + right;
				else
					m_bz4 = left + right;
			}
		}
		return;
	}

	POSITION pos;
	pos = m_List1.GetFirstSelectedItemPosition();
	if (pos == NULL)
	{
		return;
	}

	CString temp;
	m_combo1.ResetContent();

	int aa = 0;
	while (pos)
	{
		//	if(aa && m_mode==1)break;//m_mode=1�鿴ѡ��
		//	if(aa && m_mode==2)break;
		aa++;
		int iItem = m_List1.GetNextSelectedItem(pos);
		CStringArray *pArray = GetCurArray();
		CString path = pArray->ElementAt(iItem);
		path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
		path = path.Left(path.ReverseFind('.'));
		path = "," + path + ",";


		int idpos = nID - IDM_MENUsp1;
		BOOL bSel = 0;//ѡ�л���ȡ��
		if (idpos < m_noarray.GetSize())
		{
			CString no = m_noarray.ElementAt(idpos);
			if (no.Find(path) != -1)
			{
				int pos = no.Find(path);
				no.Delete(pos, path.GetLength() - 1);
			}
			else if (no.GetLength() > 4000)
			{
				AfxMessageBox("���̫��,ѡ��ʧ��!", MB_ICONSTOP); return;
			}
			else
			{
				bSel = 1;
				no.TrimRight(",");
				no += path;
			}
			no.TrimLeft(",");
			no.TrimRight(",");
			m_List2.SetItemText(idpos, 4, no);

			if (no.IsEmpty())
				m_noarray.SetAt(idpos, no);
			else
				m_noarray.SetAt(idpos, "," + no + ",");
		}
		else
		{
			idpos -= m_noarray.GetSize();
			CString no = m_no2array.ElementAt(idpos);
			if (no.Find(path) != -1)
			{
				int pos = no.Find(path);
				no.Delete(pos, path.GetLength() - 1);
			}
			else if (no.GetLength() > 4000)
			{
				AfxMessageBox("���̫��,ѡ��ʧ��!", MB_ICONSTOP); return;
			}
			else
			{
				bSel = 1;
				no.TrimRight(",");
				no += path;
			}
			no.TrimLeft(",");
			no.TrimRight(",");

#ifdef LKAY_VERSION
			m_List3.SetItemText (idpos, 7, no);
#else
			m_List3.SetItemText(idpos, 5, no);
#endif
			if (no.IsEmpty())
				m_no2array.SetAt(idpos, no);
			else
				m_no2array.SetAt(idpos, "," + no + ",");
		}

		m_bModify = 1;

		if (bSel == 0 && m_SelectCategory == 1 && IsSelPhoto(path) == 0)
		{
			temp.Format("%d", iItem);
			m_combo1.AddString(temp);
			continue;
		}
		else if (bSel == 1 && m_SelectCategory == 2)
		{
			temp.Format("%d", iItem);
			m_combo1.AddString(temp);
			continue;
		}
		else if (bSel == 1 && m_SelectCategory == 3)
		{
			temp.Format("%d", iItem);
			m_combo1.AddString(temp);
			continue;
		}
		else if (bSel == 0 && m_SelectCategory == 4 && IsSelAlbumPhoto(path) == 0)
		{
			temp.Format("%d", iItem);
			m_combo1.AddString(temp);
			continue;
		}
		else if (bSel == 0 && m_SelectCategory == 5 && IsSelDiskPhoto(path) == 0)
		{
			temp.Format("%d", iItem);
			m_combo1.AddString(temp);
			continue;
		}
		/////////////////////////
		CString no, dir;
		no = pArray->ElementAt(iItem);
		if (m_Runingmode)
		{
			if (no.Left(no.ReverseFind('\\') + 1) != m_path)
			{
				dir = no.Left(no.ReverseFind('\\') + 1);
				dir = dir.Right(dir.GetLength() - m_path.GetLength());
			}
		}
		no = no.Right(no.GetLength() - no.ReverseFind('\\') - 1);
		no = no.Left(no.ReverseFind('.'));
		no += GetSelName(no);
		m_List1.SetItemText(iItem, 0, dir + no);
	}


	CArray<int, int>posarray;
	for (int i = m_combo1.GetCount() - 1; i >= 0; i--)
	{
		m_combo1.GetLBText(i, temp);
		posarray.Add(atoi(temp));
	}
	SortArray2(posarray);


	if (posarray.GetSize())
	{
		if (m_SelectCategory == 1)
		{
			for (int i = 0; i < posarray.GetSize(); i++)
			{
				m_List1.DeleteItem(posarray.ElementAt(i));
				m_patharray3.Add(m_patharray2.ElementAt(posarray.ElementAt(i)));
				m_patharray2.RemoveAt(posarray.ElementAt(i));
			}
			if (m_showpichwd)
				::SendMessage(m_showpichwd, WM_CLOSE, 0, 0);
		}
		else if (m_SelectCategory == 2)
		{
			for (int i = 0; i < posarray.GetSize(); i++)
			{
				m_List1.DeleteItem(posarray.ElementAt(i));
				m_patharray3.RemoveAt(posarray.ElementAt(i));
			}
			if (m_showpichwd)
				::SendMessage(m_showpichwd, WM_CLOSE, 0, 0);
		}
		else if (m_SelectCategory == 3)
		{
			for (int i = 0; i < posarray.GetSize(); i++)
			{
				m_List1.DeleteItem(posarray.ElementAt(i));
				m_patharray1.Add(m_patharray4.ElementAt(posarray.ElementAt(i)));
				m_patharray4.RemoveAt(posarray.ElementAt(i));
			}

			if (m_showpichwd)
				::SendMessage(m_showpichwd, WM_CLOSE, 0, 0);
		}
		else if (m_SelectCategory == 4)
		{
			for (int i = 0; i < posarray.GetSize(); i++)
			{
				m_List1.DeleteItem(posarray.ElementAt(i));
				m_patharray5.RemoveAt(posarray.ElementAt(i));
			}
			if (m_showpichwd)
				::SendMessage(m_showpichwd, WM_CLOSE, 0, 0);
		}
		else if (m_SelectCategory == 5)
		{
			for (int i = 0; i < posarray.GetSize(); i++)
			{
				m_List1.DeleteItem(posarray.ElementAt(i));
				m_patharray6.RemoveAt(posarray.ElementAt(i));
			}

			if (m_showpichwd)
				::SendMessage(m_showpichwd, WM_CLOSE, 0, 0);
		}
	}
	if (m_Runingmode == 0)
	{
		Save();
		DrawLogin();
		if (m_showpichwd)
			::SendMessage(m_showpichwd, WM_USER + 200, 0, 0);
	}
}
void ChoosePhotoSkin2::OnCommandMenu2(UINT nID)//�����,�����˵�����;
{
	if (32794 == nID)// �����˵������޸�Ҫ��;
	{
		POSITION pos;
		pos = m_List1.GetFirstSelectedItemPosition();
		if (pos == NULL)
		{
			return;
		}
		int iItem = m_List1.GetNextSelectedItem(pos);
		CStringArray *pArray = GetCurArray();
		CString path = pArray->ElementAt(iItem);
		path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
		path = path.Left(path.Find('.'));

		UpdateData();
		CClientRequirement dlg;
		dlg.m_no = "��ǰ��Ƭ:" + path;
		dlg.m_bz2 = m_bz3;
		dlg.m_bSave = 0;
		dlg.m_nMode = 2;
		if (dlg.DoModal() == IDOK)
		{
			m_bz3 = dlg.m_bz2;
			UpdateData(false);
		}
		return;
	}

	POSITION pos;
	pos = m_List1.GetFirstSelectedItemPosition();
	if (pos == NULL)
	{
		return;
	}

	CString temp;
	m_combo1.ResetContent();
	int aa = 0;
	while (pos) // ��ʼ��ȡ��Ƭ;
	{
		//	if(aa && m_mode==1)break;
		//	if(aa && m_mode==2)break;
		aa++;
		int iItem = m_List1.GetNextSelectedItem(pos);
		CStringArray *pArray = GetCurArray();

		// path:
		CString path = pArray->ElementAt(iItem);
		//AfxMessageBox(path);//Jeff box

		if (m_bChooseBig)//ѡ�Ŵ�
			path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
		else//ѡ���
			path = path.Right(path.GetLength() - m_path.GetLength());
		path = path.Left(path.ReverseFind('.'));
		path = "," + path + ",";

		int idpos = nID - IDM_MENUsp1;
		BOOL bSel = 0;//ѡ�л���ȡ��
		if (idpos < m_noarray.GetSize())
		{
			//MessageBox("1");
			CString no = m_noarray.ElementAt(idpos); // no:Ϊdindansp�ֶ�no;
			//AfxMessageBox(no);//Jeff box

			if (no.Find(path) != -1)
			{
				int pos = no.Find(path);
				no.Delete(pos, path.GetLength() - 1);
			}
			else if (no.GetLength() > 4000)
			{
				AfxMessageBox("���̫��,ѡ��ʧ��!", MB_ICONSTOP); return;
			}
			else
			{
				bSel = 1;
				no.TrimRight(",");
				no += path;
			}
			no.TrimLeft(",");
			no.TrimRight(",");
			m_List2.SetItemText(idpos, 4, no);

			if (no.IsEmpty())
				m_noarray.SetAt(idpos, no);
			else
				m_noarray.SetAt(idpos, "," + no + ",");
		}
		else
		{
			idpos -= m_noarray.GetSize();
			CString no = m_no2array.ElementAt(idpos);

			if (no.Find(path) != -1)
			{
				int pos = no.Find(path);
				no.Delete(pos, path.GetLength() - 1);
			}
			else if (no.GetLength() > 4000)
			{
				AfxMessageBox("���̫��,ѡ��ʧ��!", MB_ICONSTOP); return;
			}
			else
			{
				bSel = 1;
				no.TrimRight(",");
				no += path;
			}
			no.TrimLeft(",");
			no.TrimRight(",");

#ifdef LKAY_VERSION
			m_List3.SetItemText (idpos, 7, no);
#else
			m_List3.SetItemText(idpos, 5, no);
#endif

			if (no.IsEmpty())
				m_no2array.SetAt(idpos, no);
			else
				m_no2array.SetAt(idpos, "," + no + ",");
		}

		m_bModify = 1;

		if (bSel == 0 && m_SelectCategory == 1 && IsSelPhoto(path) == 0)
		{
			temp.Format("%d", iItem);
			m_combo1.AddString(temp);
			continue;
		}
		else if (bSel == 1 && m_SelectCategory == 2)
		{
			temp.Format("%d", iItem);
			m_combo1.AddString(temp);
			continue;
		}
		else if (bSel == 1 && m_SelectCategory == 3)
		{
			temp.Format("%d", iItem);
			m_combo1.AddString(temp);
			continue;
		}
		/////////////////////////
		CString no, dir;
		no = pArray->ElementAt(iItem);
		if (m_bChooseBig)//ѡ�Ŵ�
			no = no.Right(no.GetLength() - no.ReverseFind('\\') - 1);
		else//ѡ���
			no = no.Right(no.GetLength() - m_path.GetLength());

		no = no.Left(no.ReverseFind('.'));

		no += GetSelName(no);

		m_List1.SetItemText(iItem, 0, no);
	}


	CArray<int, int>posarray;
	for (int i = m_combo1.GetCount() - 1; i >= 0; i--)
	{
		m_combo1.GetLBText(i, temp);
		posarray.Add(atoi(temp));
	}
	SortArray2(posarray);


	if (posarray.GetSize())
	{
		if (m_SelectCategory == 1)
		{
			for (int i = 0; i < posarray.GetSize(); i++)
			{
				m_List1.DeleteItem(posarray.ElementAt(i));
				m_patharray3.Add(m_patharray2.ElementAt(posarray.ElementAt(i)));
				m_patharray2.RemoveAt(posarray.ElementAt(i));
			}

			if (m_showpichwd)
				::SendMessage(m_showpichwd, WM_CLOSE, 0, 0);
		}
		else if (m_SelectCategory == 2)
		{
			for (int i = 0; i < posarray.GetSize(); i++)
			{
				m_List1.DeleteItem(posarray.ElementAt(i));
				m_patharray3.RemoveAt(posarray.ElementAt(i));
			}

			if (m_showpichwd)
				::SendMessage(m_showpichwd, WM_CLOSE, 0, 0);
		}
		else if (m_SelectCategory == 3)
		{
			for (int i = 0; i < posarray.GetSize(); i++)
			{
				m_List1.DeleteItem(posarray.ElementAt(i));
				m_patharray1.Add(m_patharray4.ElementAt(posarray.ElementAt(i)));
				m_patharray4.RemoveAt(posarray.ElementAt(i));
			}

			if (m_showpichwd)
				::SendMessage(m_showpichwd, WM_CLOSE, 0, 0);
		}
	}

	Save();
	DrawLogin();
	if (m_showpichwd)
		::SendMessage(m_showpichwd, WM_USER + 200, 0, 0);

}
int ChoosePhotoSkin2::GetZS(CString str)
{
	str.TrimLeft(",");
	str.TrimRight(",");
	if (str.IsEmpty())return 0;
	int pos = str.Find(',');
	int count = 1;
	while (pos != -1)
	{
		str.Delete(pos);
		pos = str.Find(',');
		count++;
	}
	return count;
}

long ChoosePhotoSkin2::UpdateTakeZS(WPARAM inWParam, LPARAM inLParam)
{
	if (m_SelectCategory == 0 && m_List1.GetItemCount() > atoi(m_takezs))
	{
		UpdateData();
		m_takezs.Format("%d", m_List1.GetItemCount());
		UpdateData(false);
	}
	DrawLogin();
	return 1;
}

void ChoosePhotoSkin2::UpdateChooseZS()
{
	m_patharray2.RemoveAll();
	CString str;

	if (m_sChooseFilter != "" && m_sChooseFilter != "ȫ��")
	{
		for (int i = 0; i < m_List3.GetItemCount(); i++)
		{
			if (m_List3.GetItemText(i, 2) != m_sChooseFilter)continue;
			str = m_no2array.ElementAt(i);
			GetPath(str);
		}
		return;
	}

	for (int i = 0; i < m_noarray.GetSize(); i++)
	{
		str = m_noarray.ElementAt(i);
		GetPath(str);
	}
	for (i = 0; i < m_no2array.GetSize(); i++)
	{
		str = m_no2array.ElementAt(i);
		GetPath(str);
	}
}

// ���水ť;
void ChoosePhotoSkin2::OnButton4() // ���水ť;
{
	if (m_Runingmode == 0)	//ѡƬʱ�ı���;
	{
		UpdateData();
		if (m_SelectCategory != 1)
		{
			CalChooseZS();
		}
		CString zs = m_taoxizs;
		int pos = zs.Find("\\");
		if (pos != -1)
		{
			zs = zs.Left(pos);
		}
		m_choosezs.Format("%d", max(0, m_patharray2.GetSize() - atoi(zs)));

		m_bSaveFail = 0;
		ChoosePhotoSkin3 dlg;
		dlg.m_strStatusOfChoosePhoto = m_strStatusOfChoosePhoto;	// Jeff ��ѡƬ״̬;
		dlg.m_pParent = this;
		dlg.DoModal();
		if (dlg.m_bSave)
			m_bModify = 0;
		if (dlg.m_bPushedSave == 0 && dlg.m_bSaveFail == 0)
		{
			CString savepath;
			savepath.Format("%s\\%s.dat", g_mainpath, m_strOrderNumber);
			if (m_Runingmode)savepath.Format("%s\\%s-2.dat", g_mainpath, m_strOrderNumber);
			::DeleteFile(savepath);		// ɾ��*.dat�ļ�;
		}
		m_bSaveFail = dlg.m_bSaveFail;

		if (dlg.m_bExit)
		{
			m_bModify = 0;
			CDialog::OnCancel();
		}
	}
	else if (m_Runingmode == 1)	// �����ʱ�ı���,delphotos2�ı�����Ҫ���¶���;
	{
		UpdateData();
		if (m_SelectCategory != 1)
		{
			CalChooseZS();
		}
		CString zs = m_taoxizs;
		int pos = zs.Find("\\");
		if (pos != -1)
		{
			zs = zs.Left(pos);
		}
		m_choosezs.Format("%d", max(0, m_patharray2.GetSize() - atoi(zs)));

		m_bSaveFail = 0;
		ChoosePhotoSkin3 dlg;
		//dlg.m_strStatusOfChoosePhoto = m_strStatusOfChoosePhoto;// Jeff.�����״̬������;
		dlg.m_pParent = this;
		dlg.DoModal();
		if (dlg.m_bSave)
			m_bModify = 0;
		if (dlg.m_bPushedSave == 0 && dlg.m_bSaveFail == 0)
		{
			CString savepath;
			savepath.Format("%s\\%s.dat", g_mainpath, m_strOrderNumber);
			if (m_Runingmode)savepath.Format("%s\\%s-2.dat", g_mainpath, m_strOrderNumber);
			::DeleteFile(savepath);		// ɾ��*.dat�ļ�;
		}
		m_bSaveFail = dlg.m_bSaveFail;

		if (dlg.m_bExit)
		{
			m_bModify = 0;
			CDialog::OnCancel();
		}
	}
}

// ɾ����Ƭ;
BOOL ChoosePhotoSkin2::OnDel()			// ɾ����Ƭ;
{
	//	printf("Jeff:m_mode=%d,m_mode2=%d.\n\n",m_mode,m_mode2);//Jeff Printf
	if (m_SelectCategory == 1)
	{
		AfxMessageBox("ѡ����Ƭ����ɾ��, ����ȡ��ѡ��״̬!", MB_ICONINFORMATION);
		return 0;
	}
	else if (m_SelectCategory == 3)
	{
		return 0;
	}

	POSITION pos;
	pos = m_List1.GetFirstSelectedItemPosition();
	if (pos == NULL)
	{
		return 0;
	}

	if (m_bRunning)
		return 0;

	int iItem = m_List1.GetNextSelectedItem(pos);
	CString no;//=m_List1.GetItemText (iItem, 0);
	CStringArray *pArray = GetCurArray();		// Jeff:��ťѡ�񷵻�(�鿴ȫ�����鿴ѡ�С��鿴δѡ����)
	no = pArray->ElementAt(iItem);
	//printf("Jeff:pos=%d,iItem=%d,no=%s \n\n",pos,iItem,no);// Jeff Printf;
	no = no.Right(no.GetLength() - no.ReverseFind('\\') - 1);
	no = no.Left(no.Find('.'));

	if (IsSelPhoto(no))	// Jeff ����������,��Щ����ɾ��δѡ�е���Ƭʱ,����ʾbox���ݡ�״̬:δ����;
	{
		AfxMessageBox("ѡ�е���Ƭ����ɾ��, ����ȡ��ѡ��״̬!", MB_ICONINFORMATION);
		return 0;
	}

	if (AfxMessageBox("�Ƿ�ɾ������Ƭ?", MB_YESNO | MB_ICONINFORMATION) != IDYES)
		return 0;

	m_List1.DeleteItem(iItem);

	CString name = pArray->ElementAt(iItem);
#if JEFF_TEST_ON
	if (PathFileExists(name))
		m_patharray4.Add(name);
#else
	m_patharray4.Add(name);
#endif

	//	printf("Jeff:��Ҫɾ������Ƭ=%s\n\n",name);// Jeff Printf;
	for (int i = 0; i < pArray->GetSize(); i++)
	{
		if (name.CollateNoCase(pArray->ElementAt(i)) == 0)
		{
			pArray->RemoveAt(i);
			if (m_SelectCategory == 2)
			{
				DelNo(no);
				//	MessageBox(no);
				//	m_patharray1.RemoveAt (i); 
			}
			break;
		}
	}

	if (iItem >= pArray->GetSize())
		iItem = 0;
	m_List1.SetItemState(iItem, LVIS_SELECTED, LVIS_SELECTED);
	DrawLogin();

	return 1;
}

extern int GetOrientation(Image *image);
void ChoosePhotoSkin2::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
	*pResult = 0;
}

void ChoosePhotoSkin2::OnTimer(UINT nIDEvent)
{
	if (nIDEvent == 1)
	{
		KillTimer(nIDEvent);
		if (m_showpichwd)
			::SendMessage(m_showpichwd, WM_USER + 200, 1, 0);
		TimeOutDlg dlg;
		dlg.m_ticks = m_ticks;
		dlg.DoModal();
		SetTimer(2, m_timer * 60000, NULL);
	}
	else if (nIDEvent == 2)	// ��ʱ��������ʱ����Ի���;
	{
		KillTimer(nIDEvent);
		if (m_showpichwd)
			::SendMessage(m_showpichwd, WM_USER + 200, 1, 0);
		TimeOutDlg dlg;
		dlg.m_ticks = m_ticks;
		dlg.DoModal();
		SetTimer(2, m_timer * 60000, NULL);
	}
	else if (nIDEvent == 3)
	{
		KillTimer(nIDEvent);
		//SetSPName3();
	}
}

float ChoosePhotoSkin2::GetSPPriceFromId(CString id)
{
	for (int i = 0; i < m_sparray.GetSize(); i++)
	{
		if (id == m_sparray.ElementAt(i).ElementAt(0))
			return atof(m_sparray.ElementAt(i).ElementAt(4));
	}
	return 0;
}

CString ChoosePhotoSkin2::GetSPNameFromId(CString id)
{
	for (int i = 0; i < m_sparray.GetSize(); i++)
	{
		if (id == m_sparray.ElementAt(i).ElementAt(0))
			return m_sparray.ElementAt(i).ElementAt(1);
	}
	id.TrimLeft("0");
	for (i = 0; i < m_sparray.GetSize(); i++)
	{
		if (id == m_sparray.ElementAt(i).ElementAt(0))
			return m_sparray.ElementAt(i).ElementAt(1);
	}
	return "";
}

CString GetPathFromNo(CString dir, CString no, CStringArray *pArray)
{
	CString sRet;
	dir.TrimRight('\\');
	dir += "\\";
	CStringArray dirarray;
	CString temp;
	if (pArray->GetSize() == 0)
	{
		using namespace helper_coffs;
		ffsco o;
		o.dirs(1);
		o.find(LPCSTR(dir), LPCSTR("*.*"));
		ffsco::typeT coo;
		ffsco::typeT::iterator it;
		coo = o.co_dir();
		for (it = coo.begin(); coo.end() != it; it++)
		{
			temp = (*it).c_str();
			if (::FindArray(&dirarray, temp) == -1 && temp != dir)
			{
				dirarray.Add(temp);
			}
		}
	}
	else
		dirarray.Copy(*pArray);

	for (int i = 0; i < dirarray.GetSize(); i++)
	{
		temp = dirarray.ElementAt(i);
		sRet.Format("%s%s.jpg", temp, no);
		if (::PathFileExists(sRet))return sRet;
	}
	return dir + no + ".jpg";
}

CString GetPathFromNo2(CString dir, CString no, CStringArray *pArray)
{
	CString path;
	for (int i = 0; i < pArray->GetSize(); i++)
	{
		path = pArray->ElementAt(i);
		path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
		if (path.Find(".") != -1)
			path = path.Left(path.Find("."));
		if (no == path)return pArray->ElementAt(i);
	}
	return "";
}

void ChoosePhotoSkin2::GetPath(CString str)
{//	if(atoi(g_cominfoarray.ElementAt(0).ElementAt(109))==0 && m_mode2==0)
	if (m_bFromLocal && m_Runingmode == 0)
	{
		str.TrimLeft(",");
		str.TrimRight(",");
		if (str.IsEmpty())return;
		int pos = str.Find(',');
		CString path, path2;
		char spath[MAX_PATH];
		::GetSystemDirectory(spath, MAX_PATH);
		CString sysdir = spath;
		sysdir += "\\lyfz";
		sysdir += "\\";
		sysdir += m_strOrderNumber;
		sysdir += "\\";
		while (pos != -1)
		{
			path = sysdir + str.Left(pos) + ".jpg";
			if (FindArray(&m_patharray2, path) == -1)
			{
#if JEFF_TEST_ON
				if (PathFileExists(path))
					m_patharray2.Add(path);
#else
				m_patharray2.Add(path);
#endif
			}

			str = str.Right(str.GetLength() - pos - 1);
			pos = str.Find(',');
		}
		path = sysdir + str + ".jpg";
		if (FindArray(&m_patharray2, path) == -1)
		{
#if JEFF_TEST_ON
			if (PathFileExists(path))
				m_patharray2.Add(path);
#else
			m_patharray2.Add(path);//MessageBox(path);
#endif
		}
	}
	else if (m_Runingmode && m_bChooseBig == 0)//�����
	{
		str.TrimLeft(",");
		str.TrimRight(",");
		if (str.IsEmpty())return;
		int pos = str.Find(',');
		CString path, path2;
		while (pos != -1)
		{
			path = m_path + str.Left(pos) + ".jpg";

			if (FindArray(&m_patharray2, path) == -1)
			{
#if JEFF_TEST_ON
				if (PathFileExists(path))
					m_patharray2.Add(path);
#else
				m_patharray2.Add(path);
#endif
			}

			str = str.Right(str.GetLength() - pos - 1);
			pos = str.Find(',');
		}
		path = m_path + str + ".jpg";

		if (FindArray(&m_patharray2, path) == -1)
		{
#if JEFF_TEST_ON
			if (PathFileExists(path))
				m_patharray2.Add(path);
#else
			m_patharray2.Add(path);
#endif
		}
	}
	else
	{
		if (m_DirArrayBuf.GetSize() == 0)
		{
			CString dir = m_path;
			dir.TrimRight('\\');
			dir += "\\";

			CString temp;
			using namespace helper_coffs;
			ffsco o;
			o.dirs(1);
			o.find(LPCSTR(dir), LPCSTR("*.*"));
			ffsco::typeT coo;
			ffsco::typeT::iterator it;
			coo = o.co_dir();
			for (it = coo.begin(); coo.end() != it; it++)
			{
				temp = (*it).c_str();
				if (::FindArray(&m_DirArrayBuf, temp) == -1 && temp != dir)
				{
					m_DirArrayBuf.Add(temp);
				}
			}
		}
		str.TrimLeft(",");
		str.TrimRight(",");
		if (str.IsEmpty())return;
		int pos = str.Find(',');
		CString path, path2;
		while (pos != -1)
		{
			path = GetPathFromNo2(m_path, str.Left(pos), &m_patharray1);
			path2 = path;

			if (m_nChoosePhotoType == 0)
			{
				path2.Replace("�ͻ�ԭƬ", "�޺õ�Ƭ");
				int pos1 = path2.Find(m_strOrderNumber);
				pos1 += m_strOrderNumber.GetLength();
				int pos2 = path2.ReverseFind('\\');
				path2 = path2.Left(pos1) + path2.Right(path2.GetLength() - pos2);
				if (::PathFileExists(path2))
					path = path2;
			}

			if (FindArray(&m_patharray2, path) == -1)
			{
#if JEFF_TEST_ON
				if (PathFileExists(path))
					m_patharray2.Add(path);
#else
				m_patharray2.Add(path);
#endif
			}

			str = str.Right(str.GetLength() - pos - 1);
			pos = str.Find(',');
		}
		path = GetPathFromNo2(m_path, str, &m_patharray1);//+".jpg";
		path2 = path;
		if (m_nChoosePhotoType == 0)
		{
			path2.Replace("�ͻ�ԭƬ", "�޺õ�Ƭ");
			int pos1 = path2.Find(m_strOrderNumber);
			pos1 += m_strOrderNumber.GetLength();
			int pos2 = path2.ReverseFind('\\');
			path2 = path2.Left(pos1) + path2.Right(path2.GetLength() - pos2);

			if (PathFileExists(path2))
				path = path2;
		}

		if (FindArray(&m_patharray2, path) == -1)
		{
#if JEFF_TEST_ON
			if (PathFileExists(path))
				m_patharray2.Add(path);
#else
			m_patharray2.Add(path);
#endif
		}
	}
}

void ChoosePhotoSkin2::LoadPhotos()//����ͼƬ;
{
	if (m_SelectCategory == 1)
	{
		ProductChooseFilter dlg;
		CString name;
		for (int i = 0; i < m_List2.GetItemCount(); i++)
		{
			name = m_List2.GetItemText(i, 2);
			dlg.m_array.Add(name);
		}
		for (i = 0; i < m_List3.GetItemCount(); i++)
		{
			name = m_List3.GetItemText(i, 2);
			dlg.m_array.Add(name);
		}
		dlg.DoModal();
		m_sChooseFilter = dlg.m_sChooseFilter;
		UpdateChooseZS();
	}
	TerminateThread();
	CStringArray *pArray = GetCurArray();

	m_vFileName.clear();
	for (int i = 0; i < pArray->GetSize(); i++)
	{
		CString filePath = pArray->ElementAt(i);
		filePath.MakeLower();
		m_vFileName.push_back(filePath);

	}
	LoadThumbImages();
}

void ChoosePhotoSkin2::GetNoSelPhoto()
{
	m_patharray3.RemoveAll();
	CString str1, str2;
	for (int i = 0; i < m_patharray1.GetSize(); i++)
	{
		BOOL bFind = 0;
		for (int j = 0; j < m_patharray2.GetSize(); j++)
		{
			str1 = m_patharray1.ElementAt(i);
			str2 = m_patharray2.ElementAt(j);
			if (str1.CollateNoCase(str2) == 0)
			{
				bFind = 1;
				break;
			}
		}
		if (bFind == 0)m_patharray3.Add(m_patharray1.ElementAt(i));
	}
}

int ChoosePhotoSkin2::GetNoSelPhotoCount()
{
	int nRet = 0;
	CString str1, str2;
	for (int i = 0; i < m_patharray1.GetSize(); i++)
	{
		BOOL bFind = 0;
		for (int j = 0; j < m_patharray2.GetSize(); j++)
		{
			str1 = m_patharray1.ElementAt(i);
			str2 = m_patharray2.ElementAt(j);
			if (str1.CollateNoCase(str2) == 0)
			{
				bFind = 1;
				break;
			}
		}
		if (bFind == 0)nRet++;
	}
	return nRet;
}

CStringArray* ChoosePhotoSkin2::GetCurArray()
{
	CStringArray *pArray;
	switch (m_SelectCategory)
	{
	case 0:
		pArray = &m_patharray1;//ȫ��
		break;
	case 1:
		pArray = &m_patharray2;//ѡ��
		break;
	case 2:
		pArray = &m_patharray3;//δѡ
		break;
	case 3:
		pArray = &m_patharray4;//ɾ��
		break;
	case 4:
		pArray = &m_patharray5;//���
		break;
	case 5:
		pArray = &m_patharray6;//���
		break;
	}
	return pArray;
}

BOOL ChoosePhotoSkin2::IsSelPhoto(CString path)
{
	//path.MakeLower ();
	for (int i = 0; i < m_no2array.GetSize(); i++)
	{
		//m_no2array.ElementAt (i).MakeLower ();
		if (m_no2array.ElementAt(i).Find(path) != -1)
			return 1;
	}
	for (i = 0; i < m_noarray.GetSize(); i++)
	{
		//m_noarray.ElementAt (i).MakeLower ();
		if (m_noarray.ElementAt(i).Find(path) != -1)
			return 1;
	}
	return 0;
}

BOOL ChoosePhotoSkin2::IsSelAlbumPhoto(CString path)
{
	CString photosno;
	for (int i = 0; i < m_List3.GetItemCount(); i++)
	{
		if (m_List3.GetItemText(i, 2) != "���")continue;
		photosno = m_no2array.ElementAt(i); break;
	}
	photosno = "," + photosno + ",";

	if (photosno.Find(path) != -1)
	{
		return 1;
	}
	return 0;
}

BOOL ChoosePhotoSkin2::IsSelDiskPhoto(CString path)
{
	CString photosno;
	for (int i = 0; i < m_List3.GetItemCount(); i++)
	{
		if (m_List3.GetItemText(i, 2) != "���")continue;
		photosno = m_no2array.ElementAt(i); break;
	}
	photosno = "," + photosno + ",";

	if (photosno.Find(path) != -1)
	{
		return 1;
	}
	return 0;
}

CString ChoosePhotoSkin2::GetSelName(CString name)//��ȡѡ����Ƭ;
{
	CString ret;
	name = "," + name + ",";
	for (int i = 0; i < m_List2.GetItemCount(); i++)
	{
		if (m_noarray.ElementAt(i).Find(name) != -1)
		{
			ret += m_List2.GetItemText(i, 2);
			ret += "\r\n";
		}
	}
	for (i = 0; i < m_List3.GetItemCount(); i++)
	{
		if (m_no2array.ElementAt(i).Find(name) != -1)
		{
			ret += m_List3.GetItemText(i, 2);
			ret += "\r\n";
		}
	}
	if (!ret.IsEmpty())
	{
		ret = "\r\n" + ret;
		ret.TrimRight("\r\n");
	}
	return ret;
}

// Jeff��ȡѡ��Ƶ�����;
BOOL ChoosePhotoSkin2::GetData2()//ѡ���ģʽ;
{
	m_List2.DeleteAllItems();
	m_List3.DeleteAllItems();
	m_noarray.RemoveAll();
	m_no2array.RemoveAll();
#ifdef CHILD_VERSION
	CString filter = "id='" + m_strOrderNumber + "';id='" + m_strOrderNumber + "';;;id='" + m_strOrderNumber + "'";
#else
	CString filter = "id='" + m_strOrderNumber + "' and kind<>'2';id='" + m_strOrderNumber + "';;;id='" + m_strOrderNumber + "'";
#endif
	g_sendhead.code[0] = 50;		// dindansp;
	g_sendhead.code[1] = 11;		// dindan.
	g_sendhead.code[2] = 4;			// shangpin
	g_sendhead.code[3] = 8;			// shangpin	
	g_sendhead.code[4] = 182;		// dindansp3	
	g_sendhead.tabcount = 5;
	g_sendhead.bsql = 0;
	g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 0;
	CArray<CStringArray, CStringArray>sparray;
	DataToArray(&sparray, &g_List1array, &m_sparray, &m_List2array, &oldsparray);

	m_patharray2.RemoveAll();

	CString str, kind;
	int nchoosezs = 0;
	int list2pos = 0;
	int list3pos = 0;

	CString savepath;
	savepath.Format("%s\\%s-2.dat", g_mainpath, m_strOrderNumber);
	CString stm1 = GetModifyTime2(savepath);
	CTime tm1 = CTime::GetCurrentTime();
	tm1 -= CTimeSpan(60, 0, 0, 0);
	CString stm2 = tm1.Format("%Y%m%d");
	BOOL bLoadHistory = 0;
	if (PathFileExists(savepath) && stm1 > stm2)
	{
		if (AfxMessageBox("���ѣ����������\r\n�ϴ�ѡƬδ�����˳�, �Ƿ�ԭ���ϴ�ѡƬ״̬?", MB_YESNO | MB_ICONINFORMATION) == IDYES)
			bLoadHistory = 1;
	}
	if (bLoadHistory)
	{
		CArray<CStringArray, CStringArray>List1array;
		CFile fp;
		fp.Open(savepath, CFile::modeRead);
		DWORD nMessageLen = fp.GetLength();
		BYTE *szChatMessage = new BYTE[nMessageLen];
		fp.Read(szChatMessage, nMessageLen);
		fp.Close();
		int count;
		memcpy(&count, szChatMessage + (nMessageLen - sizeof(int)), sizeof(int));
		CMemFile memfile;
		memfile.Attach(szChatMessage, nMessageLen);
		CArchive ar(&memfile, CArchive::load);
		List1array.SetSize(count);
		for (int i = 0; i < List1array.GetSize(); i++)
		{
			List1array.ElementAt(i).Serialize(ar);
		}
		ar.Close();
		memfile.Detach();
		delete[]szChatMessage;

		list2pos = 0;
		list3pos = 0;
		for (i = 0; i < List1array.GetSize(); i++)
		{
			if (0)//List1array.ElementAt (i).GetSize ()==6)
			{
				kind = "0";
				m_List2.InsertItem(list2pos, List1array.ElementAt(i).ElementAt(1));
				m_List2.SetItemText(list2pos, 1, List1array.ElementAt(i).ElementAt(2));
				m_List2.SetItemText(list2pos, 2, List1array.ElementAt(i).ElementAt(3));
				m_List2.SetItemText(list2pos, 3, List1array.ElementAt(i).ElementAt(4));
				m_List2.SetItemText(list2pos, 4, List1array.ElementAt(i).ElementAt(5));
				str = List1array.ElementAt(i).ElementAt(5);
				list2pos++;
			}
			else
			{
				kind = "4";
				m_List3.InsertItem(list3pos, List1array.ElementAt(i).ElementAt(1));
				m_List3.SetItemText(list3pos, 1, List1array.ElementAt(i).ElementAt(2));
				m_List3.SetItemText(list3pos, 2, List1array.ElementAt(i).ElementAt(3));
				m_List3.SetItemText(list3pos, 3, List1array.ElementAt(i).ElementAt(4));
				m_List3.SetItemText(list3pos, 4, List1array.ElementAt(i).ElementAt(5));
				m_List3.SetItemText(list3pos, 5, List1array.ElementAt(i).ElementAt(6));
#ifdef LKAY_VERSION
				m_List3.SetItemText(list3pos, 6, List1array.ElementAt (i).ElementAt (7));
				m_List3.SetItemText(list3pos, 7, List1array.ElementAt (i).ElementAt (8));
				str=List1array.ElementAt (i).ElementAt (8);
#else
				str = List1array.ElementAt(i).ElementAt(6);
#endif
				list3pos++;
			}

			nchoosezs += GetZS(str);
			GetPath(str);

			if (!str.IsEmpty())
				str = "," + str + ",";
			str.MakeLower();
			if (kind == "4")
				m_no2array.Add(str);
			else
				m_noarray.Add(str);
		}
	}
	else
	{
		for (int i = 0; i < sparray.GetSize(); i++)
		{
			kind = "4";//sparray.ElementAt (i).ElementAt (4);
			if (kind == "4")
			{
				m_List3.InsertItem(list3pos, sparray.ElementAt(i).ElementAt(7));
				m_List3.SetItemText(list3pos, 1, sparray.ElementAt(i).ElementAt(1));
				m_List3.SetItemText(list3pos, 2, sparray.ElementAt(i).ElementAt(5));
				m_List3.SetItemText(list3pos, 3, sparray.ElementAt(i).ElementAt(2));
				m_List3.SetItemText(list3pos, 4, sparray.ElementAt(i).ElementAt(3));
#ifdef LKAY_VERSION
				m_List3.SetItemText(list3pos, 5, sparray.ElementAt (i).ElementAt (9));
				m_List3.SetItemText(list3pos, 6, sparray.ElementAt (i).ElementAt (10));
				m_List3.SetItemText(list3pos, 7, sparray.ElementAt (i).ElementAt (8));
#else
				m_List3.SetItemText(list3pos, 5, sparray.ElementAt(i).ElementAt(8));	// 8 dindansp:no2
#endif
				list3pos++;
			}
			else
			{
				m_List2.InsertItem(list2pos, sparray.ElementAt(i).ElementAt(7));
				m_List2.SetItemText(list2pos, 1, sparray.ElementAt(i).ElementAt(1));
				m_List2.SetItemText(list2pos, 2, sparray.ElementAt(i).ElementAt(5));
				m_List2.SetItemText(list2pos, 3, sparray.ElementAt(i).ElementAt(3));
				m_List2.SetItemText(list2pos, 4, sparray.ElementAt(i).ElementAt(8));	// 8 dindansp:no2

				list2pos++;
			}

			str = sparray.ElementAt(i).ElementAt(8);	// 8 dindansp:no2
			str.MakeLower();
			nchoosezs += GetZS(str);
			GetPath(str);
			if (!str.IsEmpty())
				str = "," + str + ",";
			if (kind == "4")
				m_no2array.Add(str);
			else
				m_noarray.Add(str);
		}
	}


	if (g_List1array.GetSize())
	{
		m_name1 = g_List1array.ElementAt(0).ElementAt(4);
		m_name2 = g_List1array.ElementAt(0).ElementAt(5);
		m_phone1 = g_List1array.ElementAt(0).ElementAt(61);
		m_phone2 = g_List1array.ElementAt(0).ElementAt(62);


		if (!m_name1.IsEmpty())
			m_name = m_name1 + ",";
		m_name += m_name2;
		m_name.TrimRight(",");
		m_waiter3 = g_user.name;
		m_taoxizs = g_List1array.ElementAt(0).ElementAt(9);
		m_time5 = g_List1array.ElementAt(0).ElementAt(22);
		m_takezs = g_List1array.ElementAt(0).ElementAt(23);
		m_choosezs = g_List1array.ElementAt(0).ElementAt(24);
		m_money3 = g_List1array.ElementAt(0).ElementAt(3);
		m_oldmoney3 = m_money3;
		m_bz3 = g_List1array.ElementAt(0).ElementAt(57);
		m_urgent = g_List1array.ElementAt(0).ElementAt(40);
		m_delphotos = g_List1array.ElementAt(0).ElementAt(56);// Jeff��ȡѡ���ʱ,��ɾ������Ƭ,ѡȡ���ֶ�delphotos2;.��ȡ����������ʱδ����ȷ���浽delphotos2�ֶ�;
		//printf("Jeff:�����:delphotos2=%s\n\n",m_delphotos);//Jeff Printf
		m_status8 = g_List1array.ElementAt(0).ElementAt(55);
		m_time6 = g_List1array.ElementAt(0).ElementAt(48);

		m_time5old = m_time5;
		m_time6old = m_time6;

		m_checkstatus = g_List1array.ElementAt(0).ElementAt(55);
		UpdateData(false);
	}
	else
	{
		m_name1 = "";
		m_name2 = "";
		m_waiter3 = "";
		m_taoxizs = "";
		m_time5 = "";
		m_takezs = "";
		m_choosezs = "";
		m_money3 = "";
		m_bz3 = "";
		m_urgent = "";
		UpdateData(false);
	}
	return 1;

}

void ChoosePhotoSkin2::SortArray()	// ��F4���������;
{
	//	if(m_mode2)return;
	m_bSort = !m_bSort;

	CStringArray *pArray[6] = { &m_patharray1, &m_patharray2, &m_patharray3, &m_patharray4, &m_patharray5, &m_patharray6 };

	if (m_bSort == 0)
	{
		for (int i = 0; i < 6; i++)
		{
			if (pArray[i]->GetSize())
			{
				int size = pArray[i]->GetSize() - 1;
				CString sTemp;
				int nPos;
				for (int ii = 0; ii < size; ii++)
				{
					nPos = rand() % (size - ii);
					sTemp = pArray[i]->ElementAt(size - ii);
					pArray[i]->SetAt(size - ii, pArray[i]->ElementAt(nPos));
					pArray[i]->SetAt(nPos, sTemp);
				}
			}
		}
	}
	else
	{	// ʹ��CCombobox��Sort������;
		for (int i = 0; i < 6; i++)
		{
			m_combo1.ResetContent();
			CString Temp;
			for (int j = 0; j < pArray[i]->GetSize(); j++)
			{
				m_combo1.AddString(pArray[i]->ElementAt(j));
			}
			for (j = 0; j < pArray[i]->GetSize(); j++)
			{
				m_combo1.GetLBText(j, Temp);
				pArray[i]->SetAt(j, Temp);
			}
		}
	}

	{
		TerminateThread();
		CStringArray *pArray = GetCurArray();

		m_vFileName.clear();
		for (int i = 0; i < pArray->GetSize(); i++)
		{
			CString filePath = pArray->ElementAt(i);
			filePath.MakeLower();
			m_vFileName.push_back(filePath);
		}
		LoadThumbImages();
	}
}

void ChoosePhotoSkin2::CheckForDisk() // ������;
{
	for (int i = 0; i < m_List2.GetItemCount(); i++)
	{
		if ("���" == m_List2.GetItemText(i, 2))return;
	}
	for (i = 0; i < m_List3.GetItemCount(); i++)
	{
		if ("���" == m_List3.GetItemText(i, 2))return;
	}
	i = m_List3.GetItemCount();
	m_List3.InsertItem(i, "");
	m_List3.SetItemText(i, 2, "���");
	m_no2array.Add("");
}

void ChoosePhotoSkin2::CheckForAlbum() // ������;
{
	for (int i = 0; i < m_List2.GetItemCount(); i++)
	{
		if ("���" == m_List2.GetItemText(i, 2))return;
	}
	for (i = 0; i < m_List3.GetItemCount(); i++)
	{
		if ("���" == m_List3.GetItemText(i, 2))return;
	}
	i = m_List3.GetItemCount();
	m_List3.InsertItem(i, "");
	m_List3.SetItemText(i, 2, "���");
	m_no2array.Add("");
}

void ChoosePhotoSkin2::GetPhotos()//�ÿ����
{
	m_patharray1.RemoveAll();
	m_path.MakeLower();
	CStringArray dirarray;
	CString str;
	if (1)
	{
		using namespace helper_coffs;
		ffsco o;
		o.dirs(1);
		o.find(LPCSTR(m_path), LPCSTR("*.*"));
		ffsco::typeT coo;
		ffsco::typeT::iterator it;
		coo = o.co_dir();
		for (it = coo.begin(); coo.end() != it; it++)
		{
			str = (*it).c_str();
			str.TrimRight("\\");
			CString dirname = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
			if (dirname.Find("DelgaBook") != -1)
			{
				if (FindArray(&m_patharray1, str) == -1)
				{
					m_patharray1.Add(str);
				}
			}
			if (FindArray(&dirarray, str) == -1)
			{
				dirarray.Add(str);
			}
		}
	}
	if (1)
	{
		for (int i = 0; i < dirarray.GetSize(); i++)
		{
			using namespace helper_coffs;
			ffsco o;
			o.dirs(0);
			o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
			ffsco::typeT coo;
			ffsco::typeT::iterator it;
			coo = o.co_file();
			for (it = coo.begin(); coo.end() != it; it++)
			{
				str = (*it).c_str();
				if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
				if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
				str.MakeLower();
				m_patharray1.Add(str);
			}
		}
	}


	CStringArray *pArray[1] = { &m_patharray1 };
	for (int i = 0; i < 1; i++)
	{
		m_combo1.ResetContent();
		CString Temp;
		for (int j = 0; j < pArray[i]->GetSize(); j++)
		{
			m_combo1.AddString(pArray[i]->ElementAt(j));
		}
		for (j = 0; j < pArray[i]->GetSize(); j++)
		{
			m_combo1.GetLBText(j, Temp);
			pArray[i]->SetAt(j, Temp);
		}
	}
}

void ChoosePhotoSkin2::Save()
{
	CString sql;
	CArray<CStringArray, CStringArray>sparray;
	sparray.SetSize(m_List2.GetItemCount() + m_no2array.GetSize());
	for (int i = 0; i < m_List2.GetItemCount(); i++)
	{
		sparray.ElementAt(i).Add(m_strOrderNumber);
		sparray.ElementAt(i).Add(m_List2.GetItemText(i, 0));
		sparray.ElementAt(i).Add(m_List2.GetItemText(i, 1));
		sparray.ElementAt(i).Add(m_List2.GetItemText(i, 2));
		sparray.ElementAt(i).Add(m_List2.GetItemText(i, 3));
		sparray.ElementAt(i).Add(m_List2.GetItemText(i, 4));
	}
	for (int j = 0; j < m_no2array.GetSize(); j++)
	{
		sparray.ElementAt(i).Add(m_strOrderNumber);
		sparray.ElementAt(i).Add(m_List3.GetItemText(j, 0));
		sparray.ElementAt(i).Add(m_List3.GetItemText(j, 1));
		sparray.ElementAt(i).Add(m_List3.GetItemText(j, 2));
		sparray.ElementAt(i).Add(m_List3.GetItemText(j, 3));
		sparray.ElementAt(i).Add(m_List3.GetItemText(j, 4));
		sparray.ElementAt(i).Add(m_List3.GetItemText(j, 5));
#ifdef LKAY_VERSION
		sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 6) );
		sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 7) );
#endif
		sparray.ElementAt(i).Add("4");
		i++;
	}
	if (sparray.GetSize() == 0)
	{
		sparray.SetSize(1);
		sparray.ElementAt(0).Add(m_strOrderNumber);
	}

	CMemFile memfile;
	CArchive ar(&memfile, CArchive::store);
	for (int ii = 0; ii < sparray.GetSize(); ii++)
	{
		sparray.ElementAt(ii).Serialize(ar);
	}
	ar.Close();
	int length = memfile.GetLength();
	BYTE *pData = memfile.Detach();
	int size = sparray.GetSize();
	BYTE *pData2 = new BYTE[length + sizeof(int)];
	memcpy(pData2, pData, length);
	memcpy(pData2 + length, &size, sizeof(int));
	delete[]pData;
	length += sizeof(int);

	CString savepath;
	savepath.Format("%s\\%s.dat", g_mainpath, m_strOrderNumber);
	if (m_Runingmode)savepath.Format("%s\\%s-2.dat", g_mainpath, m_strOrderNumber);
	if (1)
	{
		CFile fp;
		fp.Open(savepath, CFile::modeCreate | CFile::modeWrite);
		fp.Write(pData2, length);
		fp.Close();
	}
	delete[]pData2;
}

void ChoosePhotoSkin2::DrawLogin()
{
	CRect rc;
	((MyBmpButton2*)m_picarray.ElementAt(3))->GetWindowRect(rc);
	ScreenToClient(rc);
	rc.right -= rc.left;
	rc.left = 5;
	rc.right += 5;
	rc.top += 20;
	rc.right -= 15;
	CDC *pDC = GetDC();
	Graphics graph(pDC->GetSafeHdc());

	Rect destinationRect(rc.left, rc.top, rc.Width(), rc.Height());
	RectF layoutRect(rc.left, rc.top, rc.Width(), rc.Height());
	rc.left /= g_fscalex;
	rc.right /= g_fscalex;
	rc.top /= g_fscaley;
	rc.bottom /= g_fscaley;

	//	graph.SetSmoothingMode(SmoothingModeHighQuality);
	graph.DrawImage(m_pBk, destinationRect, rc.left, rc.top, rc.Width(), rc.Height(), UnitPixel);

	StringFormat format;
	format.SetAlignment(StringAlignmentNear);
	SolidBrush *Brush = new SolidBrush(Color(255, 255, 255, 255));

	CString str;

	str.Format("����:%d", m_List1.GetItemCount());

	int leng = GetLengthEx(str);
	BSTR bstr = str.AllocSysString();
	Font  *g_TimerFont = new Font(L"����", 13);

	graph.SetTextRenderingHint(TextRenderingHintAntiAlias);
	graph.DrawString(
		bstr,
		leng,
		g_TimerFont,
		layoutRect,
		&format,
		Brush);
	delete Brush;
	delete g_TimerFont;
	SysFreeString(bstr);
	ReleaseDC(pDC);
}

//--------------------------------------------------
// remark by Jeff 2014.12.15
// ������CheckOK
// �������ж��ַ����Ƿ����������;
// ������name Ҫ�жϵ��ַ���;
// ���أ������������ɷ���1,���򷵻�0;
//--------------------------------------------------
BOOL ChoosePhotoSkin2::CheckOK(CString name)
{
	if (name.GetLength() > 4)return 0;
	for (int i = 0; i < name.GetLength(); i++)
	{
		if (name.GetAt(i) < '0' || name.GetAt(i) > '9')return 0;
	}
	return 1;
}

//--------------------------------------------------
// remark by Jeff 2014.12.15
// ������CheckName
// ����������CheckOK,�ж��ַ����Ƿ����������(��ȥ"$" "."�������Լ���׺��);
// ������name Ҫ�жϵ��ַ���;
// ���أ������������ɷ���1,���򷵻�0;
//--------------------------------------------------
BOOL ChoosePhotoSkin2::CheckName(CString name)
{//$001.002.003
	int pos = name.Find("$");
	if (pos != 0)return 0;
	name.Delete(0, 1);
	pos = name.Find(".");

	while (pos != -1)
	{
		if (CheckOK(name.Left(pos)) == 0)return 0;
		name = name.Right(name.GetLength() - pos - 1);
		pos = name.Find(".");
	}
	return CheckOK(name);
}

void ChoosePhotoSkin2::DelNo(CString no)
{
	CString no2;

	for (int i = 0; i < m_patharray1.GetSize(); i++)
	{
		no2 = m_patharray1.ElementAt(i);
		no2 = no2.Right(no2.GetLength() - no2.ReverseFind('\\') - 1);
		no2 = no2.Left(no2.Find('.'));
		if (no == no2)
		{
			m_patharray1.RemoveAt(i);
			return;
		}
	}
}

CString ChoosePhotoSkin2::GetZSInfo(int iItem)
{
	if (m_SelectCategory != 1)
		CalChooseZS();
	CString str;

	//	str.Format("%d/%d %d+", m_patharray2.GetSize(), atoi(m_taoxizs), max(0,m_patharray2.GetSize()-atoi(m_taoxizs)));
	CString scount = m_List1.GetItemText(iItem, 0);
	int ncount = 0;
	int npos = scount.Find("\r\n");
	while (npos != -1)
	{
		ncount++;
		scount = scount.Right(scount.GetLength() - npos - 2);
		npos = scount.Find("\r\n");
	}

	/*	if(m_mode2)
	str.Format("X:%d", ncount);
	else
	str.Format("X:%d %d/%d %d+ S:%d/%d", ncount, m_patharray2.GetSize(), atoi(m_taoxizs), max(0,m_patharray2.GetSize()-atoi(m_taoxizs)), GetNoSelPhotoCount(), max(0, atoi(m_taoxizs)-m_patharray2.GetSize()));
	*/

	CString zs = m_taoxizs;
	int pos = zs.Find("\\");
	if (pos != -1)
	{
		zs = zs.Left(pos);
	}
	if (m_Runingmode)
		str.Format("X:%d", ncount);
	else
		str.Format("ѡ�д���:%d ��ѡ/Ӧѡ:%d/%d\r\n��ѡ:%d+ δѡ/ʣ��:%d/%d", ncount, m_patharray2.GetSize(), atoi(zs), max(0, m_patharray2.GetSize() - atoi(zs)), max(0, atoi(zs) - m_patharray2.GetSize()), GetNoSelPhotoCount());

	return str;
}

// GetSelCountFromName
// ����:������Ƭ����;
// ����:
// [IN]name:	
//			dindansp���ֶ�no�������;(example:001,002,003(����,���),004)
// [OUT]scount	
// 
// 
void ChoosePhotoSkin2::GetSelCountFromName(CString name, CString &scount)
{
	name.TrimLeft(",");
	name.TrimRight(",");
	if (name.GetLength() == 0)
	{
		scount = "0";
		return;
	}

	// Jeff:����������,����Ƭ��Ϊ:003(����,���),��ͻ�����һ��;
	// ��Ҫ��ɵ�һ������;
	int ncount = 0;
	int npos = name.Find(",");
	while (npos != -1)
	{
		ncount++;
		name = name.Right(name.GetLength() - npos - 1);
		npos = name.Find(",");
	}
	ncount++;
	scount.Format("%d", ncount);
}


void ChoosePhotoSkin2::CalChooseZS()
{
	m_patharray2.RemoveAll();
	CString str;

	for (int i = 0; i < m_noarray.GetSize(); i++)
	{
		str = m_noarray.ElementAt(i);
		GetPath(str);
	}
	for (i = 0; i < m_no2array.GetSize(); i++)
	{
		str = m_no2array.ElementAt(i);
		GetPath(str);
	}
}
//���
//
void ChoosePhotoSkin2::GetAlbumPhoto()//�鿴�����Ƭ;
{
	if (m_SelectCategory == 4)return;
	m_SelectCategory = 4;
	m_patharray5.RemoveAll();
	CString photosno;
	for (int i = 0; i < m_List3.GetItemCount(); i++)
	{
		if (m_List3.GetItemText(i, 2) != "���")continue;
		photosno = m_no2array.ElementAt(i); break;
	}
	photosno = "," + photosno + ",";
	for (i = m_patharray1.GetSize() - 1; i >= 0; i--)
	{
		CString no;
		no = m_patharray1.ElementAt(i);
		no = no.Right(no.GetLength() - no.ReverseFind('\\') - 1);
		no = no.Left(no.Find('.'));
		no = "," + no;
		no += ",";
		if (photosno.Find(no) != -1)
		{
			no = m_patharray1.ElementAt(i);
			m_patharray5.Add(no);
		}
	}
	LoadPhotos();
}

void ChoosePhotoSkin2::GetDiskPhoto()//�鿴�����Ƭ;
{
	if (m_SelectCategory == 5)return;
	m_SelectCategory = 5;
	m_patharray6.RemoveAll();
	CString photosno;
	for (int i = 0; i < m_List3.GetItemCount(); i++)
	{
		if (m_List3.GetItemText(i, 2) != "���")continue;
		photosno = m_no2array.ElementAt(i); break;
	}
	photosno = "," + photosno + ",";
	for (i = m_patharray1.GetSize() - 1; i >= 0; i--)
	{
		CString no;
		no = m_patharray1.ElementAt(i);
		no = no.Right(no.GetLength() - no.ReverseFind('\\') - 1);
		no = no.Left(no.Find('.'));
		no = "," + no;
		no += ",";
		if (photosno.Find(no) != -1)
		{
			no = m_patharray1.ElementAt(i);
			m_patharray6.Add(no);
		}
	}
	LoadPhotos();
}

BOOL ChoosePhotoSkin2::ReLoad()
{
	if (m_Runingmode == 0)
		return GetData();
	else
		return GetData2();
}

BOOL ChoosePhotoSkin2::IsPhoto2Exist()
{
	//printf("Jeff:g_path2=%s\n\n",g_path2);
	CString path2;
	CString path = g_path2 + "\\";
	path += m_strOrderNumber;
	path += "\\";

	//printf("Jeff:path=%s\n\n",path);
#if 0	// ԭ������ֻ��������ǰ�ļ�����û��ͼƬ�ļ�,��û�ж����ļ��н�������,��һֱ���ش���ֵ;
	using namespace helper_coffs;
	ffsco o;
	o.dirs(0);
	o.find(LPCSTR(path), LPCSTR("*.jpg"));
	ffsco::typeT coo;
	coo = o.co_file();

	//	printf("Jeff:%d\n\n",coo.size());

	return coo.size();

#else	// Jeff.���������ļ��������Ƭ;2014.09.02

	CStringArray StrSubFoloderArray;
	using namespace helper_coffs;
	ffsco o;
	o.dirs(1);	// Jeff.1:������Ŀ¼;
	o.find(LPCSTR(path), LPCSTR("*.*"));	// ���ܴ���m��s��ͷ������ͼ,��Ҫ���˵�;

	if (o.count() == 0)
		return 0;

	// ��ȡ��Ŀ¼��;
	ffsco::typeT coo;
	ffsco::typeT::iterator it;
	coo = o.co_dir();
	for (it = coo.begin(); it != coo.end(); it++)
	{
		if (::FindArray(&StrSubFoloderArray, (*it).c_str()) == -1)
			StrSubFoloderArray.Add((*it).c_str());
	}

	// ��ȡ��Ŀ¼�µ��ļ���;
	CStringArray StrPhotoArray;
	for (int n = 0; n < StrSubFoloderArray.GetSize(); n++)
	{
		ffsco op;
		op.dirs(0);
		op.find(LPCSTR(StrSubFoloderArray.ElementAt(n)), LPCSTR("*.*"));
		ffsco::typeT coo;
		ffsco::typeT::iterator itp;
		coo = op.co_file();

		for (itp = coo.begin(); itp != coo.end(); itp++)
		{
			StrPhotoArray.Add((*itp).c_str());
		}
	}

	CString strTempFile;
	int nIndex = 0;
	int nSizeOfFile = 0;	// ��¼��Ƭ�ļ���;
	int nCount = StrPhotoArray.GetSize();
	for (int i = 0; i < nCount; i++)
	{
		strTempFile = StrPhotoArray.ElementAt(i);
		nIndex = strTempFile.ReverseFind('\\');
		strTempFile = strTempFile.Right(strTempFile.GetLength() - nIndex - 1);

		if (strTempFile.Left(1) == "m" || strTempFile.Left(1) == "s")
		{
			continue;
		}

		strTempFile = strTempFile.Right(4);
		strTempFile.MakeLower();

		if (strTempFile == ".jpg")
		{
			nSizeOfFile++;
		}
		else if (strTempFile == ".raw")
		{
			nSizeOfFile++;
		}
		else if (strTempFile == ".cr2")
		{
			nSizeOfFile++;
		}
		else if (strTempFile == ".nef")
		{
			nSizeOfFile++;
		}
	}

	return nSizeOfFile;
#endif
}

void ChoosePhotoSkin2::ReLoadPhoto()
{
	if (!((MyBmpButton2*)m_picarray.ElementAt(8))->GetPushDown())
	{
		m_path = g_path3 + "\\";
		m_path += m_strOrderNumber;
		m_path += "\\";
		GetPhotos();
		m_bChooseBig = 0;
	}
	else
	{
		m_bChooseBig = 1;
		IsGrowthTx growthtxdlg;
		growthtxdlg.m_mode = 1;
		growthtxdlg.m_strOrderNumber = m_strOrderNumber;
		growthtxdlg.DoModal();
		m_bGrowthTX = growthtxdlg.m_bGrowthTx;
		m_seltxname = growthtxdlg.m_seltxname;

		m_patharray1.RemoveAll();
		if (CheckHC()) //
		{
			CString str;
			m_bFromLocal = 1;
			char path[MAX_PATH];
			::GetSystemDirectory(path, MAX_PATH);
			CString sysdir = path;
			sysdir += "\\lyfz";
			::CreateDirectory(sysdir, NULL);
			sysdir += "\\";
			sysdir += m_strOrderNumber;
			using namespace helper_coffs;
			ffsco o;
			o.dirs(1);
			o.find(LPCSTR(sysdir), LPCSTR("*.jpg"));
			ffsco::typeT coo;
			ffsco::typeT::iterator it;
			coo = o.co_file();
			for (it = coo.begin(); coo.end() != it; it++)
			{
				str = (*it).c_str();
				if (str.GetAt(str.ReverseFind('\\') + 1) != 's' && str.GetAt(str.ReverseFind('\\') + 1) != 'm')
				{
					m_patharray1.Add(str);
				}
			}
		}
		if (m_patharray1.GetSize() == 0)
		{
			if (IsPhoto2Exist())
			{
				SelBrunDevice dlg;
				dlg.m_mode = 1;
				if (dlg.DoModal() == IDOK)
					m_nChoosePhotoType = dlg.m_sel;
				else
					m_nChoosePhotoType = 0;
				//m_nChoosePhotoType=0 ԭƬ+��Ƭ 1����Ƭ 2��ԭƬ
			}
			else 
				AfxMessageBox("��ܰ��ʾ��\r\nδ�ҵ�����Ƭ����ʹ��ԭƬѡƬ", MB_ICONINFORMATION);

			{
				CString path, path2;
				m_path = g_path1 + "\\";
				m_path += m_strOrderNumber;
				m_path += "\\";
				if (m_seltxname != "" && m_seltxname != "ȫ��")
				{
					m_path += m_seltxname;
					m_path += "\\";
				}
				if (m_nChoosePhotoType == 1)	// ѡƬ:��Ƭ
				{
					m_path = g_path2 + "\\";
					m_path += m_strOrderNumber;
					m_path += "\\";
				}
				CString filename;
				using namespace helper_coffs;
				ffsco o;
				o.dirs(1);
				o.find(LPCSTR(m_path), LPCSTR("*.*"));
				ffsco::typeT coo;
				ffsco::typeT::iterator it;
				coo = o.co_file();
				for (it = coo.begin(); coo.end() != it; it++)
				{
					path = (*it).c_str();

					if (path.GetAt(path.ReverseFind('\\') + 1) != 's' && path.GetAt(path.ReverseFind('\\') + 1) != 'm')
					{
						path.MakeLower();

						filename = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
						if (filename.Find(".") != -1)
							filename = filename.Left(filename.Find("."));
						if (!myisdigit(filename))continue;

						if (m_nChoosePhotoType == 1)
						{
#if JEFF_TEST_ON
							if (PathFileExists(path))
								m_patharray1.Add(path);
#else
							m_patharray1.Add(path);
#endif
						}
						else
						{
							path2 = path;

							if (m_nChoosePhotoType == 0)
								path2.Replace("�ͻ�ԭƬ", "�޺õ�Ƭ");
							if (m_bGrowthTX == 0)
							{
								int pos = path2.Find(m_strOrderNumber);
								pos += m_strOrderNumber.GetLength();
								int pos2 = path2.ReverseFind('\\');
								path2 = path2.Left(pos) + path2.Right(path2.GetLength() - pos2);
							}

							if (m_nChoosePhotoType == 0 && ::PathFileExists(path2))
							{
								m_patharray1.Add(path2);
							}
							else
							{
								path2.Replace(".raw", ".jpg");
								if (PathFileExists(path2))
								{
									m_patharray1.Add(path2);
									continue;
								}
								path2.Replace(".nef", ".jpg");
								if (PathFileExists(path2))
								{
									m_patharray1.Add(path2); 
									continue;
								}
								path2.Replace(".cr2", ".jpg");
								if (PathFileExists(path2))
								{
									m_patharray1.Add(path2);
									continue;
								}
								else
								{
									if (path.Right(3) != "jpg")
										continue;
#if JEFF_TEST_ON
									if (PathFileExists(path))
										m_patharray1.Add(path);
#else
									m_patharray1.Add(path);
#endif
								}
							}
						}
					}
				}
			}

			//	if(0)
			{//�����޺õ�Ч��
				CString path, path2;
				path2 = g_path2 + "\\";
				path2 += m_strOrderNumber;
				path2 += "\\";
				using namespace helper_coffs;
				ffsco o;
				o.dirs(0);
				o.find(LPCSTR(path2), LPCSTR("*.jpg"));
				ffsco::typeT coo;
				ffsco::typeT::iterator it;
				coo = o.co_file();
				for (it = coo.begin(); coo.end() != it; it++)
				{
					path = (*it).c_str();
					if (path.GetAt(path.ReverseFind('\\') + 1) != 's' && path.GetAt(path.ReverseFind('\\') + 1) != 'm')
					{
						path.MakeLower();
						path2 = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
						if (path2.Find("-") != -1)
						{
#if JEFF_TEST_ON
							if (PathFileExists(path))
								m_patharray1.Add(path);
#else
							m_patharray1.Add(path);
#endif
						}
					}
				}
			}
		}
		if (m_patharray1.GetSize() && atoi(g_cominfoarray.ElementAt(0).ElementAt(61)))
		{
			int size = m_patharray1.GetSize() - 1;
			CString sTemp;
			int nPos;
			for (int i = 0; i < size; i++)
			{
				nPos = rand() % (size - i);
				sTemp = m_patharray1.ElementAt(size - i);
				m_patharray1.SetAt(size - i, m_patharray1.ElementAt(nPos));
				m_patharray1.SetAt(nPos, sTemp);
			}
		}
	}
	m_SelectCategory = 0;
	LoadPhotos();
}

BOOL ChoosePhotoSkin2::CheckHC()//��鱾�����Ƿ��л������Ƭ;
{
	char path[MAX_PATH];
	::GetSystemDirectory(path, MAX_PATH); //printf("Jeff:CheckHC::path=%s\n\n",path);//Jeff Printf
	CString sysdir = path;
	sysdir += "\\lyfz";
	::CreateDirectory(sysdir, NULL); //printf("Jeff:CheckHC::sysdir1=%s\n\n",sysdir);//Jeff Printf
	sysdir += "\\";
	sysdir += m_strOrderNumber;	 //printf("Jeff:CheckHC::sysdir2=%s\n\n",sysdir);//Jeff Printf

	using namespace helper_coffs;
	ffsco o;
	o.dirs(0);
	o.find(LPCSTR(sysdir), LPCSTR("*.jpg"));
	ffsco::typeT coo;
	coo = o.co_file();
	if (coo.size())
	{
		if (AfxMessageBox("����, �˿����б�������Ƭ���Ƿ�ʹ�û���Ƭ?", MB_YESNO | MB_ICONINFORMATION) == IDYES)
			return 1;
	}
	return 0;
}