// ChoosePhotoSkin2.cpp : implementation file // #include "stdafx.h" #include "ChoosePhotoSkin2.h" #include "LYFZIPManage.h" #include "./helper/ffsco.h" #include ".\MenuBarXP\MenuXP.h" #include "ChoosePhotoSkin3.h" #include "ShowPic22.h" #include "ClientRequirement.h" #include "MyLock.h" #define THUMBNAIL_WIDTH 100 #define THUMBNAIL_HEIGHT 90 extern RESDATA2 g_resdata2; extern BOOL g_bAlphaWnd; extern HCURSOR g_cursorhand; ///////////////////////////////////////////////////////////////////////////// // ChoosePhotoSkin2 dialog ChoosePhotoSkin2::ChoosePhotoSkin2(CWnd* pParent /*=NULL*/) : CDialog(ChoosePhotoSkin2::IDD, pParent) { //{{AFX_DATA_INIT(ChoosePhotoSkin2) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pBk=NULL; m_pParent=NULL; m_name1 = _T(""); m_name2 = _T(""); m_time4 = CTime::GetCurrentTime ().Format ("%Y-%m-%d"); m_waiter3 = _T(""); m_takezs = _T(""); m_taoxizs = _T(""); m_choosezs = _T(""); m_id = _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_mode=0; m_showpichwd=NULL; m_mode2=0; g_pMainWnd->GetSkin(); m_bSort=0; } ChoosePhotoSkin2::ChoosePhotoSkin2(DWORD id, CWnd* pParent) : CDialog(id, pParent) { //{{AFX_DATA_INIT(ChoosePhotoSkin2) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT 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_id); 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_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) ON_BN_CLICKED(IDC_BUTTON4, OnButton4) ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1) ON_WM_TIMER() ON_BN_CLICKED(IDC_BUTTON7, OnSpBox) ON_BN_CLICKED(IDC_BUTTON8, OnButton8) ON_BN_CLICKED(IDC_BUTTON5, OnButton5) ON_BN_CLICKED(IDC_BUTTON6, OnButton6) //}}AFX_MSG_MAP ON_MESSAGE(WM_USER+1101,OnBtnClick) ON_COMMAND_RANGE(IDM_MENUsp1, IDM_MENUsp1+31, OnCommandMenu) ON_MESSAGE(WM_USER+200, UpdateTakeZS) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // ChoosePhotoSkin2 message handlers extern void SizeToContent(HWND hwnd, Image *img); extern void DeleteDirectory(CString strDir); void ChoosePhotoSkin2::OnBtnClick (WPARAM wParam, LPARAM lParam) { int id=lParam; id-=99; switch(id) { case 1: case 2: case 4: if(m_mode==id-1)return; m_mode=id-1; LoadPhotos(); break; case 3: if(m_mode==id-1)return; UpdateChooseZS(); GetNoSelPhoto(); m_mode=id-1; LoadPhotos(); break; case 5: OnButton4(); break; case 9: { CClientRequirement dlg; dlg.m_bz2=m_bz2; dlg.m_id=m_id; dlg.m_bSave =1; dlg.DoModal (); m_bz2=dlg.m_bz2; } break; case 10: { if(AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO|MB_ICONSTOP)!=IDYES)return ; CString path=m_path; path.TrimRight ('\\'); DeleteDirectory(path); GetPhotos(); LoadPhotos(); } break; case 11: { 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); ::DeleteFile (m_path+title+".jpg"); ::DeleteFile (m_path+"s"+title+".jpg"); } GetPhotos(); LoadPhotos(); } break; case 6: if(m_bModify) { if(AfxMessageBox("提醒, 选片修改未保存, 是否保存后再退出?", MB_YESNO|MB_ICONINFORMATION)==IDYES) { OnButton4(); } else { CString savepath; savepath.Format ("%s\\%s.dat", g_mainpath, m_id); ::DeleteFile (savepath); } } g_bInSkin=0; CDialog::OnCancel (); break; } } BOOL ChoosePhotoSkin2::OnInitDialog() { CDialog::OnInitDialog(); g_bInSkin=1; // TODO: Add extra initialization here if(g_cursorhand==NULL) g_cursorhand=AfxGetApp()->LoadCursor(IDC_CURSORHAND); BYTE *pData=NULL; BYTE *pDataBegin; if(!LoadLia(g_mainpath+"\\skin\\"+m_liapath, &pData, &pDataBegin, &m_pBk, m_hWnd)) { EndDialog(0); return false; } /* CFile fp; if(!fp.Open (g_mainpath+"\\skin\\"+m_liapath, CFile::modeRead)) { AfxMessageBox(_T("lia文件未找到."), MB_ICONINFORMATION); EndDialog(0); return false; } DWORD count=fp.GetLength (); BYTE *pData=new BYTE[count]; BYTE *pDataBegin=pData; fp.Read (pData, count); fp.Close (); ///////////// CStringArray childarray; DWORD childlength; memcpy(&childlength, pData, sizeof(DWORD)); pData+=sizeof(DWORD); BYTE *pChildData=new BYTE[childlength]; memcpy(pChildData, pData, childlength); pData+=childlength; CMemFile memfile; memfile.Attach (pChildData,childlength); CArchive ar(&memfile, CArchive::load); childarray.Serialize (ar); ar.Close(); memfile.Detach (); delete []pChildData; ////////////////////// memcpy(&g_resdata2, pData, sizeof(RESDATA2)); pData+=sizeof(RESDATA2); */ for(int i=0; iCreate(str, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW , rc, this, i+100); pic->m_bmpcount =g_resdata2.nPicBmpCount [i]; pic->ReadBmp (&pData, NULL, this); } else m_picarray.Add (NULL); m_rcarray.Add(g_resdata2.rect[i]); } delete []pDataBegin; if(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); } 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 (4))->ShowWindow (SW_HIDE); if(IsHasRights2new(37)==0) { ((MyBmpButton2*)m_picarray.ElementAt (9))->ShowWindow (SW_HIDE); ((MyBmpButton2*)m_picarray.ElementAt (10))->ShowWindow (SW_HIDE); } } #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_mode2==0) ::LoadImageFromBuf (&img, g_mainpath+"\\skin\\标题-选片.jpg"); else ::LoadImageFromBuf (&img, g_mainpath+"\\skin\\标题-看设计.jpg"); graph.DrawImage(img, 0,0); delete img; #endif m_List1.MoveWindow (m_rcarray.ElementAt (6)); CString path,str; if(m_mode2) { m_path=g_path3+"\\"; m_path+=m_id; m_path +="\\"; } if(m_mode2)//看设计 { GetPhotos(); } else { using namespace helper_coffs; ffsco o; o.dirs(0); o.find(LPCSTR(m_path), 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.MakeLower (); m_patharray1.Add (path); } } } if(m_mode2==0) { if(m_patharray1.GetSize ()==0) { if(AfxMessageBox("此单未导入修好的片, 是否用原片选片?", MB_YESNO|MB_ICONINFORMATION)==IDYES) { m_path=g_path1+"\\"; m_path+=m_id; m_path +="\\"; using namespace helper_coffs; ffsco o; o.dirs(0); o.find(LPCSTR(m_path), 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.MakeLower (); m_patharray1.Add (path); } } } } if(m_patharray1.GetSize ()) { int size=m_patharray1.GetSize ()-1; CString sTemp; int nPos; for(int i=0;iScreenToClient(rc); Graphics graph(dc.GetSafeHdc ()); Rect destinationRect(0,0,rc.Width (), rc.Height ()); graph.DrawImage(((ChoosePhotoSkin2*)GetParent())->m_pBk, destinationRect, rc.left , rc.top ,rc.Width (), rc.Height (),UnitPixel); }*/ 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.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.DrawImage(m_pBk, destinationRect, 0,0,width,height,UnitPixel); } catch(...) { } } void ChoosePhotoSkin2::OnDestroy() { try { CDialog::OnDestroy(); TerminateThread(); if(m_pBk)delete m_pBk; MyBmpButton2 *pic=NULL; for(int i=0; iDestroyWindow(); delete pic; } } m_picarray.RemoveAll(); } catch(...) { } } BOOL ChoosePhotoSkin2::OnEraseBkgnd(CDC* pDC) { // TODO: Add your message handler code here and/or call default return 1; } void ChoosePhotoSkin2::SetLiaPath(CString path) { m_liapath=path; } BEGIN_EVENTSINK_MAP(ChoosePhotoSkin2, CDialog) //{{AFX_EVENTSINK_MAP(ChoosePhotoSkin2) ON_EVENT(ChoosePhotoSkin2, 100, 150 /* FSCommand */, OnFSCommandShockwaveflash1, VTS_BSTR VTS_BSTR) //}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP() void ChoosePhotoSkin2::OnFSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args) { // TODO: Add your control notification handler code here } 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; iGetImageCount(); i++) pImgList->Remove(i); // remove all items from list view ListCtrl->DeleteAllItems(); pImgList->SetImageCount(pDlg->m_vFileName.size()); // TCHAR path[MAX_PATH]; vector::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_mode2==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); str=spath+str.Left (str.GetLength ()-4); ListCtrl->InsertItem(nIndex, str, 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)); 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(::PathFileExists (spath)) ::LoadImageFromBuf (&image, spath); else if(::PathFileExists (str)) ::LoadImageFromBuf (&image, str); else continue; if(image->GetWidth()==0) continue; int orientation=GetOrientation(image); if(orientation==8) image->RotateFlip( Rotate270FlipNone ); else if(orientation==6) image->RotateFlip( Rotate90FlipNone ); // 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); 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 } ListCtrl->Invalidate(); pDlg->m_bRunning=false; pDlg->m_bTerminate=false; pDlg->PostMessage(WM_USER+200, 0, 0); return 0; } catch(...) { ListCtrl->Invalidate(); pDlg->m_bRunning=false; pDlg->m_bTerminate=false; pDlg->PostMessage(WM_USER+200, 0, 0); } } void ChoosePhotoSkin2::LoadThumbImages() { } 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; } void ChoosePhotoSkin2::OnDblclkList1() { POSITION pos; pos=m_List1.GetFirstSelectedItemPosition(); if(pos==NULL) { return; } int iItem=m_List1.GetNextSelectedItem(pos); m_showpichwd=NULL; ShowPic22 dlg; dlg.m_pParent =this; dlg.m_pos=iItem; dlg.m_pPathArray=GetCurArray(); dlg.DoModal (); m_showpichwd=NULL; } void ChoosePhotoSkin2::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here OnDblclkList1(); *pResult = 0; } void ChoosePhotoSkin2::GetData() { CString filter="id='"+m_id+"' and kind<>'5';id='"+m_id+"';"; g_sendhead.code[0]=50; g_sendhead.code[1]=11; g_sendhead.code[2]=4; g_sendhead.tabcount=3; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return; CArraysparray; DataToArray(&sparray, &g_List1array, &m_sparray); 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_id); if(::PathFileExists (savepath)) { CArrayList1array; 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; imessage==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(); return 1; case VK_RETURN: OnDblclkList1(); return 1; case VK_F4: SortArray(); return 1; } } return CDialog::PreTranslateMessage(pMsg); } void ChoosePhotoSkin2::OnRclickList1() { if(m_bRunning)return; 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 ('.')); path=","+path+","; // MessageBox(path); // TODO: Add your control notification handler code here CMenuXP *pPopup; pPopup = new CMenuXP; pPopup->CYBUTTONMARGIN=3; pPopup->CreatePopupMenu(); pPopup->SetMenuStyle(CMenuXP::STYLE_XP); CString name,no; int count=0; for(int i=0; iAppendODMenu2(0, new CMenuXPText(IDM_MENUsp1+i, name, NULL)); if(no.Find (path)!=-1) pPopup->CheckMenuItem(IDM_MENUsp1+i, MF_BYCOMMAND | MF_CHECKED); } count=i; for(; iAppendODMenu2(0, new CMenuXPText(IDM_MENUsp1+i, name, NULL)); if(no.Find (path)!=-1) pPopup->CheckMenuItem(IDM_MENUsp1+i, MF_BYCOMMAND | MF_CHECKED); } CPoint pt; ::GetCursorPos (&pt); pPopup->TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this, 0); delete pPopup; } void ChoosePhotoSkin2::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult) { if( m_showpichwd)return; OnRclickList1(); *pResult = 0; } void ChoosePhotoSkin2::OnCommandMenu(UINT nID) { POSITION pos; pos=m_List1.GetFirstSelectedItemPosition(); if(pos==NULL) { return; } CString temp; m_combo1.ResetContent (); while (pos) { 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 ('.')); path=","+path+","; int idpos=nID-IDM_MENUsp1; BOOL bSel=0;//选中还是取消 if(idpos2000) { 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()>2000) { AfxMessageBox("编号太长,选择失败!", MB_ICONSTOP);return; } else { bSel=1; no.TrimRight (","); no+=path; } no.TrimLeft (","); no.TrimRight (","); m_List3.SetItemText (idpos, 5, no); if(no.IsEmpty ()) m_no2array.SetAt (idpos, no); else m_no2array.SetAt (idpos, ","+no+","); } m_bModify=1; // for(int i=0; iElementAt (iItem); no=no.Right (no.GetLength ()-no.ReverseFind ('\\')-1); no=no.Left (no.Find ('.')); no+=GetSelName(no); m_List1.SetItemText (iItem, 0, no); } if(m_combo1.GetCount ()) { if(m_mode==1) { for(int i=m_combo1.GetCount ()-1; i>=0; i--) { m_combo1.GetLBText (i, temp); m_List1.DeleteItem (atoi(temp)); m_patharray3.Add (m_patharray2.ElementAt (atoi(temp))); m_patharray2.RemoveAt (atoi(temp)); } // UpdateChooseZS(); // LoadPhotos(); if( m_showpichwd) ::SendMessage (m_showpichwd, WM_CLOSE, 0, 0); } else if(m_mode==2) { for(int i=m_combo1.GetCount ()-1; i>=0; i--) { m_combo1.GetLBText (i, temp); m_List1.DeleteItem (atoi(temp)); m_patharray3.RemoveAt (atoi(temp)); } if( m_showpichwd) ::SendMessage (m_showpichwd, WM_CLOSE, 0, 0); } else if(m_mode==3) { for(int i=m_combo1.GetCount ()-1; i>=0; i--) { m_combo1.GetLBText (i, temp); m_List1.DeleteItem (atoi(temp)); m_patharray1.Add (m_patharray4.ElementAt (atoi(temp))); m_patharray4.RemoveAt (atoi(temp)); } if( m_showpichwd) ::SendMessage (m_showpichwd, WM_CLOSE, 0, 0); } } Save(); } 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) { UpdateData(); m_takezs.TrimLeft (); if(m_takezs.IsEmpty ()) { m_takezs.Format ("%d", m_List1.GetItemCount () ); UpdateData(false); } return 1; } void ChoosePhotoSkin2::OnButton1() { // TODO: Add your control notification handler code here } void ChoosePhotoSkin2::UpdateChooseZS() { m_patharray2.RemoveAll (); CString str; for(int i=0; iElementAt (iItem); no=no.Right (no.GetLength ()-no.ReverseFind ('\\')-1); no=no.Left (no.Find ('.')); if(IsSelPhoto(no)) { AfxMessageBox("选中的照片不能删除, 请先取消选中状态!", MB_ICONINFORMATION); return 0; } if(AfxMessageBox("是否删除此照片?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return 0; m_List1.DeleteItem (iItem); CString name=pArray->ElementAt (iItem); m_patharray4.Add (name); for(int i=0; iGetSize (); i++) { if(name.CollateNoCase (pArray->ElementAt (i))==0) { pArray->RemoveAt (i); break; } } if(iItem>=pArray->GetSize ()) iItem=0; m_List1.SetItemState (iItem, LVIS_SELECTED, LVIS_SELECTED); return 1; } extern int GetOrientation(Image *image); void ChoosePhotoSkin2::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here *pResult = 0; } void ChoosePhotoSkin2::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default if(nIDEvent==3) { KillTimer(nIDEvent); SetSPName3(); } } float ChoosePhotoSkin2::GetSPPriceFromId(CString id) { for(int i=0; iGetSize (); i++) { if(pArray->ElementAt (i)==*pStr) return i; } return -1; } void ChoosePhotoSkin2::GetPath(CString str) { str.TrimLeft (","); str.TrimRight (","); if(str.IsEmpty ())return; int pos=str.Find (','); CString path; while(pos!=-1) { path=m_path+str.Left (pos)+".jpg"; if(::FindArray(&m_patharray2, &path)==-1)// && ::FindArray(&m_patharray1, &path)!=-1) m_patharray2.Add (path); str=str.Right (str.GetLength ()-pos-1); pos=str.Find (','); } path=m_path+str+".jpg"; if(::FindArray(&m_patharray2, &path)==-1)// && ::FindArray(&m_patharray1, &path)!=-1) m_patharray2.Add (path); } void ChoosePhotoSkin2::LoadPhotos() { if(m_mode==1)UpdateChooseZS(); TerminateThread(); CStringArray *pArray=GetCurArray(); m_vFileName.clear(); for(int i=0; iGetSize (); 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; iProcessChatMessageRequest2(filter);if(g_bSendOK==0)return; DataToArray(&g_List1array); if(g_List1array.GetSize ()) m_bz2=g_List1array.ElementAt (0).ElementAt (7); } void ChoosePhotoSkin2::SortArray() { if(m_mode2)return; m_bSort=!m_bSort; CStringArray *pArray[4]={&m_patharray1,&m_patharray2,&m_patharray3,&m_patharray4}; if(m_bSort==0) { for(int i=0; i<4; i++) { if(pArray[i]->GetSize ()) { int size=pArray[i]->GetSize ()-1; CString sTemp; int nPos; for(int ii=0;iiElementAt (size-ii); pArray[i]->SetAt (size-ii, pArray[i]->ElementAt (nPos)); pArray[i]->SetAt (nPos, sTemp); } } } } else { for(int i=0; i<4; i++) { m_combo1.ResetContent (); CString Temp; for(int j=0; jGetSize (); j++) { m_combo1.AddString (pArray[i]->ElementAt (j)); } for( j=0; jGetSize (); j++) { m_combo1.GetLBText (j, Temp); pArray[i]->SetAt (j, Temp); } } } { TerminateThread(); CStringArray *pArray=GetCurArray(); m_vFileName.clear(); for(int i=0; iGetSize (); i++) { CString filePath=pArray->ElementAt (i); filePath.MakeLower(); m_vFileName.push_back(filePath); } LoadThumbImages(); } } void ChoosePhotoSkin2::CheckForAlbum() { for(int i=0; isparray; sparray.SetSize(m_List2.GetItemCount ()+m_no2array.GetSize ()); for(int i=0; i