ChoosePhotoSkin2.cpp 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874
  1. // ChoosePhotoSkin2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ChoosePhotoSkin2.h"
  5. #include "LYFZIPManage.h"
  6. #include "./helper/ffsco.h"
  7. #include ".\MenuBarXP\MenuXP.h"
  8. #include "ChoosePhotoSkin3.h"
  9. #include "ShowPic22.h"
  10. #include "ClientRequirement.h"
  11. #include "MyLock.h"
  12. #define THUMBNAIL_WIDTH 100
  13. #define THUMBNAIL_HEIGHT 90
  14. extern RESDATA2 g_resdata2;
  15. extern BOOL g_bAlphaWnd;
  16. extern HCURSOR g_cursorhand;
  17. /////////////////////////////////////////////////////////////////////////////
  18. // ChoosePhotoSkin2 dialog
  19. ChoosePhotoSkin2::ChoosePhotoSkin2(CWnd* pParent /*=NULL*/)
  20. : CDialog(ChoosePhotoSkin2::IDD, pParent)
  21. {
  22. //{{AFX_DATA_INIT(ChoosePhotoSkin2)
  23. // NOTE: the ClassWizard will add member initialization here
  24. //}}AFX_DATA_INIT
  25. m_pBk=NULL;
  26. m_pParent=NULL;
  27. m_name1 = _T("");
  28. m_name2 = _T("");
  29. m_time4 = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  30. m_waiter3 = _T("");
  31. m_takezs = _T("");
  32. m_taoxizs = _T("");
  33. m_choosezs = _T("");
  34. m_id = _T("");
  35. m_money3 = _T("");
  36. m_bz3 = _T("");
  37. //}}AFX_DATA_INIT
  38. m_bTerminate=false;
  39. m_bRunning=false;
  40. m_hThread = NULL;
  41. m_bSave=0;
  42. m_bModify=0;
  43. m_mode=0;
  44. m_showpichwd=NULL;
  45. m_mode2=0;
  46. g_pMainWnd->GetSkin();
  47. m_bSort=0;
  48. }
  49. ChoosePhotoSkin2::ChoosePhotoSkin2(DWORD id, CWnd* pParent)
  50. : CDialog(id, pParent)
  51. {
  52. //{{AFX_DATA_INIT(ChoosePhotoSkin2)
  53. // NOTE: the ClassWizard will add member initialization here
  54. //}}AFX_DATA_INIT
  55. m_pBk=NULL;
  56. m_pParent=NULL;
  57. }
  58. void ChoosePhotoSkin2::DoDataExchange(CDataExchange* pDX)
  59. {
  60. CDialog::DoDataExchange(pDX);
  61. //{{AFX_DATA_MAP(ChoosePhotoSkin2)
  62. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  63. DDX_Control(pDX, IDC_EDITzs3, m_editnum4);
  64. DDX_Control(pDX, IDC_EDITzs2, m_editnum3);
  65. DDX_Control(pDX, IDC_EDITzs, m_editnum2);
  66. DDX_Control(pDX, IDC_EDITmoney3, m_editnum1);
  67. DDX_Control(pDX, IDC_LIST3, m_List3);
  68. DDX_Control(pDX, IDC_LIST2, m_List2);
  69. DDX_Control(pDX, IDC_LIST1, m_List1);
  70. DDX_Text(pDX, IDC_EDITname1, m_name1);
  71. DDX_Text(pDX, IDC_EDITname2, m_name2);
  72. DDX_Text(pDX, IDC_EDITtime4, m_time4);
  73. DDX_Text(pDX, IDC_EDITwaiter3, m_waiter3);
  74. DDX_Text(pDX, IDC_EDITzs, m_takezs);
  75. DDX_Text(pDX, IDC_EDITzs2, m_taoxizs);
  76. DDX_Text(pDX, IDC_EDITzs3, m_choosezs);
  77. DDX_Text(pDX, IDC_EDITmoney3, m_money3);
  78. DDX_Text(pDX, IDC_EDITid, m_id);
  79. DDX_Text(pDX, IDC_EDITbz3, m_bz3);
  80. //}}AFX_DATA_MAP}
  81. }
  82. BEGIN_MESSAGE_MAP(ChoosePhotoSkin2, CDialog)
  83. //{{AFX_MSG_MAP(ChoosePhotoSkin2)
  84. ON_WM_PAINT()
  85. ON_WM_DESTROY()
  86. ON_WM_ERASEBKGND()
  87. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  88. ON_WM_CLOSE()
  89. ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnRclickList1)
  90. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  91. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  92. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  93. ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
  94. ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
  95. ON_WM_TIMER()
  96. ON_BN_CLICKED(IDC_BUTTON7, OnSpBox)
  97. ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
  98. ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
  99. ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
  100. //}}AFX_MSG_MAP
  101. ON_MESSAGE(WM_USER+1101,OnBtnClick)
  102. ON_COMMAND_RANGE(IDM_MENUsp1, IDM_MENUsp1+31, OnCommandMenu)
  103. ON_MESSAGE(WM_USER+200, UpdateTakeZS)
  104. END_MESSAGE_MAP()
  105. /////////////////////////////////////////////////////////////////////////////
  106. // ChoosePhotoSkin2 message handlers
  107. extern void SizeToContent(HWND hwnd, Image *img);
  108. extern void DeleteDirectory(CString strDir);
  109. void ChoosePhotoSkin2::OnBtnClick (WPARAM wParam, LPARAM lParam)
  110. {
  111. int id=lParam;
  112. id-=99;
  113. switch(id)
  114. {
  115. case 1:
  116. case 2:
  117. case 4:
  118. if(m_mode==id-1)return;
  119. m_mode=id-1;
  120. LoadPhotos();
  121. break;
  122. case 3:
  123. if(m_mode==id-1)return;
  124. UpdateChooseZS();
  125. GetNoSelPhoto();
  126. m_mode=id-1;
  127. LoadPhotos();
  128. break;
  129. case 5:
  130. OnButton4();
  131. break;
  132. case 9:
  133. {
  134. CClientRequirement dlg;
  135. dlg.m_bz2=m_bz2;
  136. dlg.m_id=m_id;
  137. dlg.m_bSave =1;
  138. dlg.DoModal ();
  139. m_bz2=dlg.m_bz2;
  140. }
  141. break;
  142. case 10:
  143. {
  144. if(AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO|MB_ICONSTOP)!=IDYES)return ;
  145. CString path=m_path;
  146. path.TrimRight ('\\');
  147. DeleteDirectory(path);
  148. GetPhotos();
  149. LoadPhotos();
  150. }
  151. break;
  152. case 11:
  153. {
  154. POSITION pos;
  155. pos=m_List1.GetFirstSelectedItemPosition();
  156. if(pos==NULL)
  157. {
  158. AfxMessageBox("请先选中您要删除的照片!", MB_ICONINFORMATION);
  159. return;
  160. }
  161. if(AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO|MB_ICONSTOP)!=IDYES)return;
  162. while (pos)
  163. {
  164. int iItem=m_List1.GetNextSelectedItem(pos);
  165. CString title=m_List1.GetItemText (iItem, 0);
  166. ::DeleteFile (m_path+title+".jpg");
  167. ::DeleteFile (m_path+"s"+title+".jpg");
  168. }
  169. GetPhotos();
  170. LoadPhotos();
  171. }
  172. break;
  173. case 6:
  174. if(m_bModify)
  175. {
  176. if(AfxMessageBox("提醒, 选片修改未保存, 是否保存后再退出?", MB_YESNO|MB_ICONINFORMATION)==IDYES)
  177. {
  178. OnButton4();
  179. }
  180. else
  181. {
  182. CString savepath;
  183. savepath.Format ("%s\\%s.dat", g_mainpath, m_id);
  184. ::DeleteFile (savepath);
  185. }
  186. }
  187. g_bInSkin=0;
  188. CDialog::OnCancel ();
  189. break;
  190. }
  191. }
  192. BOOL ChoosePhotoSkin2::OnInitDialog()
  193. {
  194. CDialog::OnInitDialog();
  195. g_bInSkin=1;
  196. // TODO: Add extra initialization here
  197. if(g_cursorhand==NULL)
  198. g_cursorhand=AfxGetApp()->LoadCursor(IDC_CURSORHAND);
  199. BYTE *pData=NULL;
  200. BYTE *pDataBegin;
  201. if(!LoadLia(g_mainpath+"\\skin\\"+m_liapath, &pData, &pDataBegin, &m_pBk, m_hWnd))
  202. {
  203. EndDialog(0);
  204. return false;
  205. }
  206. /* CFile fp;
  207. if(!fp.Open (g_mainpath+"\\skin\\"+m_liapath, CFile::modeRead))
  208. {
  209. AfxMessageBox(_T("lia文件未找到."), MB_ICONINFORMATION);
  210. EndDialog(0);
  211. return false;
  212. }
  213. DWORD count=fp.GetLength ();
  214. BYTE *pData=new BYTE[count];
  215. BYTE *pDataBegin=pData;
  216. fp.Read (pData, count);
  217. fp.Close ();
  218. /////////////
  219. CStringArray childarray;
  220. DWORD childlength;
  221. memcpy(&childlength, pData, sizeof(DWORD));
  222. pData+=sizeof(DWORD);
  223. BYTE *pChildData=new BYTE[childlength];
  224. memcpy(pChildData, pData, childlength);
  225. pData+=childlength;
  226. CMemFile memfile;
  227. memfile.Attach (pChildData,childlength);
  228. CArchive ar(&memfile, CArchive::load);
  229. childarray.Serialize (ar);
  230. ar.Close();
  231. memfile.Detach ();
  232. delete []pChildData;
  233. //////////////////////
  234. memcpy(&g_resdata2, pData, sizeof(RESDATA2));
  235. pData+=sizeof(RESDATA2);
  236. */
  237. for(int i=0; i<g_resdata2.nPicCount; i++)
  238. {
  239. g_resdata2.rect[i].left *=g_fscalex;
  240. g_resdata2.rect[i].right *=g_fscalex;
  241. g_resdata2.rect[i].top *=g_fscaley;
  242. g_resdata2.rect[i].bottom *=g_fscaley;
  243. if(g_resdata2.nPicBmpCount [i])
  244. {
  245. MyBmpButton2 *pic=new MyBmpButton2;
  246. m_picarray.Add((DWORD)pic);
  247. CRect rc=g_resdata2.rect[i];
  248. CString str;
  249. str.Format (_T("%d"), i+1);
  250. pic->Create(str, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW , rc, this, i+100);
  251. pic->m_bmpcount =g_resdata2.nPicBmpCount [i];
  252. pic->ReadBmp (&pData, NULL, this);
  253. }
  254. else
  255. m_picarray.Add (NULL);
  256. m_rcarray.Add(g_resdata2.rect[i]);
  257. }
  258. delete []pDataBegin;
  259. if(m_mode2==0)
  260. {
  261. ((MyBmpButton2*)m_picarray.ElementAt (7))->ShowWindow (SW_HIDE);
  262. ((MyBmpButton2*)m_picarray.ElementAt (8))->ShowWindow (SW_HIDE);
  263. ((MyBmpButton2*)m_picarray.ElementAt (9))->ShowWindow (SW_HIDE);
  264. ((MyBmpButton2*)m_picarray.ElementAt (10))->ShowWindow (SW_HIDE);
  265. }
  266. else
  267. {
  268. ((MyBmpButton2*)m_picarray.ElementAt (7))->EnableWindow (0);
  269. ((MyBmpButton2*)m_picarray.ElementAt (0))->ShowWindow (SW_HIDE);
  270. ((MyBmpButton2*)m_picarray.ElementAt (1))->ShowWindow (SW_HIDE);
  271. ((MyBmpButton2*)m_picarray.ElementAt (2))->ShowWindow (SW_HIDE);
  272. ((MyBmpButton2*)m_picarray.ElementAt (3))->ShowWindow (SW_HIDE);
  273. ((MyBmpButton2*)m_picarray.ElementAt (4))->ShowWindow (SW_HIDE);
  274. if(IsHasRights2new(37)==0)
  275. {
  276. ((MyBmpButton2*)m_picarray.ElementAt (9))->ShowWindow (SW_HIDE);
  277. ((MyBmpButton2*)m_picarray.ElementAt (10))->ShowWindow (SW_HIDE);
  278. }
  279. }
  280. #ifndef MNLS_VERSION
  281. ((MyBmpButton2*)m_picarray.ElementAt (7))->ShowWindow (SW_HIDE);
  282. ((MyBmpButton2*)m_picarray.ElementAt (7))->EnableWindow (0);
  283. Graphics graph(m_pBk);
  284. Image *img=NULL;
  285. if(m_mode2==0)
  286. ::LoadImageFromBuf (&img, g_mainpath+"\\skin\\标题-选片.jpg");
  287. else
  288. ::LoadImageFromBuf (&img, g_mainpath+"\\skin\\标题-看设计.jpg");
  289. graph.DrawImage(img, 0,0);
  290. delete img;
  291. #endif
  292. m_List1.MoveWindow (m_rcarray.ElementAt (6));
  293. CString path,str;
  294. if(m_mode2)
  295. {
  296. m_path=g_path3+"\\";
  297. m_path+=m_id;
  298. m_path +="\\";
  299. }
  300. if(m_mode2)//看设计
  301. {
  302. GetPhotos();
  303. }
  304. else
  305. {
  306. using namespace helper_coffs;
  307. ffsco o;
  308. o.dirs(0);
  309. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  310. ffsco::typeT coo;
  311. ffsco::typeT::iterator it;
  312. coo = o.co_file();
  313. for (it = coo.begin();
  314. coo.end() != it;
  315. it ++)
  316. {
  317. path=(*it).c_str();
  318. if(path.GetAt (path.ReverseFind ('\\')+1)!='s')
  319. {
  320. path.MakeLower ();
  321. m_patharray1.Add (path);
  322. }
  323. }
  324. }
  325. if(m_mode2==0)
  326. {
  327. if(m_patharray1.GetSize ()==0)
  328. {
  329. if(AfxMessageBox("此单未导入修好的片, 是否用原片选片?", MB_YESNO|MB_ICONINFORMATION)==IDYES)
  330. {
  331. m_path=g_path1+"\\";
  332. m_path+=m_id;
  333. m_path +="\\";
  334. using namespace helper_coffs;
  335. ffsco o;
  336. o.dirs(0);
  337. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  338. ffsco::typeT coo;
  339. ffsco::typeT::iterator it;
  340. coo = o.co_file();
  341. for (it = coo.begin();
  342. coo.end() != it;
  343. it ++)
  344. {
  345. path=(*it).c_str();
  346. if(path.GetAt (path.ReverseFind ('\\')+1)!='s')
  347. {
  348. path.MakeLower ();
  349. m_patharray1.Add (path);
  350. }
  351. }
  352. }
  353. }
  354. if(m_patharray1.GetSize ())
  355. {
  356. int size=m_patharray1.GetSize ()-1;
  357. CString sTemp;
  358. int nPos;
  359. for(int i=0;i<size;i++)
  360. {
  361. nPos=rand()%(size-i);
  362. sTemp=m_patharray1.ElementAt (size-i);
  363. m_patharray1.SetAt (size-i, m_patharray1.ElementAt (nPos));
  364. m_patharray1.SetAt (nPos, sTemp);
  365. }
  366. }
  367. }
  368. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  369. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  370. m_List2.InitStyle();
  371. m_List2.InsertColumn(0,_T("autuid"),LVCFMT_LEFT,0);
  372. m_List2.InsertColumn(1,_T("编号"),LVCFMT_LEFT,45);
  373. m_List2.InsertColumn(2,_T("商品名称"),LVCFMT_LEFT,150);
  374. m_List2.InsertColumn(3,_T("数量"),LVCFMT_LEFT,45);
  375. m_List2.InsertColumn(4,_T("照片编号"),LVCFMT_LEFT,410);
  376. m_List3.InitStyle();
  377. m_List3.InsertColumn(0,_T("autuid"),LVCFMT_LEFT,0);
  378. m_List3.InsertColumn(1,_T("编号"),LVCFMT_LEFT,45);
  379. m_List3.InsertColumn(2,_T("商品名称"),LVCFMT_LEFT,150);
  380. m_List3.InsertColumn(3,_T("价格"),LVCFMT_LEFT,45);
  381. m_List3.InsertColumn(4,_T("数量"),LVCFMT_LEFT,45);
  382. m_List3.InsertColumn(5,_T("照片编号"),LVCFMT_LEFT,365);
  383. if(m_mode2==0)
  384. GetData();
  385. else
  386. GetData2();
  387. LoadPhotos();
  388. return false; // return TRUE unless you set the focus to a control
  389. // EXCEPTION: OCX Property Pages should return FALSE
  390. }
  391. void ChoosePhotoSkin2::OnPaint()
  392. {
  393. try
  394. {
  395. CPaintDC dc(this); // device context for painting
  396. // TODO: Add your message handler code here
  397. /* if(::FindParent (m_hWnd) )
  398. {
  399. CRect rc;
  400. GetWindowRect (rc);
  401. GetParent()->ScreenToClient(rc);
  402. Graphics graph(dc.GetSafeHdc ());
  403. Rect destinationRect(0,0,rc.Width (), rc.Height ());
  404. graph.DrawImage(((ChoosePhotoSkin2*)GetParent())->m_pBk, destinationRect, rc.left , rc.top ,rc.Width (), rc.Height (),UnitPixel);
  405. }*/
  406. if(m_pBk==NULL)
  407. {
  408. return ;
  409. }
  410. CRect rc;
  411. GetClientRect(rc);
  412. Graphics graph(dc.GetSafeHdc ());
  413. Rect destinationRect(0,0,rc.Width (), rc.Height ());
  414. int width=m_pBk->GetWidth() ;
  415. int height=m_pBk->GetHeight() ;
  416. graph.DrawImage(m_pBk, destinationRect, 0,0,width,height,UnitPixel);
  417. // Do not call CDialog::OnPaint() for painting messages
  418. }
  419. catch(...)
  420. {
  421. }
  422. }
  423. void ChoosePhotoSkin2::OnPaint2(CWnd *pWnd)
  424. {
  425. try
  426. {
  427. CPaintDC dc(pWnd); // device context for painting
  428. // TODO: Add your message handler code here
  429. CRect rc;
  430. GetClientRect(rc);
  431. if(m_pBk==NULL)
  432. {
  433. return ;
  434. }
  435. int width=m_pBk->GetWidth() ;
  436. int height=m_pBk->GetHeight() ;
  437. Graphics graph(dc.GetSafeHdc ());
  438. Rect destinationRect(0,0,rc.Width (), rc.Height ());
  439. graph.DrawImage(m_pBk, destinationRect, 0,0,width,height,UnitPixel);
  440. }
  441. catch(...)
  442. {
  443. }
  444. }
  445. void ChoosePhotoSkin2::OnDestroy()
  446. {
  447. try
  448. {
  449. CDialog::OnDestroy();
  450. TerminateThread();
  451. if(m_pBk)delete m_pBk;
  452. MyBmpButton2 *pic=NULL;
  453. for(int i=0; i<m_picarray.GetSize(); i++)
  454. {
  455. pic=(MyBmpButton2*)m_picarray.ElementAt(i);
  456. if(pic)
  457. {
  458. pic->DestroyWindow();
  459. delete pic;
  460. }
  461. }
  462. m_picarray.RemoveAll();
  463. }
  464. catch(...)
  465. {
  466. }
  467. }
  468. BOOL ChoosePhotoSkin2::OnEraseBkgnd(CDC* pDC)
  469. {
  470. // TODO: Add your message handler code here and/or call default
  471. return 1;
  472. }
  473. void ChoosePhotoSkin2::SetLiaPath(CString path)
  474. {
  475. m_liapath=path;
  476. }
  477. BEGIN_EVENTSINK_MAP(ChoosePhotoSkin2, CDialog)
  478. //{{AFX_EVENTSINK_MAP(ChoosePhotoSkin2)
  479. ON_EVENT(ChoosePhotoSkin2, 100, 150 /* FSCommand */, OnFSCommandShockwaveflash1, VTS_BSTR VTS_BSTR)
  480. //}}AFX_EVENTSINK_MAP
  481. END_EVENTSINK_MAP()
  482. void ChoosePhotoSkin2::OnFSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args)
  483. {
  484. // TODO: Add your control notification handler code here
  485. }
  486. extern void LoadImageFromFile(Image **img, CString path);
  487. unsigned __stdcall LoadThumbNail3(LPVOID lpParam)
  488. {
  489. ChoosePhotoSkin2 *pDlg=(ChoosePhotoSkin2*)lpParam;
  490. CListCtrl *ListCtrl=&pDlg->m_List1;
  491. try
  492. {
  493. CImageList* pImgList=&pDlg->m_ImageListThumb;
  494. // reset our image list
  495. for(int i=0; i<pImgList->GetImageCount(); i++)
  496. pImgList->Remove(i);
  497. // remove all items from list view
  498. ListCtrl->DeleteAllItems();
  499. pImgList->SetImageCount(pDlg->m_vFileName.size());
  500. // TCHAR path[MAX_PATH];
  501. vector<CString>::iterator iter;
  502. // Set redraw to FALSE to avoid flickering during adding new items
  503. ListCtrl->SetRedraw(FALSE);
  504. int nIndex=0;
  505. CString str,spath;
  506. if(pDlg->m_mode2==0)
  507. {
  508. for(iter=pDlg->m_vFileName.begin(); iter!=pDlg->m_vFileName.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  509. {
  510. str=*iter;
  511. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  512. str=str.Left (str.Find ('.'));
  513. str+=pDlg->GetSelName(str);
  514. ListCtrl->InsertItem(nIndex, str, nIndex);
  515. }
  516. }
  517. else
  518. {
  519. for(iter=pDlg->m_vFileName.begin(); iter!=pDlg->m_vFileName.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  520. {
  521. str=*iter;
  522. spath.Empty ();
  523. if(str.Left (str.ReverseFind ('\\')+1)!=pDlg->m_path)
  524. {
  525. spath=str.Left (str.ReverseFind ('\\')+1);
  526. spath= spath.Right (spath.GetLength ()-pDlg->m_path.GetLength ());
  527. }
  528. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  529. str=spath+str.Left (str.GetLength ()-4);
  530. ListCtrl->InsertItem(nIndex, str, nIndex);
  531. }
  532. }
  533. ListCtrl->SetRedraw(TRUE);
  534. ListCtrl->Invalidate();
  535. const float fRatio=(float)THUMBNAIL_HEIGHT/THUMBNAIL_WIDTH;
  536. int XDest, YDest, nDestWidth, nDestHeight;
  537. nIndex=0;
  538. SolidBrush whitebrush(Color(255,255,255,255));
  539. for(iter=pDlg->m_vFileName.begin(); iter!=pDlg->m_vFileName.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  540. {
  541. // Load Image File
  542. Image *image=NULL;
  543. Bitmap *pBmp=NULL;
  544. str=*iter;
  545. spath=str.Left (str.ReverseFind ('\\')+1);
  546. spath+="s";
  547. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  548. if(::PathFileExists (spath))
  549. ::LoadImageFromBuf (&image, spath);
  550. else if(::PathFileExists (str))
  551. ::LoadImageFromBuf (&image, str);
  552. else
  553. continue;
  554. if(image->GetWidth()==0)
  555. continue;
  556. int orientation=GetOrientation(image);
  557. if(orientation==8)
  558. image->RotateFlip( Rotate270FlipNone );
  559. else if(orientation==6)
  560. image->RotateFlip( Rotate90FlipNone );
  561. // Calculate Rect to fit to canvas
  562. const float fImgRatio=(float)image->GetHeight()/image->GetWidth();
  563. if(fImgRatio > fRatio)
  564. {
  565. nDestWidth=THUMBNAIL_HEIGHT/fImgRatio;
  566. XDest=(THUMBNAIL_WIDTH-nDestWidth)/2;
  567. YDest=0;
  568. nDestHeight=THUMBNAIL_HEIGHT;
  569. }
  570. else
  571. {
  572. XDest=0;
  573. nDestWidth=THUMBNAIL_WIDTH;
  574. nDestHeight=THUMBNAIL_WIDTH*fImgRatio;
  575. YDest=(THUMBNAIL_HEIGHT-nDestHeight)/2;
  576. }
  577. pBmp=new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB );
  578. Graphics graph2(pBmp);
  579. graph2.Clear(Color(255,192,192,192));
  580. graph2.FillRectangle (&whitebrush,1, 1, THUMBNAIL_WIDTH-2, THUMBNAIL_HEIGHT-2);
  581. Graphics graph(pBmp);
  582. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  583. // Draw Image
  584. graph.DrawImage(image, desRect, 0,0,image->GetWidth(),image->GetHeight(),UnitPixel);
  585. delete image;
  586. // Attach to Bitmap and Replace image in CImageList
  587. CBitmap bitmap;
  588. HBITMAP hbmp;
  589. pBmp->GetHBITMAP(Color(255,255,255,255), &hbmp);
  590. bitmap.Attach(hbmp);
  591. pImgList->Replace(nIndex, &bitmap, NULL);
  592. delete pBmp;
  593. // Redraw only a current item for removing flickering and fast speed.
  594. ListCtrl->RedrawItems(nIndex, nIndex);
  595. // Release used DC and Object
  596. }
  597. ListCtrl->Invalidate();
  598. pDlg->m_bRunning=false;
  599. pDlg->m_bTerminate=false;
  600. pDlg->PostMessage(WM_USER+200, 0, 0);
  601. return 0;
  602. }
  603. catch(...)
  604. {
  605. ListCtrl->Invalidate();
  606. pDlg->m_bRunning=false;
  607. pDlg->m_bTerminate=false;
  608. pDlg->PostMessage(WM_USER+200, 0, 0);
  609. }
  610. }
  611. void ChoosePhotoSkin2::LoadThumbImages()
  612. {
  613. }
  614. BOOL ChoosePhotoSkin2::TerminateThread()
  615. {
  616. if ( !m_bRunning )
  617. return TRUE;
  618. m_bTerminate=true;
  619. for( ; ; )
  620. {
  621. if ( ::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0 )
  622. break;
  623. MSG msg;
  624. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  625. {
  626. if (!AfxGetApp()->PumpMessage())
  627. break;
  628. }
  629. }
  630. ::CloseHandle(m_hThread);
  631. return TRUE;
  632. }
  633. void ChoosePhotoSkin2::OnDblclkList1()
  634. {
  635. POSITION pos;
  636. pos=m_List1.GetFirstSelectedItemPosition();
  637. if(pos==NULL)
  638. {
  639. return;
  640. }
  641. int iItem=m_List1.GetNextSelectedItem(pos);
  642. m_showpichwd=NULL;
  643. ShowPic22 dlg;
  644. dlg.m_pParent =this;
  645. dlg.m_pos=iItem;
  646. dlg.m_pPathArray=GetCurArray();
  647. dlg.DoModal ();
  648. m_showpichwd=NULL;
  649. }
  650. void ChoosePhotoSkin2::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  651. {
  652. // TODO: Add your control notification handler code here
  653. OnDblclkList1();
  654. *pResult = 0;
  655. }
  656. void ChoosePhotoSkin2::GetData()
  657. {
  658. CString filter="id='"+m_id+"' and kind<>'5';id='"+m_id+"';";
  659. g_sendhead.code[0]=50;
  660. g_sendhead.code[1]=11;
  661. g_sendhead.code[2]=4;
  662. g_sendhead.tabcount=3;
  663. g_sendhead.bsql=0;
  664. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  665. CArray<CStringArray, CStringArray>sparray;
  666. DataToArray(&sparray, &g_List1array, &m_sparray);
  667. m_patharray2.RemoveAll ();
  668. CString str,kind;
  669. int nchoosezs=0;
  670. int list2pos=0;
  671. int list3pos=0;
  672. CString savepath;
  673. savepath.Format ("%s\\%s.dat", g_mainpath, m_id);
  674. if(::PathFileExists (savepath))
  675. {
  676. CArray<CStringArray, CStringArray>List1array;
  677. CFile fp;
  678. fp.Open (savepath, CFile::modeRead);
  679. DWORD nMessageLen=fp.GetLength ();
  680. BYTE *szChatMessage = new BYTE[nMessageLen];
  681. fp.Read (szChatMessage, nMessageLen);
  682. fp.Close ();
  683. int count;
  684. memcpy(&count, szChatMessage+(nMessageLen-sizeof(int)), sizeof(int));
  685. CMemFile memfile;
  686. memfile.Attach (szChatMessage, nMessageLen);
  687. CArchive ar(&memfile, CArchive::load);
  688. List1array.SetSize(count);
  689. for(int i=0; i<List1array.GetSize (); i++)
  690. {
  691. List1array.ElementAt (i).Serialize (ar);
  692. }
  693. ar.Close();
  694. memfile.Detach ();
  695. delete []szChatMessage;
  696. list2pos=0;
  697. list3pos=0;
  698. for( i=0; i<List1array.GetSize (); i++)
  699. {
  700. if(List1array.ElementAt (i).GetSize ()==6)
  701. {
  702. kind="0";
  703. m_List2.InsertItem(list2pos, List1array.ElementAt (i).ElementAt (1));
  704. m_List2.SetItemText(list2pos, 1, List1array.ElementAt (i).ElementAt (2));
  705. m_List2.SetItemText(list2pos, 2, List1array.ElementAt (i).ElementAt (3));
  706. m_List2.SetItemText(list2pos, 3, List1array.ElementAt (i).ElementAt (4));
  707. m_List2.SetItemText(list2pos, 4, List1array.ElementAt (i).ElementAt (5));
  708. str=List1array.ElementAt (i).ElementAt (5);
  709. list2pos++;
  710. }
  711. else
  712. {
  713. kind="4";
  714. m_List3.InsertItem(list3pos, List1array.ElementAt (i).ElementAt (1));
  715. m_List3.SetItemText(list3pos, 1, List1array.ElementAt (i).ElementAt (2));
  716. m_List3.SetItemText(list3pos, 2, List1array.ElementAt (i).ElementAt (3));
  717. m_List3.SetItemText(list3pos, 3, List1array.ElementAt (i).ElementAt (4));
  718. m_List3.SetItemText(list3pos, 4, List1array.ElementAt (i).ElementAt (5));
  719. m_List3.SetItemText(list3pos, 5, List1array.ElementAt (i).ElementAt (6));
  720. str=List1array.ElementAt (i).ElementAt (6);
  721. list3pos++;
  722. }
  723. nchoosezs+=GetZS(str);
  724. GetPath(str);
  725. if(!str.IsEmpty ())
  726. str=","+str+",";
  727. str.MakeLower ();
  728. if(kind=="4")
  729. m_no2array.Add (str);
  730. else
  731. m_noarray.Add (str);
  732. }
  733. }
  734. else
  735. {
  736. for(int i=0; i<sparray.GetSize (); i++)
  737. {
  738. kind=sparray.ElementAt (i).ElementAt (4);
  739. if(kind=="4")
  740. {
  741. m_List3.InsertItem(list3pos, sparray.ElementAt (i).ElementAt (7));
  742. m_List3.SetItemText(list3pos, 1, sparray.ElementAt (i).ElementAt (1));
  743. m_List3.SetItemText(list3pos, 2, sparray.ElementAt (i).ElementAt (5));
  744. m_List3.SetItemText(list3pos, 3, sparray.ElementAt (i).ElementAt (2));
  745. m_List3.SetItemText(list3pos, 4, sparray.ElementAt (i).ElementAt (3));
  746. m_List3.SetItemText(list3pos, 5, sparray.ElementAt (i).ElementAt (6));
  747. list3pos++;
  748. }
  749. else
  750. {
  751. m_List2.InsertItem(list2pos, sparray.ElementAt (i).ElementAt (7));
  752. m_List2.SetItemText(list2pos, 1, sparray.ElementAt (i).ElementAt (1));
  753. m_List2.SetItemText(list2pos, 2, sparray.ElementAt (i).ElementAt (5));
  754. m_List2.SetItemText(list2pos, 3, sparray.ElementAt (i).ElementAt (3));
  755. m_List2.SetItemText(list2pos, 4, sparray.ElementAt (i).ElementAt (6));
  756. list2pos++;
  757. }
  758. str=sparray.ElementAt (i).ElementAt (6);
  759. str.MakeLower ();
  760. nchoosezs+=GetZS(str);
  761. GetPath(str);
  762. if(!str.IsEmpty ())
  763. str=","+str+",";
  764. if(kind=="4")
  765. m_no2array.Add (str);
  766. else
  767. m_noarray.Add (str);
  768. }
  769. CheckForAlbum();
  770. }
  771. if(g_List1array.GetSize())
  772. {
  773. m_name1 = g_List1array.ElementAt (0).ElementAt (4);
  774. m_name2 = g_List1array.ElementAt (0).ElementAt (5);
  775. m_waiter3 = g_user.name ;
  776. m_taoxizs = g_List1array.ElementAt (0).ElementAt (9);
  777. m_time5 = g_List1array.ElementAt (0).ElementAt (22);
  778. m_takezs = g_List1array.ElementAt (0).ElementAt (23);
  779. m_choosezs = g_List1array.ElementAt (0).ElementAt (24);
  780. // m_choosezs .Format ("%d", max(0,nchoosezs-atoi(m_taoxizs)));
  781. m_money3 = g_List1array.ElementAt (0).ElementAt (3);
  782. m_bz3 = g_List1array.ElementAt (0).ElementAt (39);
  783. m_urgent = g_List1array.ElementAt (0).ElementAt (40);
  784. UpdateData(false);
  785. }
  786. else
  787. {
  788. m_name1 = "";
  789. m_name2 = "";
  790. m_waiter3 = "";
  791. m_taoxizs = "";
  792. m_time5 = "";
  793. m_takezs = "";
  794. m_choosezs = "";
  795. m_money3 = "";
  796. m_bz3 = "";
  797. m_urgent = "";
  798. UpdateData(false);
  799. }
  800. }
  801. void ChoosePhotoSkin2::OnOK()
  802. {
  803. // TODO: Add extra validation here
  804. }
  805. void ChoosePhotoSkin2::OnCancel()
  806. {
  807. // TODO: Add extra cleanup here
  808. }
  809. void ChoosePhotoSkin2::OnClose()
  810. {
  811. // TODO: Add your message handler code here and/or call default
  812. if(m_bModify)
  813. {
  814. if(AfxMessageBox("提醒, 选片修改未保存, 是否保存后再退出?", MB_YESNO|MB_ICONINFORMATION)==IDYES)
  815. {
  816. OnButton4();
  817. }
  818. }
  819. CDialog::OnCancel();
  820. }
  821. BOOL ChoosePhotoSkin2::PreTranslateMessage(MSG* pMsg)
  822. {
  823. // TODO: Add your specialized code here and/or call the base class
  824. if(pMsg->message==WM_LBUTTONDOWN)
  825. {
  826. g_bNeedDrawParent=2;
  827. if(0)
  828. {//list3
  829. CPoint pt;
  830. CRect rc,rc2;
  831. ::GetCursorPos (&pt);
  832. m_List3.GetWindowRect (rc2);
  833. if(rc2.PtInRect (pt)==0) return CDialog::PreTranslateMessage(pMsg);
  834. SetTimer(3, 300, NULL);
  835. }
  836. }
  837. else if(0)//pMsg->message==WM_LBUTTONDBLCLK)
  838. {
  839. {//list1
  840. CPoint pt;
  841. CRect rc,rc2;
  842. ::GetCursorPos (&pt);
  843. m_List2.GetWindowRect (rc2);
  844. if(rc2.PtInRect (pt)) return 1;
  845. }
  846. {//list3
  847. CPoint pt;
  848. CRect rc,rc2;
  849. ::GetCursorPos (&pt);
  850. m_List3.GetWindowRect (rc2);
  851. if(rc2.PtInRect (pt)==0)return CDialog::PreTranslateMessage(pMsg);
  852. pt.x-=rc2.left ;
  853. pt.y-=rc2.top ;
  854. int iItem=m_List3.GetItemCount ()-1;
  855. if(iItem<0)
  856. {
  857. m_List3.GetHeaderCtrl()->GetItemRect (0, rc);
  858. int hei=rc.Height ();
  859. rc.top +=hei;
  860. rc.bottom +=hei;
  861. if(rc.PtInRect (pt))
  862. {
  863. m_List3.InsertItem(m_List3.GetItemCount (), "");
  864. }
  865. }
  866. else
  867. {
  868. m_List3.GetSubItemRect( iItem, 0, LVIR_BOUNDS, rc);
  869. int hei=rc.Height ();
  870. rc.top +=hei;
  871. rc.bottom +=hei;
  872. if(rc.PtInRect (pt))
  873. {
  874. if(m_List3.GetItemText (iItem, 1).IsEmpty ()&&m_List3.GetItemText (iItem, 2).IsEmpty ())
  875. return CDialog::PreTranslateMessage(pMsg);
  876. m_List3.InsertItem(m_List3.GetItemCount (), "");
  877. }
  878. POSITION pos;
  879. pos=m_List3.GetFirstSelectedItemPosition();
  880. if(pos)
  881. {
  882. iItem=m_List3.GetNextSelectedItem(pos);
  883. m_List3.GetSubItemRect( iItem, 4, LVIR_BOUNDS, rc);
  884. if(rc.PtInRect (pt))return 1;
  885. }
  886. }
  887. }
  888. }
  889. else if(pMsg->message==WM_KEYDOWN)
  890. {
  891. if(m_showpichwd)return 1;
  892. switch (pMsg->wParam)
  893. {
  894. case VK_DELETE:
  895. OnDel();
  896. return 1;
  897. case VK_RETURN:
  898. OnDblclkList1();
  899. return 1;
  900. case VK_F4:
  901. SortArray();
  902. return 1;
  903. }
  904. }
  905. return CDialog::PreTranslateMessage(pMsg);
  906. }
  907. void ChoosePhotoSkin2::OnRclickList1()
  908. {
  909. if(m_bRunning)return;
  910. POSITION pos;
  911. pos=m_List1.GetFirstSelectedItemPosition();
  912. if(pos==NULL)
  913. {
  914. return;
  915. }
  916. int iItem=m_List1.GetNextSelectedItem(pos);
  917. CStringArray *pArray=GetCurArray();
  918. CString path=pArray->ElementAt (iItem);
  919. path=path.Right (path.GetLength ()-path.ReverseFind ('\\')-1);
  920. path=path.Left (path.Find ('.'));
  921. path=","+path+",";
  922. // MessageBox(path);
  923. // TODO: Add your control notification handler code here
  924. CMenuXP *pPopup;
  925. pPopup = new CMenuXP;
  926. pPopup->CYBUTTONMARGIN=3;
  927. pPopup->CreatePopupMenu();
  928. pPopup->SetMenuStyle(CMenuXP::STYLE_XP);
  929. CString name,no;
  930. int count=0;
  931. for(int i=0; i<m_List2.GetItemCount (); i++)
  932. {
  933. name=m_List2.GetItemText (i, 2);
  934. no=m_noarray.ElementAt (i);
  935. pPopup->AppendODMenu2(0, new CMenuXPText(IDM_MENUsp1+i, name, NULL));
  936. if(no.Find (path)!=-1)
  937. pPopup->CheckMenuItem(IDM_MENUsp1+i, MF_BYCOMMAND | MF_CHECKED);
  938. }
  939. count=i;
  940. for(; i<count+m_no2array.GetSize (); i++)
  941. {
  942. name=m_List3.GetItemText (i-count, 2);
  943. no=m_no2array.ElementAt (i-count);
  944. pPopup->AppendODMenu2(0, new CMenuXPText(IDM_MENUsp1+i, name, NULL));
  945. if(no.Find (path)!=-1)
  946. pPopup->CheckMenuItem(IDM_MENUsp1+i, MF_BYCOMMAND | MF_CHECKED);
  947. }
  948. CPoint pt;
  949. ::GetCursorPos (&pt);
  950. pPopup->TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this, 0);
  951. delete pPopup;
  952. }
  953. void ChoosePhotoSkin2::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult)
  954. {
  955. if( m_showpichwd)return;
  956. OnRclickList1();
  957. *pResult = 0;
  958. }
  959. void ChoosePhotoSkin2::OnCommandMenu(UINT nID)
  960. {
  961. POSITION pos;
  962. pos=m_List1.GetFirstSelectedItemPosition();
  963. if(pos==NULL)
  964. {
  965. return;
  966. }
  967. CString temp;
  968. m_combo1.ResetContent ();
  969. while (pos)
  970. {
  971. int iItem=m_List1.GetNextSelectedItem(pos);
  972. CStringArray *pArray=GetCurArray();
  973. CString path=pArray->ElementAt (iItem);
  974. path=path.Right (path.GetLength ()-path.ReverseFind ('\\')-1);
  975. path=path.Left (path.Find ('.'));
  976. path=","+path+",";
  977. int idpos=nID-IDM_MENUsp1;
  978. BOOL bSel=0;//选中还是取消
  979. if(idpos<m_noarray.GetSize ())
  980. {
  981. CString no=m_noarray.ElementAt (idpos);
  982. if(no.Find (path)!=-1)
  983. {
  984. int pos=no.Find (path);
  985. no.Delete (pos, path.GetLength ()-1);
  986. }
  987. else if(no.GetLength()>2000)
  988. {
  989. AfxMessageBox("编号太长,选择失败!", MB_ICONSTOP);return;
  990. }
  991. else
  992. {
  993. bSel=1;
  994. no.TrimRight (",");
  995. no+=path;
  996. }
  997. no.TrimLeft (",");
  998. no.TrimRight (",");
  999. m_List2.SetItemText (idpos, 4, no);
  1000. if(no.IsEmpty ())
  1001. m_noarray.SetAt (idpos, no);
  1002. else
  1003. m_noarray.SetAt (idpos, ","+no+",");
  1004. }
  1005. else
  1006. {
  1007. idpos-=m_noarray.GetSize ();
  1008. CString no=m_no2array.ElementAt (idpos);
  1009. if(no.Find (path)!=-1)
  1010. {
  1011. int pos=no.Find (path);
  1012. no.Delete (pos, path.GetLength ()-1);
  1013. }
  1014. else if(no.GetLength()>2000)
  1015. {
  1016. AfxMessageBox("编号太长,选择失败!", MB_ICONSTOP);return;
  1017. }
  1018. else
  1019. {
  1020. bSel=1;
  1021. no.TrimRight (",");
  1022. no+=path;
  1023. }
  1024. no.TrimLeft (",");
  1025. no.TrimRight (",");
  1026. m_List3.SetItemText (idpos, 5, no);
  1027. if(no.IsEmpty ())
  1028. m_no2array.SetAt (idpos, no);
  1029. else
  1030. m_no2array.SetAt (idpos, ","+no+",");
  1031. }
  1032. m_bModify=1;
  1033. // for(int i=0; i<m_patharray2.GetSize (); i++)
  1034. // MessageBox(m_patharray2.ElementAt (i));
  1035. if(bSel==0 && m_mode==1 && IsSelPhoto(path)==0)
  1036. {
  1037. temp.Format("%d", iItem);
  1038. m_combo1.AddString (temp);
  1039. // m_List1.DeleteItem (iItem);
  1040. //重新计算array2后顺序乱了, 干脆重载
  1041. // UpdateChooseZS();
  1042. // LoadPhotos();
  1043. // return;
  1044. continue;
  1045. }
  1046. else if(bSel==1 && m_mode==2)
  1047. {
  1048. temp.Format("%d", iItem);
  1049. m_combo1.AddString (temp);
  1050. continue;
  1051. // m_List1.DeleteItem (iItem);
  1052. // m_patharray3.RemoveAt (iItem);
  1053. // if( m_showpichwd)
  1054. // ::SendMessage (m_showpichwd, WM_CLOSE, 0, 0);
  1055. // return;
  1056. }
  1057. else if(bSel==1 && m_mode==3)
  1058. {
  1059. temp.Format("%d", iItem);
  1060. m_combo1.AddString (temp);
  1061. continue;
  1062. // m_List1.DeleteItem (iItem);
  1063. // m_patharray1.Add (m_patharray4.ElementAt (iItem));
  1064. // m_patharray4.RemoveAt (iItem);
  1065. // return;
  1066. }
  1067. /////////////////////////
  1068. CString no;
  1069. no=pArray->ElementAt (iItem);
  1070. no=no.Right (no.GetLength ()-no.ReverseFind ('\\')-1);
  1071. no=no.Left (no.Find ('.'));
  1072. no+=GetSelName(no);
  1073. m_List1.SetItemText (iItem, 0, no);
  1074. }
  1075. if(m_combo1.GetCount ())
  1076. {
  1077. if(m_mode==1)
  1078. {
  1079. for(int i=m_combo1.GetCount ()-1; i>=0; i--)
  1080. {
  1081. m_combo1.GetLBText (i, temp);
  1082. m_List1.DeleteItem (atoi(temp));
  1083. m_patharray3.Add (m_patharray2.ElementAt (atoi(temp)));
  1084. m_patharray2.RemoveAt (atoi(temp));
  1085. }
  1086. // UpdateChooseZS();
  1087. // LoadPhotos();
  1088. if( m_showpichwd)
  1089. ::SendMessage (m_showpichwd, WM_CLOSE, 0, 0);
  1090. }
  1091. else if(m_mode==2)
  1092. {
  1093. for(int i=m_combo1.GetCount ()-1; i>=0; i--)
  1094. {
  1095. m_combo1.GetLBText (i, temp);
  1096. m_List1.DeleteItem (atoi(temp));
  1097. m_patharray3.RemoveAt (atoi(temp));
  1098. }
  1099. if( m_showpichwd)
  1100. ::SendMessage (m_showpichwd, WM_CLOSE, 0, 0);
  1101. }
  1102. else if(m_mode==3)
  1103. {
  1104. for(int i=m_combo1.GetCount ()-1; i>=0; i--)
  1105. {
  1106. m_combo1.GetLBText (i, temp);
  1107. m_List1.DeleteItem (atoi(temp));
  1108. m_patharray1.Add (m_patharray4.ElementAt (atoi(temp)));
  1109. m_patharray4.RemoveAt (atoi(temp));
  1110. }
  1111. if( m_showpichwd)
  1112. ::SendMessage (m_showpichwd, WM_CLOSE, 0, 0);
  1113. }
  1114. }
  1115. Save();
  1116. }
  1117. int ChoosePhotoSkin2::GetZS(CString str)
  1118. {
  1119. str.TrimLeft (",");
  1120. str.TrimRight (",");
  1121. if(str.IsEmpty ())return 0;
  1122. int pos=str.Find (',');
  1123. int count=1;
  1124. while(pos!=-1)
  1125. {
  1126. str.Delete (pos);
  1127. pos=str.Find (',');
  1128. count++;
  1129. }
  1130. return count;
  1131. }
  1132. long ChoosePhotoSkin2::UpdateTakeZS(WPARAM inWParam, LPARAM inLParam)
  1133. {
  1134. UpdateData();
  1135. m_takezs.TrimLeft ();
  1136. if(m_takezs.IsEmpty ())
  1137. {
  1138. m_takezs.Format ("%d", m_List1.GetItemCount () );
  1139. UpdateData(false);
  1140. }
  1141. return 1;
  1142. }
  1143. void ChoosePhotoSkin2::OnButton1()
  1144. {
  1145. // TODO: Add your control notification handler code here
  1146. }
  1147. void ChoosePhotoSkin2::UpdateChooseZS()
  1148. {
  1149. m_patharray2.RemoveAll ();
  1150. CString str;
  1151. for(int i=0; i<m_noarray.GetSize (); i++)
  1152. {
  1153. str=m_noarray.ElementAt (i);
  1154. GetPath(str);
  1155. }
  1156. for( i=0; i<m_no2array.GetSize (); i++)
  1157. {
  1158. str=m_no2array.ElementAt (i);
  1159. GetPath(str);
  1160. }
  1161. }
  1162. void ChoosePhotoSkin2::OnButton2()
  1163. {
  1164. // TODO: Add your control notification handler code here
  1165. }
  1166. void ChoosePhotoSkin2::OnButton3()
  1167. {
  1168. // TODO: Add your control notification handler code here
  1169. }
  1170. void ChoosePhotoSkin2::OnButton4()
  1171. {
  1172. // TODO: Add your control notification handler code here
  1173. UpdateData();
  1174. ChoosePhotoSkin3 dlg;
  1175. dlg.m_pParent =this;
  1176. dlg.DoModal ();
  1177. if(dlg.m_bSave )
  1178. m_bModify=0;
  1179. if(dlg.m_bPushedSave==0 && dlg.m_bSaveFail==0)
  1180. {
  1181. CString savepath;
  1182. savepath.Format ("%s\\%s.dat", g_mainpath, m_id);
  1183. ::DeleteFile (savepath);
  1184. }
  1185. }
  1186. BOOL ChoosePhotoSkin2::OnDel()
  1187. {
  1188. if(m_mode==1)
  1189. {
  1190. AfxMessageBox("选中照片不能删除, 请先取消选中状态!", MB_ICONINFORMATION);
  1191. return 0;
  1192. }
  1193. else if(m_mode==3)
  1194. {
  1195. return 0;
  1196. }
  1197. POSITION pos;
  1198. pos=m_List1.GetFirstSelectedItemPosition();
  1199. if(pos==NULL)
  1200. {
  1201. return 0;
  1202. }
  1203. int iItem=m_List1.GetNextSelectedItem(pos);
  1204. CString no;//=m_List1.GetItemText (iItem, 0);
  1205. CStringArray *pArray=GetCurArray();
  1206. no=pArray->ElementAt (iItem);
  1207. no=no.Right (no.GetLength ()-no.ReverseFind ('\\')-1);
  1208. no=no.Left (no.Find ('.'));
  1209. if(IsSelPhoto(no))
  1210. {
  1211. AfxMessageBox("选中的照片不能删除, 请先取消选中状态!", MB_ICONINFORMATION);
  1212. return 0;
  1213. }
  1214. if(AfxMessageBox("是否删除此照片?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return 0;
  1215. m_List1.DeleteItem (iItem);
  1216. CString name=pArray->ElementAt (iItem);
  1217. m_patharray4.Add (name);
  1218. for(int i=0; i<pArray->GetSize (); i++)
  1219. {
  1220. if(name.CollateNoCase (pArray->ElementAt (i))==0)
  1221. {
  1222. pArray->RemoveAt (i);
  1223. break;
  1224. }
  1225. }
  1226. if(iItem>=pArray->GetSize ())
  1227. iItem=0;
  1228. m_List1.SetItemState (iItem, LVIS_SELECTED, LVIS_SELECTED);
  1229. return 1;
  1230. }
  1231. extern int GetOrientation(Image *image);
  1232. void ChoosePhotoSkin2::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
  1233. {
  1234. // TODO: Add your control notification handler code here
  1235. *pResult = 0;
  1236. }
  1237. void ChoosePhotoSkin2::OnTimer(UINT nIDEvent)
  1238. {
  1239. // TODO: Add your message handler code here and/or call default
  1240. if(nIDEvent==3)
  1241. {
  1242. KillTimer(nIDEvent);
  1243. SetSPName3();
  1244. }
  1245. }
  1246. float ChoosePhotoSkin2::GetSPPriceFromId(CString id)
  1247. {
  1248. for(int i=0; i<m_sparray.GetSize (); i++)
  1249. {
  1250. if(id==m_sparray.ElementAt (i).ElementAt (0))
  1251. return atof(m_sparray.ElementAt (i).ElementAt (4));
  1252. }
  1253. return 0;
  1254. }
  1255. CString ChoosePhotoSkin2::GetSPNameFromId(CString id)
  1256. {
  1257. for(int i=0; i<m_sparray.GetSize (); i++)
  1258. {
  1259. if(id==m_sparray.ElementAt (i).ElementAt (0))
  1260. return m_sparray.ElementAt (i).ElementAt (1);
  1261. }
  1262. id.TrimLeft ("0");
  1263. for( i=0; i<m_sparray.GetSize (); i++)
  1264. {
  1265. if(id==m_sparray.ElementAt (i).ElementAt (0))
  1266. return m_sparray.ElementAt (i).ElementAt (1);
  1267. }
  1268. return "";
  1269. }
  1270. void ChoosePhotoSkin2::SetSPName3()
  1271. {
  1272. /* UpdateData();
  1273. m_no2array.RemoveAll ();
  1274. CString str;
  1275. float list3money=0;
  1276. for(int i=0; i<m_List3.GetItemCount (); i++)
  1277. {
  1278. if(GetSPNameFromId(m_List3.GetItemText (i, 0))!="")
  1279. m_List3.SetItemText(i,1, GetSPNameFromId(m_List3.GetItemText (i, 0)));
  1280. str.Format ("%f", GetSPPriceFromId(m_List3.GetItemText (i, 0)));
  1281. ConvertToPrice (str);
  1282. m_List3.SetItemText(i,2, str);
  1283. list3money+=GetSPPriceFromId(m_List3.GetItemText (i, 0))*atof(m_List3.GetItemText(i,3));
  1284. if(m_List3.GetItemText(i,0)!="" && m_List3.GetItemText(i,1)!="")
  1285. {
  1286. str=m_List3.GetItemText(i,4);str.MakeLower ();
  1287. if(!str.IsEmpty ())
  1288. str=","+str+",";
  1289. m_no2array.Add (str);
  1290. }
  1291. }
  1292. m_money3.Format ("%f", list3money);
  1293. ConvertToPrice(m_money3);
  1294. UpdateData(false);*/
  1295. }
  1296. void ChoosePhotoSkin2::OnSpBox()
  1297. {
  1298. // TODO: Add your control notification handler code here
  1299. /* SPBox dlg;
  1300. if(dlg.DoModal ()!=IDOK)return;
  1301. int pos=m_List3.GetItemCount ();
  1302. CString str;
  1303. if(pos)
  1304. {
  1305. if(m_List3.GetItemText (pos-1, 0).IsEmpty ()&&m_List3.GetItemText (pos-1, 1).IsEmpty ())
  1306. {
  1307. pos--;
  1308. m_List3.SetItemText(pos,0, dlg.m_spid);
  1309. m_List3.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
  1310. str.Format ("%f", GetSPPriceFromId(dlg.m_spid));
  1311. ConvertToPrice (str);
  1312. m_List3.SetItemText(pos,2, str);
  1313. }
  1314. else
  1315. {
  1316. m_List3.InsertItem(pos, dlg.m_spid);
  1317. m_List3.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
  1318. str.Format ("%f", GetSPPriceFromId(dlg.m_spid));
  1319. ConvertToPrice (str);
  1320. m_List3.SetItemText(pos,2, str);
  1321. }
  1322. }
  1323. else
  1324. {
  1325. m_List3.InsertItem(pos, dlg.m_spid);
  1326. m_List3.SetItemText(pos,1, GetSPNameFromId(dlg.m_spid));
  1327. str.Format ("%f", GetSPPriceFromId(dlg.m_spid));
  1328. ConvertToPrice (str);
  1329. m_List3.SetItemText(pos,2, str);
  1330. }
  1331. SetSPName3();*/
  1332. }
  1333. void ChoosePhotoSkin2::OnButton8()
  1334. {
  1335. // TODO: Add your control notification handler code here
  1336. /* POSITION pos;
  1337. pos=m_List3.GetFirstSelectedItemPosition();
  1338. if(pos==NULL)
  1339. {
  1340. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
  1341. return;
  1342. }
  1343. int iItem=m_List3.GetNextSelectedItem(pos);
  1344. m_List3.DeleteItem (iItem);
  1345. SetSPName3();*/
  1346. }
  1347. void ChoosePhotoSkin2::OnButton5()
  1348. {
  1349. // TODO: Add your control notification handler code here
  1350. }
  1351. void ChoosePhotoSkin2::OnButton6()
  1352. {
  1353. // TODO: Add your control notification handler code here
  1354. }
  1355. //查看全部,查看选中,查看未选,查看删除,保存,关闭
  1356. int FindArray(CStringArray *pArray, CString *pStr)
  1357. {
  1358. for(int i=0; i<pArray->GetSize (); i++)
  1359. {
  1360. if(pArray->ElementAt (i)==*pStr)
  1361. return i;
  1362. }
  1363. return -1;
  1364. }
  1365. void ChoosePhotoSkin2::GetPath(CString str)
  1366. {
  1367. str.TrimLeft (",");
  1368. str.TrimRight (",");
  1369. if(str.IsEmpty ())return;
  1370. int pos=str.Find (',');
  1371. CString path;
  1372. while(pos!=-1)
  1373. {
  1374. path=m_path+str.Left (pos)+".jpg";
  1375. if(::FindArray(&m_patharray2, &path)==-1)// && ::FindArray(&m_patharray1, &path)!=-1)
  1376. m_patharray2.Add (path);
  1377. str=str.Right (str.GetLength ()-pos-1);
  1378. pos=str.Find (',');
  1379. }
  1380. path=m_path+str+".jpg";
  1381. if(::FindArray(&m_patharray2, &path)==-1)// && ::FindArray(&m_patharray1, &path)!=-1)
  1382. m_patharray2.Add (path);
  1383. }
  1384. void ChoosePhotoSkin2::LoadPhotos()
  1385. {
  1386. if(m_mode==1)UpdateChooseZS();
  1387. TerminateThread();
  1388. CStringArray *pArray=GetCurArray();
  1389. m_vFileName.clear();
  1390. for(int i=0; i<pArray->GetSize (); i++)
  1391. {
  1392. CString filePath=pArray->ElementAt (i);
  1393. filePath.MakeLower();
  1394. m_vFileName.push_back(filePath);
  1395. }
  1396. LoadThumbImages();
  1397. }
  1398. void ChoosePhotoSkin2::GetNoSelPhoto()
  1399. {
  1400. m_patharray3.RemoveAll ();
  1401. CString str1, str2;
  1402. for(int i=0; i<m_patharray1.GetSize (); i++)
  1403. {
  1404. BOOL bFind=0;
  1405. for(int j=0; j<m_patharray2.GetSize (); j++)
  1406. {
  1407. str1=m_patharray1.ElementAt (i);
  1408. str2=m_patharray2.ElementAt (j);
  1409. if(str1.CollateNoCase (str2)==0)
  1410. {
  1411. bFind=1;
  1412. break;
  1413. }
  1414. }
  1415. if(bFind==0)m_patharray3.Add (m_patharray1.ElementAt (i));
  1416. }
  1417. }
  1418. CStringArray* ChoosePhotoSkin2::GetCurArray()
  1419. {
  1420. CStringArray *pArray;
  1421. switch(m_mode)
  1422. {
  1423. case 0:
  1424. pArray=&m_patharray1;
  1425. break;
  1426. case 1:
  1427. pArray=&m_patharray2;
  1428. break;
  1429. case 2:
  1430. pArray=&m_patharray3;
  1431. break;
  1432. case 3:
  1433. pArray=&m_patharray4;
  1434. break;
  1435. }
  1436. return pArray;
  1437. }
  1438. BOOL ChoosePhotoSkin2::IsSelPhoto(CString path)
  1439. {
  1440. //path.MakeLower ();
  1441. for(int i=0; i<m_no2array.GetSize (); i++)
  1442. {
  1443. //m_no2array.ElementAt (i).MakeLower ();
  1444. if(m_no2array.ElementAt (i).Find (path)!=-1)
  1445. return 1;
  1446. }
  1447. for( i=0; i<m_noarray.GetSize (); i++)
  1448. {
  1449. //m_noarray.ElementAt (i).MakeLower ();
  1450. if(m_noarray.ElementAt (i).Find (path)!=-1)
  1451. return 1;
  1452. }
  1453. return 0;
  1454. }
  1455. CString ChoosePhotoSkin2::GetSelName(CString name)
  1456. {
  1457. CString ret;
  1458. name=","+name+",";
  1459. for(int i=0; i<m_List2.GetItemCount (); i++)
  1460. {
  1461. if(m_noarray.ElementAt (i).Find (name)!=-1)
  1462. {
  1463. ret+=m_List2.GetItemText (i, 2);
  1464. ret+="\r\n";
  1465. }
  1466. }
  1467. for( i=0; i<m_List3.GetItemCount (); i++)
  1468. {
  1469. if(m_no2array.ElementAt (i).Find (name)!=-1)
  1470. {
  1471. ret+=m_List3.GetItemText (i, 2);
  1472. ret+="\r\n";
  1473. }
  1474. }
  1475. if(!ret.IsEmpty ())
  1476. {
  1477. ret="\r\n"+ret;
  1478. ret.TrimRight ("\r\n");
  1479. }
  1480. return ret;
  1481. }
  1482. //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
  1483. void ChoosePhotoSkin2::GetData2()
  1484. {
  1485. CString filter="id='"+m_id+"'";
  1486. g_sendhead.code[0]=31;
  1487. g_sendhead.tabcount=1;
  1488. g_sendhead.bsql=0;
  1489. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  1490. DataToArray(&g_List1array);
  1491. if(g_List1array.GetSize ())
  1492. m_bz2=g_List1array.ElementAt (0).ElementAt (7);
  1493. }
  1494. void ChoosePhotoSkin2::SortArray()
  1495. {
  1496. if(m_mode2)return;
  1497. m_bSort=!m_bSort;
  1498. CStringArray *pArray[4]={&m_patharray1,&m_patharray2,&m_patharray3,&m_patharray4};
  1499. if(m_bSort==0)
  1500. {
  1501. for(int i=0; i<4; i++)
  1502. {
  1503. if(pArray[i]->GetSize ())
  1504. {
  1505. int size=pArray[i]->GetSize ()-1;
  1506. CString sTemp;
  1507. int nPos;
  1508. for(int ii=0;ii<size;ii++)
  1509. {
  1510. nPos=rand()%(size-ii);
  1511. sTemp=pArray[i]->ElementAt (size-ii);
  1512. pArray[i]->SetAt (size-ii, pArray[i]->ElementAt (nPos));
  1513. pArray[i]->SetAt (nPos, sTemp);
  1514. }
  1515. }
  1516. }
  1517. }
  1518. else
  1519. {
  1520. for(int i=0; i<4; i++)
  1521. {
  1522. m_combo1.ResetContent ();
  1523. CString Temp;
  1524. for(int j=0; j<pArray[i]->GetSize (); j++)
  1525. {
  1526. m_combo1.AddString (pArray[i]->ElementAt (j));
  1527. }
  1528. for( j=0; j<pArray[i]->GetSize (); j++)
  1529. {
  1530. m_combo1.GetLBText (j, Temp);
  1531. pArray[i]->SetAt (j, Temp);
  1532. }
  1533. }
  1534. }
  1535. {
  1536. TerminateThread();
  1537. CStringArray *pArray=GetCurArray();
  1538. m_vFileName.clear();
  1539. for(int i=0; i<pArray->GetSize (); i++)
  1540. {
  1541. CString filePath=pArray->ElementAt (i);
  1542. filePath.MakeLower();
  1543. m_vFileName.push_back(filePath);
  1544. }
  1545. LoadThumbImages();
  1546. }
  1547. }
  1548. void ChoosePhotoSkin2::CheckForAlbum()
  1549. {
  1550. for(int i=0; i<m_List2.GetItemCount (); i++)
  1551. {
  1552. if("入册"==m_List2.GetItemText (i, 2))return;
  1553. }
  1554. for( i=0; i<m_List3.GetItemCount (); i++)
  1555. {
  1556. if("入册"==m_List3.GetItemText (i, 2))return;
  1557. }
  1558. i=m_List3.GetItemCount ();
  1559. m_List3.InsertItem(i, "");
  1560. m_List3.SetItemText(i, 2, "入册");
  1561. m_no2array.Add ("");
  1562. }
  1563. void ChoosePhotoSkin2::GetPhotos()//得看设计
  1564. {
  1565. m_patharray1.RemoveAll ();
  1566. m_path.MakeLower ();
  1567. CStringArray dirarray;
  1568. CString str;
  1569. if(1)
  1570. {
  1571. using namespace helper_coffs;
  1572. ffsco o;
  1573. o.dirs(1);
  1574. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  1575. ffsco::typeT coo;
  1576. ffsco::typeT::iterator it;
  1577. coo = o.co_dir();
  1578. for (it = coo.begin();
  1579. coo.end() != it;
  1580. it ++)
  1581. {
  1582. str=(*it).c_str();
  1583. if(FindArray(&dirarray, str)==-1)
  1584. {
  1585. dirarray.Add (str);
  1586. }
  1587. }
  1588. }
  1589. if(1)
  1590. {
  1591. for(int i=0; i<dirarray.GetSize (); i++)
  1592. {
  1593. using namespace helper_coffs;
  1594. ffsco o;
  1595. o.dirs(0);
  1596. o.find(LPCSTR(dirarray.ElementAt (i)), LPCSTR("*.jpg"));
  1597. ffsco::typeT coo;
  1598. ffsco::typeT::iterator it;
  1599. coo = o.co_file();
  1600. for (it = coo.begin();
  1601. coo.end() != it;
  1602. it ++)
  1603. {
  1604. str=(*it).c_str();
  1605. if(str.GetAt (str.ReverseFind ('\\')+1)=='s')continue;
  1606. str.MakeLower ();
  1607. m_patharray1.Add (str);
  1608. }
  1609. }
  1610. }
  1611. }
  1612. void ChoosePhotoSkin2::Save()
  1613. {
  1614. CString sql;
  1615. CArray<CStringArray, CStringArray>sparray;
  1616. sparray.SetSize(m_List2.GetItemCount ()+m_no2array.GetSize ());
  1617. for(int i=0; i<m_List2.GetItemCount (); i++)
  1618. {
  1619. sparray.ElementAt (i).Add ( m_id );
  1620. sparray.ElementAt (i).Add ( m_List2.GetItemText (i, 0) );
  1621. sparray.ElementAt (i).Add ( m_List2.GetItemText (i, 1) );
  1622. sparray.ElementAt (i).Add ( m_List2.GetItemText (i, 2) );
  1623. sparray.ElementAt (i).Add ( m_List2.GetItemText (i, 3) );
  1624. sparray.ElementAt (i).Add ( m_List2.GetItemText (i, 4) );
  1625. }
  1626. for( int j=0; j<m_no2array.GetSize (); j++)
  1627. {
  1628. sparray.ElementAt (i).Add ( m_id );
  1629. sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 0) );
  1630. sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 1) );
  1631. sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 2) );
  1632. sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 3) );
  1633. sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 4) );
  1634. sparray.ElementAt (i).Add ( m_List3.GetItemText (j, 5) );
  1635. sparray.ElementAt (i).Add ( "4" );
  1636. i++;
  1637. }
  1638. if(sparray.GetSize ()==0)
  1639. {
  1640. sparray.SetSize(1);
  1641. sparray.ElementAt (0).Add (m_id);
  1642. }
  1643. CMemFile memfile;
  1644. CArchive ar(&memfile, CArchive::store);
  1645. for(int ii=0; ii<sparray.GetSize (); ii++)
  1646. {
  1647. sparray.ElementAt (ii).Serialize (ar);
  1648. }
  1649. ar.Close();
  1650. int length=memfile.GetLength ();
  1651. BYTE *pData = memfile.Detach();
  1652. int size=sparray.GetSize ();
  1653. BYTE *pData2=new BYTE[length+sizeof(int)];
  1654. memcpy(pData2, pData, length);
  1655. memcpy(pData2+length, &size, sizeof(int));
  1656. delete []pData;
  1657. length+=sizeof(int);
  1658. CString savepath;
  1659. savepath.Format ("%s\\%s.dat", g_mainpath, m_id);
  1660. if(1)
  1661. {
  1662. CFile fp;
  1663. fp.Open (savepath, CFile::modeCreate|CFile::modeWrite);
  1664. fp.Write (pData2, length);
  1665. fp.Close ();
  1666. }
  1667. delete []pData2;
  1668. }