// ChooseDesignSkin.cpp : implementation file // #include "stdafx.h" #include "ChooseDesignSkin.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 "ComparePhoto.h" #include "ReplaceDesignNo.h" #include "Login2.h" #include "TimeOutDlg.h" #include "ShowEffect.h" #include "SelBrunDevice.h" #include "ProductChooseFilter.h" #include "NewFolderDlg.h" #include "NetShareInfo.h" #include "ShowMsg3.h" using namespace helper_coffs; #ifdef _DEBUG //#define new DEBUG_NEW (如果出现new时传多个参数会出错) #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif using namespace helper_coffs; extern int GetOrientation(Image *image); extern HCURSOR g_cursorhand; ///////////////////////////////////////////////////////////////////////////// // ChooseDesignSkin message handlers extern void SizeToContent(HWND hwnd, Image *img); //mode //0 全部 //1 选中 //2 未选 //3 删除 //4 入册 //5 入底 ///////////////////////////////////////////////////////////////////////////// // ChooseDesignSkin dialog IDC_EDITzs ChooseDesignSkin::ChooseDesignSkin(CWnd* pParent /*=NULL*/) : ChoosePhotoBase(ChooseDesignSkin::IDD, pParent) { m_time4 = g_date; g_pMainWnd->GetSkin(); m_bChooseBig = 0; m_Runingmode = 1; } ChooseDesignSkin::ChooseDesignSkin(DWORD id, CWnd* pParent) : ChoosePhotoBase(id, pParent) { m_time4 = g_date; g_pMainWnd->GetSkin(); m_bChooseBig = 0; m_Runingmode = 1; } void ChooseDesignSkin::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(ChooseDesignSkin) DDX_Control(pDX, IDC_COMBO1, m_combo1); 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(ChooseDesignSkin, CDialog) //{{AFX_MSG_MAP(ChooseDesignSkin) 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() ///////////////////////////////////////////////////////////////////////////// // ChooseDesignSkin message handlers BOOL ChooseDesignSkin::OnInitDialog() //初始化选片*看设计 { ChoosePhotoBase::OnInitDialog(); //加载相片和文件夹icon LoadImageFromRes(&m_pHideImg, MAKEINTRESOURCE(IDR_JPG5), _T("JPG")); if(m_pHideImg == NULL) { MessageBox(_T("加载图标失败")); return FALSE; } // 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 + _T("\\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//SZWNS_VERSION } else m_picarray.Add(NULL); m_rcarray.Add(g_resdata2.rect[i]); } delete[]pDataBegin; //初始化按钮位置 { //看设计 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); } 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); } } ((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); #ifndef MNLS_VERSION//mnls ((MyBmpButton2*)m_picarray.ElementAt(7))->ShowWindow(SW_HIDE); ((MyBmpButton2*)m_picarray.ElementAt(7))->EnableWindow(0); Graphics graph(m_pBk); Image *img = NULL; ::LoadImageFromBuf(&img, g_mainpath + _T("\\图片\\标题-看设计.jpg")); if (img) { if (img->GetWidth() == 2000) { graph.SetSmoothingMode(SmoothingModeHighQuality); graph.DrawImage(img, 0, 0); } delete img; } #endif//MNLS_VERSION //初始化列表位置 CRect listrc = m_rcarray.ElementAt(6); CRect rc; GetClientRect(rc); rc.top = listrc.top; m_List1.MoveWindow(rc); //创建图标列表控件 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); // 2015.11.13 保存列表添加多一列商品备注选项; m_List3.InsertColumn(6, _T("备注"), LVCFMT_LEFT, 300); #endif//LKAY_VERSION CString path, str; m_path = g_path3 + _T("\\"); m_path += m_strOrderNumber; m_path += _T("\\"); GetPhotos(); { //选设计模式 GetData(); if (m_checkstatus != _T("未看")) { 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; } } } //记录已删除的相片 RecordDeletedPhotos(&m_delphotos, m_DelPhotoPath); } //在界面上显示图片; LoadPhotos(); if (atoi(g_cominfoarray.ElementAt(0).ElementAt(95)) || g_cominfoarray.ElementAt(0).ElementAt(95) == _T("")) { 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; } void ChooseDesignSkin::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 ChooseDesignSkin::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(); } //清除资源的路径 ClearResData(); if(m_pHideImg) delete m_pHideImg; CDialog::OnDestroy(); } catch (...) { } } #ifdef VC60 void ChooseDesignSkin::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; if(INDX_SEL == m_SelectCategory) OnSelPhoto(); LoadPhotos(); } break; case 3://查看未选按钮事件; { m_SelectCategory = INDX_NOSEL; m_sChooseFilter = _T(""); UpdateChooseZS(); GetNoSelPhoto(); LoadPhotos(); } break; case 13: // 查看入册相片按钮事件; GetAlbumPhoto(); LoadPhotos(); break; case 14: // 查看入底相片按钮事件; GetDiskPhoto(); LoadPhotos(); break; case 15: // 效果图按钮事件; { ShowEffectDlg dlg; dlg.m_pPhotopatharray = this->GetCurArray(m_SelectCategory); 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 6: // 关闭按钮事件 ; if (m_bModify && m_bCanSave) { ShowMsg3 dlg; dlg.m_strMsg = _T("提醒, 选片修改未保存, 是否保存后再退出?"); // if (AfxMessageBox(_T("提醒, 选片修改未保存, 是否保存后再退出?"), MB_YESNO | MB_ICONINFORMATION) == IDYES) if(dlg.DoModal() == IDOK) { OnButton4(); if (m_bSaveFail) { AfxMessageBox(_T("连接服务器失败, 保存失败, 您可以在本机上重新进入选片恢复到选中状态!")); CDialog::OnCancel(); return; } return; } else { CString savepath = _T(""); savepath.Format(_T("%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: ReplaceDesignNo dlg; dlg.m_id = this->m_strOrderNumber; dlg.DoModal(); break; } } #else LRESULT ChooseDesignSkin::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 0; m_SelectCategory = id - 1; if(INDX_SEL == m_SelectCategory) OnSelPhoto(); LoadPhotos(); } break; case 3://查看未选按钮事件; { m_SelectCategory = INDX_NOSEL; m_sChooseFilter = _T(""); UpdateChooseZS(); GetNoSelPhoto(); LoadPhotos(); } break; case 13: // 查看入册相片按钮事件; GetAlbumPhoto(); LoadPhotos(); break; case 14: // 查看入底相片按钮事件; GetDiskPhoto(); LoadPhotos(); break; case 15: // 效果图按钮事件; { ShowEffectDlg dlg; dlg.m_pPhotopatharray = this->GetCurArray(m_SelectCategory); 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 6: // 关闭按钮事件 ; if (m_bModify && m_bCanSave) { ShowMsg3 dlg; dlg.m_strMsg = _T("提醒, 选片修改未保存, 是否保存后再退出?"); // if (AfxMessageBox(_T("提醒, 选片修改未保存, 是否保存后再退出?"), MB_YESNO | MB_ICONINFORMATION) == IDYES) if(dlg.DoModal() == IDOK) { OnButton4(); if (m_bSaveFail) { AfxMessageBox(_T("连接服务器失败, 保存失败, 您可以在本机上重新进入选片恢复到选中状态!")); CDialog::OnCancel(); return 0; } return 0; } else { CString savepath = _T(""); savepath.Format(_T("%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: ReplaceDesignNo dlg; dlg.m_id = this->m_strOrderNumber; dlg.DoModal(); break; } return 0; } #endif BOOL ChooseDesignSkin::OnEraseBkgnd(CDC* pDC) { return 1; } BEGIN_EVENTSINK_MAP(ChooseDesignSkin, CDialog) ON_EVENT(ChooseDesignSkin, 100, 150 /* FSCommand */, OnFSCommandShockwaveflash1, VTS_BSTR VTS_BSTR) END_EVENTSINK_MAP() void ChooseDesignSkin::OnFSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args) { } //------------------------------------------------------------------ // 函数:OnDblclkList1 // 描述:处理双击和回车时的图片显示效果;与函数名本身的表达意义不一致,导致歧义! // 参数: // 返回: //------------------------------------------------------------------ void ChooseDesignSkin::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 // 这一块代码是用于处理回车键; CArrayposarray; posarray.Add(iItem); // 获取剩下的图片位置; while (pos) { int iItem = m_List1.GetNextSelectedItem(pos); posarray.Add(iItem); if (posarray.GetSize() > 3) break; } if (posarray.GetSize() >= 2) { CStringArray* pPtahArray = NULL; pPtahArray = GetCurArray(m_SelectCategory); CComparePhoto dlg; dlg.m_path1 = pPtahArray->ElementAt(posarray.ElementAt(0)); dlg.m_path2 = pPtahArray->ElementAt(posarray.ElementAt(1)); if (posarray.GetSize() > 2) dlg.m_path3 = pPtahArray->ElementAt(posarray.ElementAt(2)); if (posarray.GetSize() > 3) dlg.m_path4 = pPtahArray->ElementAt(posarray.ElementAt(3)); dlg.DoModal(); return; } #endif //JEFF_TEST_OFF 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; dlg.m_bShowImgInfo = 1; dlg.m_pParent = this; dlg.m_nCurImgPos = iItem; CStringArray* pArray = GetCurArray(m_SelectCategory); if(pArray == NULL) return; dlg.m_AryOfImgPath = pArray; dlg.DoModal(); m_showpichwd = NULL; } void ChooseDesignSkin::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) // 双击图片列表! { OnDblclkList1(); *pResult = 0; } /************************************************************************/ /* 函数: GetData 描述: 选片模式 参数: 返回: 注意: */ /************************************************************************/ BOOL ChooseDesignSkin::GetData()//选片模式; { m_List2.DeleteAllItems(); m_List3.DeleteAllItems(); m_noarray.RemoveAll(); m_no2array.RemoveAll(); m_oldsparray.RemoveAll(); //选设计 CString filter = _T(""); #ifdef CHILD_VERSION filter = "id='" + m_strOrderNumber + "';id='" + m_strOrderNumber + "';;;id='" + m_strOrderNumber + "'"; #else filter = "id='" + m_strOrderNumber + "' and kind<>'2';id='" + m_strOrderNumber + "';;;id='" + m_strOrderNumber + "'"; #endif //CHILD_VERSION //订单号、商品编号、商品价格、订单商品数量、商品类型、商品名称、选片选中相片名、自增id、选设计选中相片名; 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 sparray; //dindansp表;//订单号、商品编号、商品价格、订单商品数量、商品类型、商品名称、选片选中相片名、自增id、选设计选中相片名; DataToArray(&sparray, &g_List1array, &m_sparray, &m_List2array, &m_oldsparray); m_SelPhotoPath.RemoveAll(); CString str(_T("")), kind(_T("")); int nchoosezs = 0; int list2pos = 0; int list3pos = 0; CString savepath = _T(""); savepath.Format(_T("%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(_T("%Y%m%d")); BOOL bLoadHistory = 0; if (PathFileExists(savepath) && stm1 > stm2) { if (AfxMessageBox(_T("提醒:请谨慎操作\r\n上次选片未正常退出, 是否还原到上次选片状态?"), MB_YESNO | MB_ICONINFORMATION) == IDYES) bLoadHistory = 1; } int i = 0; if (bLoadHistory) { //还原到上次选片状态 CArray 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 = 0; memcpy(&count, szChatMessage + (nMessageLen - sizeof(int)), sizeof(int)); CMemFile memfile; memfile.Attach(szChatMessage, nMessageLen); CArchive ar(&memfile, CArchive::load); List1array.SetSize(count); for ( 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)); m_List3.SetItemText(list3pos, 6, List1array.ElementAt(i).ElementAt(9)); #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 //#ifdef LKAY_VERSION list3pos++; } nchoosezs += GetZS(str); GetPathAddToSel(str); if (!str.IsEmpty()) { #ifdef USE_SEP_VEB str = SEPS_VEB + str + SEPS_VEB; #else str = SEPS_CMA + str + SEPS_CMA; #endif //#ifdef USE_SEP_VEB } str.MakeLower(); if (kind == _T("4")) m_no2array.Add(str); else m_noarray.Add(str); } } else { for ( i = 0; i < sparray.GetSize(); i++) { kind = _T("4");//sparray.ElementAt (i).ElementAt (4); if (kind == _T("4")) { m_List3.InsertItem(list3pos, sparray.ElementAt(i).ElementAt(7)); // dindansp表autoid; 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)); // 选设计时选中的相片名; m_List3.SetItemText(list3pos, 6, sparray.ElementAt(i).ElementAt(9)); // 商品备注; #endif list3pos++; } else { m_List2.InsertItem(list2pos, sparray.ElementAt(i).ElementAt(7)); // dindansp表autoid; 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)); // 选设计时选中的相片名; list2pos++; } str = sparray.ElementAt(i).ElementAt(8); str.MakeLower(); nchoosezs += GetZS(str); // 获取no或no2字段中包含的相片名数量; GetPathAddToSel(str); if (!str.IsEmpty()) { #ifdef USE_SEP_VEB str = SEPS_VEB + str + SEPS_VEB; #else str = SEPS_CMA + str + SEPS_CMA; #endif //#ifdef USE_SEP_VEB } if (kind == _T("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); #ifdef USE_SEP_VEB if (!m_name1.IsEmpty()) m_name = m_name1 + SEPS_VEB; m_name += m_name2; m_name.TrimRight(SEPS_VEB); #else if (!m_name1.IsEmpty()) m_name = m_name1 + SEPS_CMA; m_name += m_name2; m_name.TrimRight(SEPS_CMA); #endif //#ifdef USE_SEP_VEB 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字段; if ( m_delphotos.GetAt(0) != SEPC_VEB || m_delphotos.GetAt(m_delphotos.GetLength() -1) != SEPC_VEB ) { m_delphotos.TrimLeft(SEPC_VEB); m_delphotos.TrimRight(SEPC_VEB); m_delphotos = SEPS_VEB + m_delphotos + SEPS_VEB; } 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 = _T(""); m_name2 = _T(""); m_waiter3 = _T(""); m_taoxizs = _T(""); m_time5 = _T(""); m_takezs = _T(""); m_choosezs = _T(""); m_money3 = ""; m_bz3 = _T(""); m_urgent = _T(""); UpdateData(false); } return 1; } void ChooseDesignSkin::OnClose() { /* if (m_bModify) { ShowMsg3 dlg; dlg.m_strMsg = _T("提醒, 选片修改未保存, 是否保存后再退出?"); if(dlg.DoModal() == IDOK) OnButton4(); } */ CDialog::OnClose(); } BOOL ChooseDesignSkin::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 (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(); //更新绘制 DrawInterface(); // LoadPhotos(); } return 1; case VK_RETURN: OnDblclkList1(); return 1; case VK_F4: if (m_bChooseBig == 0) return 1; if (atoi(g_cominfoarray.ElementAt(0).ElementAt(62))) { if (m_SelectCategory == INDX_SEL) UpdateChooseZS(); SortArray(); } return 1; case VK_F5: if (atoi(g_cominfoarray.ElementAt(0).ElementAt(86))) { OnBtnClick(0, 99 + 4); } return 1; case VK_F1: { if (m_selphotownd2.GetSafeHwnd() == NULL) { m_selphotownd2.m_id = m_strOrderNumber; m_selphotownd2.m_bGrowthTX = m_bGrowthTX; m_selphotownd2.m_seltxname = m_seltxname; 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_bChooseBig == 0) return 1; if (atoi(g_cominfoarray.ElementAt(0).ElementAt(60))) { m_bHide = !m_bHide; LoadPhotos(); } return 1; case VK_F6: { ReplaceDesignNo dlg; dlg.m_id = this->m_strOrderNumber; dlg.DoModal(); } return 1; case VK_ESCAPE: { return TRUE; } break; } } else if(pMsg->message == WM_LBUTTONUP) { CDialog::PreTranslateMessage(pMsg); return TRUE; } return CDialog::PreTranslateMessage(pMsg); } // 右键选片模式; void ChooseDesignSkin::OnRclickList1() { if (m_bRunning) return; CMenuXP *pPopup = NULL; POSITION pos; pos = m_List1.GetFirstSelectedItemPosition(); if (pos == NULL) return; CString path = _T(""); CStringArray* pArray = NULL; int iItem = m_List1.GetNextSelectedItem(pos); pArray = GetCurArray(m_SelectCategory); path = pArray->ElementAt(iItem); //path//打印出相片完整路径名; // 右键看设计模式; if (!m_bChooseBig) path = path.Right(path.GetLength() - m_path.GetLength()); else path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1); path = path.Left(path.ReverseFind('.')); #ifdef USE_SEP_VEB path = SEPS_VEB + path + SEPS_VEB; // #else path = SEPS_CMA + path + SEPS_CMA; // #endif //#ifdef USE_SEP_VEB // TODO: Add your control notification handler code here // 1.创建菜单对象; // 1.创建菜单对象; 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 i = 0; int maxleng = 1; { CString name, no; int count = 0; for ( 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 scount = _T(""); CString name, no; int count = 0; for ( 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));// 2.使用AppendODMenu2添加子菜单项; //绑定事件ID 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); // 3.使用TrackPopupMenu,正常弹出菜单; pPopup->TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this, 0); delete pPopup; } void ChooseDesignSkin::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult) { if (m_showpichwd) return; OnRclickList1(); *pResult = 0; } // /************************************************************************/ /* 函数: OnCommandMenu 描述: 弹出菜单处理; 参数: UINT nID 事件ID 返回: 注意: */ /************************************************************************/ void ChooseDesignSkin::OnCommandMenu(UINT nID) { //看设计事件 OnCommandMenu2(nID); return; } /************************************************************************/ /* 函数: OnCommandMenu2 描述: 看设计,弹出菜单处理; 参数: UINT nID 事件ID 返回: 注意: */ /************************************************************************/ void ChooseDesignSkin::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(m_SelectCategory); 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(m_SelectCategory); // 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('.')); #ifdef USE_SEP_VEB path = SEPS_VEB + path + SEPS_VEB; // #else path = SEPS_CMA + path + SEPS_CMA; // #endif //#ifdef USE_SEP_VEB 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; #ifdef USE_SEP_VEB no.TrimRight(SEPS_VEB); #else no.TrimRight(SEPS_CMA); #endif //#ifdef USE_SEP_VEB no += path; } #ifdef USE_SEP_VEB no.TrimLeft(SEPS_VEB); no.TrimRight(SEPS_VEB); #else no.TrimLeft(SEPS_CMA); no.TrimRight(SEPS_CMA); #endif //#ifdef USE_SEP_VEB m_List2.SetItemText(idpos, 4, no); if (no.IsEmpty()) m_noarray.SetAt(idpos, no); else { #ifdef USE_SEP_VEB m_noarray.SetAt(idpos, SEPS_VEB + no + SEPS_VEB); #else m_noarray.SetAt(idpos, SEPS_CMA + no + SEPS_CMA); #endif //#ifdef USE_SEP_VEB } } 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; #ifdef USE_SEP_VEB no.TrimRight(SEPS_VEB); #else no.TrimRight(SEPS_CMA); #endif //#ifdef USE_SEP_VEB no += path; } #ifdef USE_SEP_VEB no.TrimLeft(SEPS_VEB); no.TrimRight(SEPS_VEB); #else no.TrimLeft(SEPS_CMA); no.TrimRight(SEPS_CMA); #endif //#ifdef USE_SEP_VEB #ifdef LKAY_VERSION m_List3.SetItemText (idpos, 7, no); #else m_List3.SetItemText(idpos, 5, no); #endif //#ifdef LKAY_VERSION if (no.IsEmpty()) m_no2array.SetAt(idpos, no); else { #ifdef USE_SEP_VEB m_no2array.SetAt(idpos, SEPS_VEB + no + SEPS_VEB); #else m_no2array.SetAt(idpos, SEPS_CMA + no + SEPS_CMA); #endif //#ifdef USE_SEP_VEB } } m_bModify = 1; if (bSel == 0 && m_SelectCategory == INDX_SEL && IsSelPhoto(path) == 0) { temp.Format("%d", iItem); m_combo1.AddString(temp); continue; } else if (bSel == 1 && m_SelectCategory == INDX_NOSEL) { temp.Format("%d", iItem); m_combo1.AddString(temp); continue; } else if (bSel == 1 && m_SelectCategory == INDX_DEL) { 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); } CArrayposarray; 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 == INDX_SEL) { for (int i = 0; i < posarray.GetSize(); i++) { m_List1.DeleteItem(posarray.ElementAt(i)); m_NoSelPhotoPath.Add(m_SelPhotoPath.ElementAt(posarray.ElementAt(i))); m_SelPhotoPath.RemoveAt(posarray.ElementAt(i)); } if (m_showpichwd) ::SendMessage(m_showpichwd, WM_CLOSE, 0, 0); } else if (m_SelectCategory == INDX_NOSEL) { for (int i = 0; i < posarray.GetSize(); i++) { m_List1.DeleteItem(posarray.ElementAt(i)); m_NoSelPhotoPath.RemoveAt(posarray.ElementAt(i)); } if (m_showpichwd) ::SendMessage(m_showpichwd, WM_CLOSE, 0, 0); } else if (m_SelectCategory == INDX_DEL) { for (int i = 0; i < posarray.GetSize(); i++) { m_List1.DeleteItem(posarray.ElementAt(i)); m_AllPhotoPath.Add(m_DelPhotoPath.ElementAt(posarray.ElementAt(i))); m_DelPhotoPath.RemoveAt(posarray.ElementAt(i)); } if (m_showpichwd) ::SendMessage(m_showpichwd, WM_CLOSE, 0, 0); } } CString strFile = m_strOrderNumber + _T("-2.dat"); Save(g_mainpath, strFile); DrawInterface(); if (m_showpichwd) ::SendMessage(m_showpichwd, WM_USER + 200, 0, 0); } long ChooseDesignSkin::UpdateTakeZS(WPARAM inWParam, LPARAM inLParam) { if (m_SelectCategory == INDX_ALL && m_List1.GetItemCount() > atoi(m_takezs)) { UpdateData(); m_takezs.Format("%d", m_List1.GetItemCount()); UpdateData(false); } //绘制 DrawInterface(); return 1; } /************************************************************************/ /* 函数: UpdateChooseZS 描述: 更新选中相片 参数: 返回: 注意: */ /************************************************************************/ void ChooseDesignSkin::UpdateChooseZS() { int i = 0; CString str = _T(""); CStringArray* pSelArr = NULL; CStringArray* pAllArr = NULL; pSelArr = GetCurArray(INDX_SEL); pAllArr = GetCurArray(INDX_ALL); pSelArr->RemoveAll(); if (m_sChooseFilter != _T("") && m_sChooseFilter != _T("全部")) { for ( i = 0; i < m_List3.GetItemCount(); i++) { if (m_List3.GetItemText(i, 2) != m_sChooseFilter) continue; str = m_no2array.ElementAt(i); GetPathAddToSel(pSelArr, str, pAllArr); } return; } for ( i = 0; i < m_noarray.GetSize(); i++) { str = m_noarray.ElementAt(i); GetPathAddToSel(pSelArr, str, pAllArr); } for (i = 0; i < m_no2array.GetSize(); i++) { str = m_no2array.ElementAt(i); GetPathAddToSel(pSelArr, str, pAllArr); } } // 保存按钮; void ChooseDesignSkin::OnButton4()// 保存按钮; { UpdateData(); if (m_SelectCategory != INDX_SEL) CalChooseZS(&m_SelPhotoPath, &m_AllPhotoPath); CString zs = m_taoxizs; int pos = zs.Find("\\"); if (pos != -1) { zs = zs.Left(pos); } m_choosezs.Format("%d", max(0, m_SelPhotoPath.GetSize() - atoi(zs))); m_bSaveFail = 0; ChoosePhotoSkin3 dlg; dlg.m_pParent = this; dlg.DoModal(); if (dlg.m_bSave) m_bModify = 0; if (dlg.m_bPushedSave == 0 && dlg.m_bSaveFail == 0) { CString savepath = _T(""); 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 ChooseDesignSkin::OnDel() // 删除相片; { // printf("Jeff:m_mode=%d,m_mode2=%d.\n\n",m_mode,m_mode2);//Jeff Printf if (m_SelectCategory == INDX_SEL) { AfxMessageBox("选中照片不能删除, 请先取消选中状态!", MB_ICONINFORMATION); return 0; } else if (m_SelectCategory == INDX_DEL) { return 0; } POSITION pos; pos = m_List1.GetFirstSelectedItemPosition(); if (pos == NULL) return 0; if (m_bRunning) return 0; CStringArray* pArray = NULL; CString strDelPhotoName = _T(""); CString strSelPhotoPath = _T(""); int iItem = m_List1.GetNextSelectedItem(pos); int nItemIdx = iItem; pArray = GetCurArray(m_SelectCategory); strSelPhotoPath = pArray->ElementAt(nItemIdx); strDelPhotoName = strSelPhotoPath; if(strDelPhotoName == _T("") || pArray == NULL) return 0; strDelPhotoName = strDelPhotoName.Right(strDelPhotoName.GetLength() - strDelPhotoName.ReverseFind('\\') - 1); strDelPhotoName = strDelPhotoName.Left(strDelPhotoName.Find('.')); if (IsSelPhoto(strDelPhotoName)) // Jeff 这里有问题,有些订单删除未选中的相片时,会提示box内容。状态:未处理; { AfxMessageBox(_T("选中的照片不能删除, 请先取消选中状态!"), MB_ICONINFORMATION); return 0; } if (AfxMessageBox(_T("是否删除此照片?"), MB_YESNO | MB_ICONINFORMATION) != IDYES) return 0; //将要删除的相片添加到删除数组里 #if JEFF_TEST_ON if(PathFileExists(strSelPhotoPath)) m_DelPhotoPath.Add(strSelPhotoPath); #else m_DelPhotoPath.Add(strSelPhotoPath); #endif //#if JEFF_TEST_ON // printf("Jeff:将要删除的相片=%s\n\n",name);// Jeff Printf; for(int i = 0; i < pArray->GetSize(); i++) { //字符串比较相同=0 if(strSelPhotoPath.CollateNoCase(pArray->ElementAt(i)) == 0) { pArray->RemoveAt(i); m_List1.DeleteItem(iItem); break; } } if(m_SelectCategory == INDX_NOSEL) DelPhotoFromName(m_AllPhotoPath, strDelPhotoName); m_bModify = 1; //设置默认选项 if(iItem >= pArray->GetSize()) iItem = 0; m_List1.SetItemState(iItem, LVIS_SELECTED, LVIS_SELECTED); return 1; } void ChooseDesignSkin::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) { *pResult = 0; } void ChooseDesignSkin::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(); } } /************************************************************************/ /* 函数: LoadPhotos 描述: 加载图片 参数: 返回: */ /************************************************************************/ void ChooseDesignSkin::LoadPhotos() { TerminateThread(); //清除资源的路径 ClearResData(); DWORD tm1(0), tm2(0); tm1 = GetTickCount(); //获取当前查看的相片 CStringArray *pArray = GetCurArray(m_SelectCategory); for (int i = 0; i < pArray->GetSize(); i++) { CString filePath = pArray->ElementAt(i); if(filePath == _T("")) continue; SResData* pRes = new SResData(); pRes->nType = (int)TYPE_ICON; //转为小写 filePath.MakeLower(); pRes->strFilePath = filePath; m_vResData.push_back(pRes); } tm2 = GetTickCount(); printf("绘制图片的准备时间:%dms\n", (tm2-tm1)); //创建绘画线程LoadThumbNail3 LoadThumbImages(); } /************************************************************************/ /* 函数: GetNoSelPhoto 描述: 未选中的相片 参数: 返回: 注意: */ /************************************************************************/ void ChooseDesignSkin::GetNoSelPhoto() { CStringArray* pNoSelArr = NULL; CStringArray* pAllArr = NULL; CStringArray* pSelArr = NULL; pNoSelArr = GetCurArray(INDX_NOSEL); pAllArr = GetCurArray(INDX_ALL); pSelArr = GetCurArray(INDX_SEL); if(pNoSelArr == NULL || pAllArr == NULL || pSelArr == NULL) return; pNoSelArr->RemoveAll(); CString str1(_T("")), str2(_T("")); for (int i = 0; i < pAllArr->GetSize(); i++) { BOOL bFind = 0; for (int j = 0; j < pSelArr->GetSize(); j++) { str1 = pAllArr->ElementAt(i); str2 = pSelArr->ElementAt(j); if (str1.CollateNoCase(str2) == 0) { bFind = 1; break; } } if (bFind == 0) pNoSelArr->Add(pAllArr->ElementAt(i)); } } /************************************************************************/ /* 函数: OnSelPhoto 描述: 查看选中相片 参数: 返回: 注意: */ /************************************************************************/ void ChooseDesignSkin::OnSelPhoto() { ProductChooseFilter dlg; CString name = _T(""); int i = 0; for ( 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); } if(dlg.DoModal() == IDCANCEL) { m_SelectCategory = INDX_ALL; return; } m_sChooseFilter = dlg.m_sChooseFilter; UpdateChooseZS(); } /************************************************************************/ /* 函数: GetCurArray 描述: 获取要查看的数据 参数: const int nIndx 选中数据索引 SFolderInfo* m_pForder 文件夹 返回: 注意: */ /************************************************************************/ CStringArray* ChooseDesignSkin::GetCurArray(const int nIndx) { CStringArray* pArray = NULL; switch (nIndx) { case INDX_ALL: //全部 pArray = &m_AllPhotoPath; break; case INDX_SEL: //选中 pArray = &m_SelPhotoPath; break; case INDX_NOSEL: //未选 pArray = &m_NoSelPhotoPath; break; case INDX_DEL: //删除 pArray = &m_DelPhotoPath; break; case INDX_INTOALBUM: //入册 pArray = &m_IntoAlbumPath; break; case INDX_ENTRYPHASSE: //入底 pArray = &m_EntryPhasepath; break; } return pArray; } /************************************************************************/ /* 函数: SortArray 描述: 按F4乱序或排序 参数: 返回: */ /************************************************************************/ void ChooseDesignSkin::SortArray() { int i = 0; int j = 0; m_bSort = !m_bSort; CStringArray *pArray[6] = { &m_AllPhotoPath, &m_SelPhotoPath, &m_NoSelPhotoPath, &m_DelPhotoPath, &m_IntoAlbumPath, &m_EntryPhasepath }; if (m_bSort == 0) { for ( 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 ( i = 0; i < 6; i++) { m_combo1.ResetContent(); CString Temp; for ( 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(); //清除资源的路径 ClearResData(); //获取当前查看的相片 CStringArray *pArr = GetCurArray(m_SelectCategory); if(pArr == NULL) return; for ( i = 0; i < pArr->GetSize(); i++) { SResData* pRes = new SResData(); pRes->nType = (int)TYPE_ICON; CString filePath = pArr->ElementAt(i); //转为小写 filePath.MakeLower(); pRes->strFilePath = filePath; m_vResData.push_back(pRes); } //创建绘画线程LoadThumbNail3 LoadThumbImages(); } /*------------------------------------------------------- 函数名: DrawInterface 描述: 绘制界面 参数: 返回值: -------------------------------------------------------*/ void ChooseDesignSkin::DrawInterface() { CRect rc(0, 0, 0, 0), rt(0, 0, 0, 0); ((MyBmpButton2*)m_picarray.ElementAt(3))->GetWindowRect(rc); ScreenToClient(rc); int nH = rc.bottom - rc.top; rc.right -= (rc.left + 100); rc.left = 5; rc.top += 10; rc.right += 220; rc.bottom = rc.top + nH - 10; rt.CopyRect(&rc); 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 = _T(""); str.Format(_T("张数:%d"), m_List1.GetItemCount()); int leng = GetLengthEx(str); BSTR bstr = str.AllocSysString(); Gdiplus::Font* pFont = new Gdiplus::Font(L"黑体", 11); graph.SetTextRenderingHint(TextRenderingHintAntiAlias); graph.DrawString( bstr, leng, pFont, layoutRect, &format, Brush); SysFreeString(bstr); delete Brush; delete pFont; ReleaseDC(pDC); } CString ChooseDesignSkin::GetZSInfo(int iItem) { if (m_SelectCategory != INDX_SEL) CalChooseZS(GetCurArray(INDX_SEL), GetCurArray(INDX_ALL)); CString str = _T(""); CString scount = m_List1.GetItemText(iItem, 0); int ncount = 0; int npos = scount.Find(_T("\r\n")); while (npos != -1) { ncount++; scount = scount.Right(scount.GetLength() - npos - 2); npos = scount.Find(_T("\r\n")); } CString zs = m_taoxizs; int pos = zs.Find("\\"); if (pos != -1) zs = zs.Left(pos); str.Format(_T("X:%d"), ncount); return str; } /************************************************************************/ /* 函数: GetPathAddToSel 描述: 获取路径添加到选中相片 参数: strName:dindansp表中no或no2字段值;相片名间使用逗号分隔; 返回: 1成功,0失败 */ /************************************************************************/ int ChooseDesignSkin::GetPathAddToSel(const CString& strName) { if(strName == _T("")) return 0; CStringArray* pSelArr = NULL; CStringArray* pAllArr = NULL; pSelArr = GetCurArray(INDX_SEL); pAllArr = GetCurArray(INDX_ALL); GetPathAddToSel(pSelArr, strName, pAllArr); return 1; } /************************************************************************/ /* 函数: GetPathAddToSel 描述: 获取路径添加到选中相片 参数: CStringArray* pSelArr const CString& str 返回: 1成功,0失败 */ /************************************************************************/ int ChooseDesignSkin::GetPathAddToSel(CStringArray* pSelArr, const CString& strName, CStringArray* pAllArr) { return ChoosePhotoBase::GetPathAddToSel(pSelArr, strName, pAllArr); } /************************************************************************/ /* 函数: GetAlbumPhoto 描述: 查看入册相片 参数: 返回: */ /************************************************************************/ void ChooseDesignSkin::GetAlbumPhoto() { if (m_SelectCategory == INDX_INTOALBUM) return; m_SelectCategory = INDX_INTOALBUM; CStringArray* pArr = NULL; pArr = GetCurArray(m_SelectCategory); pArr->RemoveAll(); CString photosName = _T(""); int i = 0; for (i= 0; i < m_List3.GetItemCount(); i++) { if (m_List3.GetItemText(i, 2) != _T("入册")) continue; photosName = m_no2array.ElementAt(i); break; } CStringArray* pAllArry = NULL; pAllArry = GetCurArray(INDX_ALL); //将入册的相片名 #ifdef USE_SEP_VEB photosName = SEPS_VEB + photosName + SEPS_VEB; #else photosName = SEPS_CMA + photosName + SEPS_CMA; #endif //#ifdef USE_SEP_VEB for (i = pAllArry->GetSize() - 1; i >= 0; i--) { CString strName = _T(""); strName = pAllArry->ElementAt(i); strName = strName.Right(strName.GetLength() - strName.ReverseFind('\\') - 1); strName = strName.Left(strName.Find('.')); #ifdef USE_SEP_VEB strName = SEPS_VEB + strName + SEPS_VEB; #else strName = SEPS_CMA + strName + SEPS_CMA; #endif //#ifdef USE_SEP_VEB if (photosName.Find(strName) != -1) { strName = pAllArry->ElementAt(i); pArr->Add(strName); } } } /************************************************************************/ /* 函数: GetDiskPhoto 描述: 查看入底相片 参数: 返回: */ /************************************************************************/ void ChooseDesignSkin::GetDiskPhoto() { if (m_SelectCategory == INDX_ENTRYPHASSE) return; m_SelectCategory = INDX_ENTRYPHASSE; CStringArray* pArr = NULL; pArr = GetCurArray(m_SelectCategory); int i = 0; pArr->RemoveAll(); CString photosName = _T(""); for ( i = 0; i < m_List3.GetItemCount(); i++) { if (m_List3.GetItemText(i, 2) != _T("入底")) continue; photosName = m_no2array.ElementAt(i); break; } CStringArray* pAllArry = NULL; pAllArry = GetCurArray(INDX_ALL); #ifdef USE_SEP_VEB photosName = SEPS_VEB + photosName + SEPS_VEB; #else photosName = SEPS_CMA + photosName + SEPS_CMA; #endif //#ifdef USE_SEP_VEB for (i = pAllArry->GetSize() - 1; i >= 0; i--) { CString strName = _T(""); strName = pAllArry->ElementAt(i); strName = strName.Right(strName.GetLength() - strName.ReverseFind('\\') - 1); strName = strName.Left(strName.Find('.')); #ifdef USE_SEP_VEB strName = SEPS_VEB + strName + SEPS_VEB; #else strName = SEPS_CMA + strName + SEPS_CMA; #endif //#ifdef USE_SEP_VEB if (photosName.Find(strName) != -1) { strName = pAllArry->ElementAt(i); pArr->Add(strName); } } } /************************************************************************/ /* 函数名: ReLoad 描述: 重新加载数据 参数: 返回值: */ /************************************************************************/ BOOL ChooseDesignSkin::ReLoad() { return GetData(); } /************************************************************************/ /* 函数: ReLoadPhoto 描述: 重新加载相片 参数: 返回: */ /************************************************************************/ void ChooseDesignSkin::ReLoadPhoto() { if (!((MyBmpButton2*)m_picarray.ElementAt(8))->GetPushDown()) { m_path = g_path3 + _T("\\"); m_path += m_strOrderNumber; m_path += _T("\\"); GetPhotos(); m_bChooseBig = 0; } else { m_bChooseBig = 1; //选择此次拍摄名称DLG(如:拍摄景点) GetTXName(&m_strOrderNumber, 1, m_bGrowthTX, m_seltxname); m_AllPhotoPath.RemoveAll(); if (IsThereACacheImg()) // m_bFromLocal = 1; if (m_AllPhotoPath.GetSize() == 0) { if (IsPhoto2Exist()) { SelBrunDevice dlg; dlg.m_mode = 0; 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 + _T("\\"); m_path += m_strOrderNumber; m_path += _T("\\"); if (m_seltxname != "" && m_seltxname != _T("全部")) { m_path += m_seltxname; m_path += _T("\\"); } if (m_nChoosePhotoType == 1) // 选片:修片 { m_path = g_path2 + _T("\\"); m_path += m_strOrderNumber; m_path += _T("\\"); } CString filename = _T(""); 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_AllPhotoPath.Add(path); #else m_AllPhotoPath.Add(path); #endif //#if JEFF_TEST_ON } 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_AllPhotoPath.Add(path2); } else { path2.Replace(".raw", _T(".jpg")); if (PathFileExists(path2)) { m_AllPhotoPath.Add(path2); continue; } path2.Replace(".nef", _T(".jpg")); if (PathFileExists(path2)) { m_AllPhotoPath.Add(path2); continue; } path2.Replace(".cr2", _T(".jpg")); if (PathFileExists(path2)) { m_AllPhotoPath.Add(path2); continue; } else { if (path.Right(3) != "jpg") continue; #if JEFF_TEST_ON if (PathFileExists(path)) m_AllPhotoPath.Add(path); #else m_AllPhotoPath.Add(path); #endif //#if JEFF_TEST_ON } } } } } } // if(0) {//多种修好的效果 CString path, path2; path2 = g_path2 + _T("\\"); path2 += m_strOrderNumber; path2 += _T("\\"); 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(_T("-")) != -1) { #if JEFF_TEST_ON if (PathFileExists(path)) m_AllPhotoPath.Add(path); #else m_AllPhotoPath.Add(path); #endif //#if JEFF_TEST_ON } } } } } if (m_AllPhotoPath.GetSize() && atoi(g_cominfoarray.ElementAt(0).ElementAt(61))) { int size = m_AllPhotoPath.GetSize() - 1; CString sTemp; int nPos; for (int i = 0; i < size; i++) { nPos = rand() % (size - i); sTemp = m_AllPhotoPath.ElementAt(size - i); m_AllPhotoPath.SetAt(size - i, m_AllPhotoPath.ElementAt(nPos)); m_AllPhotoPath.SetAt(nPos, sTemp); } } } m_SelectCategory = INDX_ALL; LoadPhotos(); } /************************************************************************/ /* 函数: DrawImageWork 描述: 绘制工作 参数: 返回: */ /************************************************************************/ void ChooseDesignSkin::DrawImageWork() { CListCtrl* ListCtrl = &m_List1; CImageList* pImgList = &m_ImageListThumb; try { // 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(m_vResData.size()); // Set redraw to FALSE to avoid flickering during adding new items ListCtrl->SetRedraw(FALSE); //添加列表项名 AddListItemName(ListCtrl); //设置重绘并刷新 ListCtrl->SetRedraw(TRUE); ListCtrl->Invalidate(); //绘制图标 DrawImage(ListCtrl, pImgList); m_bRunning = false; m_bTerminate = false; PostMessage(WM_USER + 200, 0, 0); return; } catch (...) { ListCtrl->Invalidate(); m_bRunning = false; m_bTerminate = false; PostMessage(WM_USER + 200, 0, 0); } } /************************************************************************/ /* 函数: AddListItemName 描述: 添加列表项名 参数: 返回: 1成功,0失败 */ /************************************************************************/ int ChooseDesignSkin::AddListItemName(CListCtrl* pListCtrl) { if(pListCtrl == NULL) return 0; int nIndex = 0; CString str(_T("")), spath(_T("")); //添加文件名 vector::iterator iter; for(iter = m_vResData.begin(); iter != m_vResData.end() && m_bTerminate != true; iter++, nIndex++) { SResData* pRes = (*iter); if(pRes == NULL) continue; str = pRes->strFilePath; if (str.Left(str.ReverseFind('\\') + 1) != m_path) { spath = str.Left(str.ReverseFind('\\') + 1); spath = spath.Right(spath.GetLength() - m_path.GetLength()); } str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1); //添加名字 if (str.Find("delgabook") != -1) { str.TrimRight(_T("\\")); str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1); str.Replace("delgabook", "Flash"); pListCtrl->InsertItem(nIndex, str, nIndex); } else { str = spath + str.Left(str.GetLength() - 4); CString temp = GetSelName(str); pListCtrl->InsertItem(nIndex, str + temp, nIndex); } } return 1; } /************************************************************************/ /* 函数: DrawImage 描述: 绘制 参数: 返回: */ /************************************************************************/ void ChooseDesignSkin::DrawImage(CListCtrl* pListCtrl, CImageList* pImgList) { if(pListCtrl == NULL) return; int nIndex = 0; Image* pHideImg = NULL; //相片图标 CString str(_T("")), spath(_T("")); vector::iterator iter; for (iter = m_vResData.begin(); iter != m_vResData.end() && m_bTerminate != true; iter++, nIndex++) { // Load Image File Image *image = NULL; Bitmap *pBmp = NULL; SResData* pRes = (*iter); if(pRes == NULL) continue; BOOL bNullimg = FALSE; //加载相片图标res\未标题-1.jpg switch(pRes->nType) { case TYPE_ICON: //相片图标 { if(m_bHide && pHideImg == NULL) pHideImg = m_pHideImg; //是否要重新加载资源 if(pHideImg == NULL) { ReLoadImageFromRes(&image, pRes->strFilePath, bNullimg); if(image == NULL) continue; } else image = pHideImg; } break; } //创建bitmap使用颜色填充区域 SolidBrush whitebrush(Color(255, 255, 255, 255)); 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); // 缩放图片符合画布大小 Rect desRect(0, 0, 0, 0); ZoomImage(image, desRect); // 绘制图标res\未标题-1.jpg Graphics graph(pBmp); graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel); // 将图片替换bitmap添加到图标列表 CBitmap bitmap; HBITMAP hbmp; pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp); bitmap.Attach(hbmp); pImgList->Replace(nIndex, &bitmap, NULL); if(pBmp) delete pBmp; // Redraw only a current item for removing flickering and fast speed. pListCtrl->RedrawItems(nIndex, nIndex); // Release used DC and Object if(image && pRes->nType == TYPE_ICON && pHideImg == NULL) delete image; } pListCtrl->Invalidate(); }