12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874 |
- // 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; 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(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);
-
- }
- 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;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("autuid"),LVCFMT_LEFT,0);
- m_List2.InsertColumn(1,_T("编号"),LVCFMT_LEFT,45);
- m_List2.InsertColumn(2,_T("商品名称"),LVCFMT_LEFT,150);
- m_List2.InsertColumn(3,_T("数量"),LVCFMT_LEFT,45);
- m_List2.InsertColumn(4,_T("照片编号"),LVCFMT_LEFT,410);
- m_List3.InitStyle();
- m_List3.InsertColumn(0,_T("autuid"),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);
- m_List3.InsertColumn(5,_T("照片编号"),LVCFMT_LEFT,365);
- if(m_mode2==0)
- GetData();
- else
- GetData2();
- LoadPhotos();
- return false; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void ChoosePhotoSkin2::OnPaint()
- {
- try
- {
- CPaintDC dc(this); // device context for painting
- // TODO: Add your message handler code here
- /* if(::FindParent (m_hWnd) )
- {
- CRect rc;
- GetWindowRect (rc);
- GetParent()->ScreenToClient(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; i<m_picarray.GetSize(); i++)
- {
- pic=(MyBmpButton2*)m_picarray.ElementAt(i);
- if(pic)
- {
- pic->DestroyWindow();
- 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; 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_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;
- CArray<CStringArray, CStringArray>sparray;
- 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))
- {
- 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(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));
- str=List1array.ElementAt (i).ElementAt (6);
- 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=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));
- m_List3.SetItemText(list3pos, 5, sparray.ElementAt (i).ElementAt (6));
- 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();
- }
- if(g_List1array.GetSize())
- {
- m_name1 = g_List1array.ElementAt (0).ElementAt (4);
- m_name2 = g_List1array.ElementAt (0).ElementAt (5);
- 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_choosezs .Format ("%d", max(0,nchoosezs-atoi(m_taoxizs)));
- m_money3 = g_List1array.ElementAt (0).ElementAt (3);
- m_bz3 = g_List1array.ElementAt (0).ElementAt (39);
- m_urgent = g_List1array.ElementAt (0).ElementAt (40);
- 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);
- }
- }
- void ChoosePhotoSkin2::OnOK()
- {
- // TODO: Add extra validation here
- }
- void ChoosePhotoSkin2::OnCancel()
- {
- // TODO: Add extra cleanup here
- }
- void ChoosePhotoSkin2::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- if(m_bModify)
- {
- if(AfxMessageBox("提醒, 选片修改未保存, 是否保存后再退出?", MB_YESNO|MB_ICONINFORMATION)==IDYES)
- {
- OnButton4();
- }
- }
- CDialog::OnCancel();
- }
- BOOL ChoosePhotoSkin2::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
-
- 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();
- 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; i<m_List2.GetItemCount (); i++)
- {
- name=m_List2.GetItemText (i, 2);
- no=m_noarray.ElementAt (i);
- pPopup->AppendODMenu2(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(; i<count+m_no2array.GetSize (); i++)
- {
- name=m_List3.GetItemText (i-count, 2);
- no=m_no2array.ElementAt (i-count);
- pPopup->AppendODMenu2(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(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()>2000)
- {
- 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; i<m_patharray2.GetSize (); i++)
- // MessageBox(m_patharray2.ElementAt (i));
- if(bSel==0 && m_mode==1 && IsSelPhoto(path)==0)
- {
- temp.Format("%d", iItem);
- m_combo1.AddString (temp);
- // m_List1.DeleteItem (iItem);
- //重新计算array2后顺序乱了, 干脆重载
- // UpdateChooseZS();
- // LoadPhotos();
- // return;
- continue;
- }
- else if(bSel==1 && m_mode==2)
- {
- temp.Format("%d", iItem);
- m_combo1.AddString (temp);
- continue;
- // m_List1.DeleteItem (iItem);
- // m_patharray3.RemoveAt (iItem);
- // if( m_showpichwd)
- // ::SendMessage (m_showpichwd, WM_CLOSE, 0, 0);
- // return;
- }
- else if(bSel==1 && m_mode==3)
- {
- temp.Format("%d", iItem);
- m_combo1.AddString (temp);
- continue;
- // m_List1.DeleteItem (iItem);
- // m_patharray1.Add (m_patharray4.ElementAt (iItem));
- // m_patharray4.RemoveAt (iItem);
- // return;
- }
- /////////////////////////
- CString no;
- no=pArray->ElementAt (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; 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::OnButton2()
- {
- // TODO: Add your control notification handler code here
-
- }
- void ChoosePhotoSkin2::OnButton3()
- {
- // TODO: Add your control notification handler code here
-
- }
- void ChoosePhotoSkin2::OnButton4()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- 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;
- savepath.Format ("%s\\%s.dat", g_mainpath, m_id);
- ::DeleteFile (savepath);
- }
- }
- BOOL ChoosePhotoSkin2::OnDel()
- {
- if(m_mode==1)
- {
- AfxMessageBox("选中照片不能删除, 请先取消选中状态!", MB_ICONINFORMATION);
- return 0;
- }
- else if(m_mode==3)
- {
- return 0;
- }
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- return 0;
- }
- int iItem=m_List1.GetNextSelectedItem(pos);
- CString no;//=m_List1.GetItemText (iItem, 0);
- CStringArray *pArray=GetCurArray();
- no=pArray->ElementAt (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; i<pArray->GetSize (); 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; 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 "";
- }
- void ChoosePhotoSkin2::SetSPName3()
- {
- /* UpdateData();
- m_no2array.RemoveAll ();
- CString str;
- float list3money=0;
- for(int i=0; i<m_List3.GetItemCount (); i++)
- {
- if(GetSPNameFromId(m_List3.GetItemText (i, 0))!="")
- m_List3.SetItemText(i,1, GetSPNameFromId(m_List3.GetItemText (i, 0)));
- str.Format ("%f", GetSPPriceFromId(m_List3.GetItemText (i, 0)));
- ConvertToPrice (str);
- m_List3.SetItemText(i,2, str);
-
- list3money+=GetSPPriceFromId(m_List3.GetItemText (i, 0))*atof(m_List3.GetItemText(i,3));
- if(m_List3.GetItemText(i,0)!="" && m_List3.GetItemText(i,1)!="")
- {
- str=m_List3.GetItemText(i,4);str.MakeLower ();
- if(!str.IsEmpty ())
- str=","+str+",";
- m_no2array.Add (str);
- }
- }
- m_money3.Format ("%f", list3money);
- ConvertToPrice(m_money3);
- UpdateData(false);*/
- }
- void ChoosePhotoSkin2::OnSpBox()
- {
- // TODO: Add your control notification handler code here
- /* SPBox dlg;
- if(dlg.DoModal ()!=IDOK)return;
- int pos=m_List3.GetItemCount ();
- CString str;
- if(pos)
- {
- if(m_List3.GetItemText (pos-1, 0).IsEmpty ()&&m_List3.GetItemText (pos-1, 1).IsEmpty ())
- {
- pos--;
- m_List3.SetItemText(pos,0, dlg.m_spid);
- m_List3.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
- str.Format ("%f", GetSPPriceFromId(dlg.m_spid));
- ConvertToPrice (str);
- m_List3.SetItemText(pos,2, str);
- }
- else
- {
- m_List3.InsertItem(pos, dlg.m_spid);
- m_List3.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
- str.Format ("%f", GetSPPriceFromId(dlg.m_spid));
- ConvertToPrice (str);
- m_List3.SetItemText(pos,2, str);
- }
- }
- else
- {
- m_List3.InsertItem(pos, dlg.m_spid);
- m_List3.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
- str.Format ("%f", GetSPPriceFromId(dlg.m_spid));
- ConvertToPrice (str);
- m_List3.SetItemText(pos,2, str);
- }
- SetSPName3();*/
- }
- void ChoosePhotoSkin2::OnButton8()
- {
- // TODO: Add your control notification handler code here
- /* POSITION pos;
- pos=m_List3.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
- return;
- }
- int iItem=m_List3.GetNextSelectedItem(pos);
- m_List3.DeleteItem (iItem);
- SetSPName3();*/
- }
- void ChoosePhotoSkin2::OnButton5()
- {
- // TODO: Add your control notification handler code here
-
- }
- void ChoosePhotoSkin2::OnButton6()
- {
- // TODO: Add your control notification handler code here
-
- }
- //查看全部,查看选中,查看未选,查看删除,保存,关闭
- int FindArray(CStringArray *pArray, CString *pStr)
- {
- for(int i=0; i<pArray->GetSize (); 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; 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));
- }
- }
- CStringArray* ChoosePhotoSkin2::GetCurArray()
- {
- CStringArray *pArray;
- switch(m_mode)
- {
- case 0:
- pArray=&m_patharray1;
- break;
- case 1:
- pArray=&m_patharray2;
- break;
- case 2:
- pArray=&m_patharray3;
- break;
- case 3:
- pArray=&m_patharray4;
- 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;
- }
- 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;
- }
- //img_2354,img_2358,img_2377,img_2378,img_2395,img_2396,img_2399,img_2421,img_2430,img_2352,img_2357,img_2432,img_2454,img_2456,img_2457,img_2459,img_2463,img_2465,img_2493,img_2496,img_2497,img_2502,img_2504,img_2505,img_2522,img_2526,img_2528,img_2531,img_2532,img_2534,img_2561,img_2564,img_2577,img_2578,img_2579,img_2600,img_2601,img_2603,img_2604,img_2608,img_2613,img_2620,img_2626,img_2627,img_2631,img_2635,img_2639,img_2643,img_2647,img_2649,img_2651,img_2652,img_2657,img_2373,img_2424,img_2494,img_2506,img_2562,img_2563,img_2655,img_2637
- void ChoosePhotoSkin2::GetData2()
- {
- CString filter="id='"+m_id+"'";
- g_sendhead.code[0]=31;
- g_sendhead.tabcount=1;
- g_sendhead.bsql=0;
- g_pMainWnd->ProcessChatMessageRequest2(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;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
- {
- for(int i=0; i<4; 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::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();
- 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;
- str.MakeLower ();
- m_patharray1.Add (str);
- }
- }
- }
- }
- 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_id );
- 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_id );
- 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) );
- sparray.ElementAt (i).Add ( "4" );
- i++;
- }
- if(sparray.GetSize ()==0)
- {
- sparray.SetSize(1);
- sparray.ElementAt (0).Add (m_id);
- }
-
- 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_id);
- if(1)
- {
- CFile fp;
- fp.Open (savepath, CFile::modeCreate|CFile::modeWrite);
- fp.Write (pData2, length);
- fp.Close ();
- }
-
-
- delete []pData2;
-
- }
|