SetDesignNo.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. // SetDesignNo.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "SetDesignNo.h"
  6. #include "ShowPic22.h"
  7. #include "JPEG.h"
  8. #define THUMBNAIL_WIDTH 80
  9. #define THUMBNAIL_HEIGHT 70
  10. /////////////////////////////////////////////////////////////////////////////
  11. // SetDesignNo dialog IDC_BU Tdelall
  12. SetDesignNo::SetDesignNo(CWnd* pParent /*=NULL*/)
  13. : CDialog(SetDesignNo::IDD, pParent)
  14. {
  15. //{{AFX_DATA_INIT(SetDesignNo)
  16. // NOTE: the ClassWizard will add member initialization here
  17. //}}AFX_DATA_INIT
  18. m_bTerminate=false;
  19. m_bRunning=false;
  20. m_hThread = NULL;
  21. m_bTerminate2=false;
  22. m_bRunning2=false;
  23. m_hThread2 = NULL;
  24. m_image=NULL;
  25. }
  26. void SetDesignNo::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(SetDesignNo)
  30. DDX_Control(pDX, IDC_LIST4, m_List4);
  31. DDX_Control(pDX, IDC_LIST1, m_List1);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(SetDesignNo, CDialog)
  35. //{{AFX_MSG_MAP(SetDesignNo)
  36. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  37. ON_WM_DESTROY()
  38. ON_NOTIFY(NM_DBLCLK, IDC_LIST4, OnDblclkList4)
  39. ON_WM_CTLCOLOR()
  40. ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
  41. ON_NOTIFY(NM_CLICK, IDC_LIST4, OnClickList4)
  42. ON_WM_PAINT()
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // SetDesignNo message handlers
  47. extern BOOL CALLBACK EnumChildProc2(HWND hwnd,LPARAM lParam);
  48. extern float m_WidthScale2;
  49. extern float m_HeightScale2;
  50. BOOL SetDesignNo::OnInitDialog()
  51. {
  52. CDialog::OnInitDialog();
  53. CRect rc2,rc;
  54. GetWindowRect(rc2);
  55. MoveWindow(g_rc);
  56. m_WidthScale2 = (float)g_rc.Width()/(float)rc2.Width(); // new/Old
  57. m_HeightScale2 = (float)g_rc.Height()/(float)rc2.Height();
  58. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc2,0);
  59. GetDlgItem(IDC_STATIC1)->GetWindowRect(rc2);
  60. rc2.right -=rc2.left ;
  61. rc2.bottom -=rc2.top ;
  62. rc2.left =rc2.top =0;
  63. GetDlgItem(IDC_STATIC1)->MoveWindow(rc2);
  64. GetDlgItem(IDC_STATIC2)->MoveWindow(rc2);
  65. GetDlgItem(IDC_STATIC3)->GetWindowRect(rc);
  66. ScreenToClient(rc);
  67. rc.top =rc2.bottom ;
  68. GetDlgItem(IDC_STATIC3)->MoveWindow(rc);
  69. CString str;
  70. str="\r\n 功能简介:设置每一张设计版面所用的客人照片编号\r\n 1. 点选左侧要设置的一张设计版 2. Ctrl+点选右侧此设计版所用的原片 3. 重复前两步全部设置完成点击保存";
  71. GetDlgItem(IDC_STATIC1)->SetWindowText(str);
  72. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  73. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  74. m_ImageListThumb2.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  75. m_List4.SetImageList(&m_ImageListThumb2, LVSIL_NORMAL);
  76. CString filter="id='"+m_id+"'";
  77. g_sendhead.code[0]=11;
  78. g_sendhead.tabcount=1;
  79. g_sendhead.bsql=0;
  80. g_pMainWnd->ProcessChatMessageRequest2(filter);
  81. if(g_bSendOK==0)
  82. {
  83. CDialog::OnCancel ();
  84. return 0;
  85. }
  86. DataToArray(&g_List1array);
  87. if(g_List1array.GetSize ())
  88. {
  89. m_designno=g_List1array.ElementAt (0).ElementAt (58);
  90. }
  91. LoadPhotos();
  92. return TRUE; // return TRUE unless you set the focus to a control
  93. // EXCEPTION: OCX Property Pages should return FALSE
  94. }
  95. unsigned __stdcall LoadThumbNail11(LPVOID lpParam)
  96. {
  97. try
  98. {
  99. SetDesignNo *pDlg=(SetDesignNo*)lpParam;
  100. CListCtrl *ListCtrl=&pDlg->m_List1;
  101. CImageList* pImgList=&pDlg->m_ImageListThumb;
  102. // reset our image list
  103. for(int i=0; i<pImgList->GetImageCount(); i++)
  104. pImgList->Remove(i);
  105. // remove all items from list view
  106. ListCtrl->DeleteAllItems();
  107. pImgList->SetImageCount(pDlg->m_vFileName.size());
  108. TCHAR path[MAX_PATH];
  109. vector<CString>::iterator iter;
  110. // Set redraw to FALSE to avoid flickering during adding new items
  111. ListCtrl->SetRedraw(FALSE);
  112. int nIndex=0;
  113. CString str, spath;
  114. for(iter=pDlg->m_vFileName.begin(); iter!=pDlg->m_vFileName.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  115. {
  116. str=*iter;
  117. spath.Empty ();
  118. if(str.Left (str.ReverseFind ('\\')+1)!=pDlg->m_path2)
  119. {
  120. spath=str.Left (str.ReverseFind ('\\')+1);
  121. spath= spath.Right (spath.GetLength ()-pDlg->m_path2.GetLength ());
  122. }
  123. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  124. str=spath+str.Left (str.GetLength ()-4);
  125. ListCtrl->InsertItem(nIndex, str, nIndex);
  126. }
  127. ListCtrl->SetRedraw(TRUE);
  128. ListCtrl->Invalidate();
  129. const float fRatio=(float)THUMBNAIL_HEIGHT/THUMBNAIL_WIDTH;
  130. int XDest, YDest, nDestWidth, nDestHeight;
  131. nIndex=0;
  132. SolidBrush whitebrush(Color(255,255,255,255));
  133. for(iter=pDlg->m_vFileName.begin(); iter!=pDlg->m_vFileName.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  134. {
  135. // Load Image File
  136. Image *image=NULL;
  137. Bitmap *pBmp=NULL;
  138. str=*iter;
  139. spath=str.Left (str.ReverseFind ('\\')+1);
  140. spath+="s";
  141. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  142. if(::CheckFileExist (spath))
  143. ::LoadImageFromBuf (&image, spath);
  144. else
  145. ::LoadImageFromBuf (&image, str);
  146. int orientation=GetOrientation(image);
  147. if(orientation==8)
  148. image->RotateFlip( Rotate270FlipNone );
  149. else if(orientation==6)
  150. image->RotateFlip( Rotate90FlipNone );
  151. if(image->GetWidth()==0)
  152. continue;
  153. // Calculate Rect to fit to canvas
  154. const float fImgRatio=(float)image->GetHeight()/image->GetWidth();
  155. if(fImgRatio > fRatio)
  156. {
  157. nDestWidth=THUMBNAIL_HEIGHT/fImgRatio;
  158. XDest=(THUMBNAIL_WIDTH-nDestWidth)/2;
  159. YDest=0;
  160. nDestHeight=THUMBNAIL_HEIGHT;
  161. }
  162. else
  163. {
  164. XDest=0;
  165. nDestWidth=THUMBNAIL_WIDTH;
  166. nDestHeight=THUMBNAIL_WIDTH*fImgRatio;
  167. YDest=(THUMBNAIL_HEIGHT-nDestHeight)/2;
  168. }
  169. pBmp=new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB );
  170. Graphics graph2(pBmp);
  171. graph2.Clear(Color(255,192,192,192));
  172. graph2.FillRectangle (&whitebrush,1, 1, THUMBNAIL_WIDTH-2, THUMBNAIL_HEIGHT-2);
  173. Graphics graph(pBmp);
  174. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  175. // Draw Image
  176. graph.DrawImage(image, desRect, 0,0,image->GetWidth(),image->GetHeight(),UnitPixel);
  177. delete image;
  178. // Attach to Bitmap and Replace image in CImageList
  179. CBitmap bitmap;
  180. HBITMAP hbmp;
  181. pBmp->GetHBITMAP(Color(255,255,255,255), &hbmp);
  182. bitmap.Attach(hbmp);
  183. pImgList->Replace(nIndex, &bitmap, NULL);
  184. delete pBmp;
  185. // Redraw only a current item for removing flickering and fast speed.
  186. ListCtrl->RedrawItems(nIndex, nIndex);
  187. // Release used DC and Object
  188. }
  189. ListCtrl->Invalidate();
  190. pDlg->m_bRunning=false;
  191. pDlg->m_bTerminate=false;
  192. _endthreadex( 0 );
  193. return 0;
  194. }
  195. catch(...)
  196. {
  197. }
  198. }
  199. unsigned __stdcall LoadThumbNail12(LPVOID lpParam)
  200. {
  201. try
  202. {
  203. SetDesignNo *pDlg=(SetDesignNo*)lpParam;
  204. CImageList* pImgList=&pDlg->m_ImageListThumb2;
  205. CListCtrl *ListCtrl=&pDlg->m_List4;
  206. // reset our image list
  207. for(int i=0; i<pImgList->GetImageCount(); i++)
  208. pImgList->Remove(i);
  209. // remove all items from list view
  210. ListCtrl->DeleteAllItems();
  211. pImgList->SetImageCount(pDlg->m_vFileName2.size());
  212. TCHAR path[MAX_PATH];
  213. vector<CString>::iterator iter;
  214. // Set redraw to FALSE to avoid flickering during adding new items
  215. ListCtrl->SetRedraw(FALSE);
  216. int nIndex=0;
  217. CString str, spath;
  218. for(iter=pDlg->m_vFileName2.begin(); iter!=pDlg->m_vFileName2.end() && pDlg->m_bTerminate2!=true; iter++, nIndex++)
  219. {
  220. str=*iter;
  221. spath.Empty ();
  222. if(str.Left (str.ReverseFind ('\\')+1)!=pDlg->m_path)
  223. {
  224. spath=str.Left (str.ReverseFind ('\\')+1);
  225. spath= spath.Right (spath.GetLength ()-pDlg->m_path.GetLength ());
  226. }
  227. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  228. str=spath+str.Left (str.GetLength ()-4);
  229. ListCtrl->InsertItem(nIndex, str, nIndex);
  230. }
  231. ListCtrl->SetRedraw(TRUE);
  232. ListCtrl->Invalidate();
  233. const float fRatio=(float)THUMBNAIL_HEIGHT/THUMBNAIL_WIDTH;
  234. int XDest, YDest, nDestWidth, nDestHeight;
  235. nIndex=0;
  236. SolidBrush whitebrush(Color(255,255,255,255));
  237. for(iter=pDlg->m_vFileName2.begin(); iter!=pDlg->m_vFileName2.end() && pDlg->m_bTerminate2!=true; iter++, nIndex++)
  238. {
  239. // Load Image File
  240. Image *image=NULL;
  241. Bitmap *pBmp=NULL;
  242. str=*iter;
  243. spath=str.Left (str.ReverseFind ('\\')+1);
  244. spath+="s";
  245. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  246. if(::CheckFileExist (spath))
  247. ::LoadImageFromBuf (&image, spath);
  248. else
  249. ::LoadImageFromBuf (&image, str);
  250. int orientation=GetOrientation(image);
  251. if(orientation==8)
  252. image->RotateFlip( Rotate270FlipNone );
  253. else if(orientation==6)
  254. image->RotateFlip( Rotate90FlipNone );
  255. if(image->GetWidth()==0)
  256. continue;
  257. // Calculate Rect to fit to canvas
  258. const float fImgRatio=(float)image->GetHeight()/image->GetWidth();
  259. if(fImgRatio > fRatio)
  260. {
  261. nDestWidth=THUMBNAIL_HEIGHT/fImgRatio;
  262. XDest=(THUMBNAIL_WIDTH-nDestWidth)/2;
  263. YDest=0;
  264. nDestHeight=THUMBNAIL_HEIGHT;
  265. }
  266. else
  267. {
  268. XDest=0;
  269. nDestWidth=THUMBNAIL_WIDTH;
  270. nDestHeight=THUMBNAIL_WIDTH*fImgRatio;
  271. YDest=(THUMBNAIL_HEIGHT-nDestHeight)/2;
  272. }
  273. pBmp=new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB );
  274. Graphics graph2(pBmp);
  275. graph2.Clear(Color(255,192,192,192));
  276. graph2.FillRectangle (&whitebrush,1, 1, THUMBNAIL_WIDTH-2, THUMBNAIL_HEIGHT-2);
  277. Graphics graph(pBmp);
  278. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  279. // Draw Image
  280. graph.DrawImage(image, desRect, 0,0,image->GetWidth(),image->GetHeight(),UnitPixel);
  281. delete image;
  282. // Attach to Bitmap and Replace image in CImageList
  283. CBitmap bitmap;
  284. HBITMAP hbmp;
  285. pBmp->GetHBITMAP(Color(255,255,255,255), &hbmp);
  286. bitmap.Attach(hbmp);
  287. pImgList->Replace(nIndex, &bitmap, NULL);
  288. delete pBmp;
  289. // Redraw only a current item for removing flickering and fast speed.
  290. ListCtrl->RedrawItems(nIndex, nIndex);
  291. // Release used DC and Object
  292. }
  293. ListCtrl->Invalidate();
  294. pDlg->m_bRunning2=false;
  295. pDlg->m_bTerminate2=false;
  296. _endthreadex( 0 );
  297. return 0;
  298. }
  299. catch(...)
  300. {
  301. }
  302. }
  303. void SetDesignNo::LoadThumbImages()
  304. {
  305. TerminateThread();
  306. m_hThread = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail11,(LPVOID)this,0/* CREATE_SUSPENDED*/,&m_dwThreadID);
  307. m_bRunning=true;
  308. }
  309. BOOL SetDesignNo::TerminateThread()
  310. {
  311. if ( !m_bRunning )
  312. return TRUE;
  313. m_bTerminate=true;
  314. for( ; ; )
  315. {
  316. if ( ::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0 )
  317. break;
  318. MSG msg;
  319. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  320. {
  321. if (!AfxGetApp()->PumpMessage())
  322. break;
  323. }
  324. }
  325. ::CloseHandle(m_hThread);
  326. return TRUE;
  327. }
  328. void SetDesignNo::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  329. {
  330. // TODO: Add your control notification handler code here
  331. POSITION pos;
  332. pos=m_List1.GetFirstSelectedItemPosition();
  333. if(pos==NULL)
  334. {
  335. return;
  336. }
  337. int iItem=m_List1.GetNextSelectedItem(pos);
  338. ShowPic22 dlg;
  339. dlg.m_pos=iItem;
  340. dlg.m_pPathArray=&m_patharray1;
  341. dlg.DoModal ();
  342. *pResult = 0;
  343. }
  344. void SetDesignNo::OnDestroy()
  345. {
  346. if(m_image)delete m_image;m_image=NULL;
  347. TerminateThread();TerminateThread2(); CDialog::OnDestroy();
  348. // TODO: Add your message handler code here
  349. }
  350. void SetDesignNo::LoadPhotos()
  351. {
  352. m_path2=g_path3+"\\";
  353. m_path2+=m_id;
  354. m_path2 +="\\";
  355. int i = 0;
  356. m_patharray1.RemoveAll ();
  357. m_path2.MakeLower ();
  358. CStringArray dirarray;
  359. CString str;
  360. if(1)
  361. {
  362. using namespace helper_coffs;
  363. ffsco o;
  364. o.dirs(1);
  365. o.find(LPCSTR(m_path2), LPCSTR("*.*"));
  366. ffsco::typeT coo;
  367. ffsco::typeT::iterator it;
  368. coo = o.co_dir();
  369. for (it = coo.begin();coo.end() != it;it ++)
  370. {
  371. str=(*it).c_str();
  372. if(FindArray(&dirarray, str)==-1)
  373. {
  374. dirarray.Add (str);
  375. }
  376. }
  377. }
  378. if(1)
  379. {
  380. for( i=0; i<dirarray.GetSize (); i++)
  381. {
  382. using namespace helper_coffs;
  383. ffsco o;
  384. o.dirs(0);
  385. o.find(LPCSTR(dirarray.ElementAt (i)), LPCSTR("*.jpg"));
  386. ffsco::typeT coo;
  387. ffsco::typeT::iterator it;
  388. coo = o.co_file();
  389. for (it = coo.begin();coo.end() != it;it ++)
  390. {
  391. str=(*it).c_str();
  392. if(str.GetAt (str.ReverseFind ('\\')+1)=='s')continue;
  393. if(str.GetAt (str.ReverseFind ('\\')+1)=='m')continue;
  394. str.MakeLower ();
  395. m_patharray1.Add (str);
  396. }
  397. }
  398. }
  399. CStringArray *pArray=&m_patharray1;
  400. m_vFileName.clear();
  401. for( i=0; i<pArray->GetSize (); i++)
  402. {
  403. CString filePath=pArray->ElementAt (i);
  404. filePath.MakeLower();
  405. m_vFileName.push_back(filePath);
  406. }
  407. LoadThumbImages();
  408. /////////////
  409. m_path=g_path1+"\\";
  410. m_path+=m_id;
  411. m_path +="\\";
  412. m_patharray2.RemoveAll ();
  413. m_path.MakeLower ();
  414. dirarray.RemoveAll ();
  415. if(1)
  416. {
  417. using namespace helper_coffs;
  418. ffsco o;
  419. o.dirs(1);
  420. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  421. ffsco::typeT coo;
  422. ffsco::typeT::iterator it;
  423. coo = o.co_dir();
  424. for (it = coo.begin();coo.end() != it;it ++)
  425. {
  426. str=(*it).c_str();
  427. if(FindArray(&dirarray, str)==-1)
  428. {
  429. dirarray.Add (str);
  430. }
  431. }
  432. }
  433. if(1)
  434. {
  435. for( i=0; i<dirarray.GetSize (); i++)
  436. {
  437. using namespace helper_coffs;
  438. ffsco o;
  439. o.dirs(0);
  440. o.find(LPCSTR(dirarray.ElementAt (i)), LPCSTR("*.jpg"));
  441. ffsco::typeT coo;
  442. ffsco::typeT::iterator it;
  443. coo = o.co_file();
  444. for (it = coo.begin();coo.end() != it;it ++)
  445. {
  446. str=(*it).c_str();
  447. if(str.GetAt (str.ReverseFind ('\\')+1)=='s')continue;
  448. if(str.GetAt (str.ReverseFind ('\\')+1)=='m')continue;
  449. str.MakeLower ();
  450. m_patharray2.Add (str);
  451. }
  452. }
  453. }
  454. if(m_bRunning2)return;
  455. pArray=&m_patharray2;
  456. m_vFileName2.clear();
  457. for( i=0; i<pArray->GetSize (); i++)
  458. {
  459. CString filePath=pArray->ElementAt (i);
  460. filePath.MakeLower();
  461. m_vFileName2.push_back(filePath);
  462. }
  463. TerminateThread2();
  464. m_hThread2 = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail12,(LPVOID)this,0,&m_dwThreadID2);
  465. m_bRunning2=true;
  466. }
  467. BOOL SetDesignNo::TerminateThread2()
  468. {
  469. if ( !m_bRunning2 )
  470. return TRUE;
  471. m_bTerminate2=true;
  472. for( ; ; )
  473. {
  474. if ( ::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0 )
  475. break;
  476. MSG msg;
  477. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  478. {
  479. if (!AfxGetApp()->PumpMessage())
  480. break;
  481. }
  482. }
  483. ::CloseHandle(m_hThread2);
  484. return TRUE;
  485. }
  486. void SetDesignNo::OnDblclkList4(NMHDR* pNMHDR, LRESULT* pResult)
  487. {
  488. // TODO: Add your control notification handler code here
  489. POSITION pos;
  490. pos=m_List4.GetFirstSelectedItemPosition();
  491. if(pos==NULL)
  492. {
  493. return;
  494. }
  495. int iItem=m_List4.GetNextSelectedItem(pos);
  496. ShowPic22 dlg;
  497. dlg.m_pos=iItem;
  498. dlg.m_pPathArray=&m_patharray2;
  499. dlg.DoModal ();
  500. *pResult = 0;
  501. }
  502. HBRUSH SetDesignNo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  503. {
  504. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  505. // TODO: Change any attributes of the DC here
  506. if (nCtlColor==CTLCOLOR_STATIC && pWnd->GetDlgCtrlID ()==IDC_STATIC1)
  507. {
  508. pDC-> SetBkMode(TRANSPARENT); //设置字体背景为透明
  509. return (HBRUSH)::GetStockObject(WHITE_BRUSH); // 设置背景色
  510. }
  511. // TODO: Return a different brush if the default is not desired
  512. // TODO: Return a different brush if the default is not desired
  513. return hbr;
  514. }
  515. void SetDesignNo::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
  516. {
  517. // TODO: Add your control notification handler code here
  518. POSITION ppos;
  519. ppos=m_List1.GetFirstSelectedItemPosition();
  520. if(ppos==NULL)
  521. {
  522. return;
  523. }
  524. int iItem=m_List1.GetNextSelectedItem(ppos);
  525. CString title="$"+m_List1.GetItemText (iItem, 0)+":";
  526. CString str,spath;
  527. if(m_image)delete m_image;m_image=NULL;
  528. str=m_patharray1.ElementAt (iItem);
  529. spath=str.Left (str.ReverseFind ('\\')+1);
  530. spath+="s";
  531. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  532. if(::CheckFileExist (spath))
  533. ::LoadImageFromBuf (&m_image, spath);
  534. else
  535. ::LoadImageFromBuf (&m_image, str);
  536. CRect rc;
  537. GetDlgItem(IDC_STATIC3)->GetWindowRect(rc);
  538. ScreenToClient(rc);
  539. InvalidateRect(rc);
  540. CString sel;
  541. // m_designno="$10x8寸晶透水晶\\005:001,002,003";
  542. //$xxxx:001,002,003,004$
  543. int pos=m_designno.Find (title);
  544. if(pos!=-1)
  545. {
  546. sel=m_designno.Right (m_designno.GetLength ()-pos);
  547. sel=sel.Right (sel.GetLength ()-title.GetLength ());
  548. pos=sel.Find ("$");
  549. if(pos!=-1)
  550. sel=sel.Left (pos);
  551. sel.TrimLeft (",");
  552. sel.TrimRight (",");
  553. sel=","+sel+",";
  554. }
  555. for(int i=0; i<m_List4.GetItemCount (); i++)
  556. {
  557. title=","+m_List4.GetItemText (i, 0)+",";
  558. if(sel.Find (title)!=-1)
  559. m_List4.SetItemState (i, LVIS_SELECTED, LVIS_SELECTED);
  560. else
  561. m_List4.SetItemState (i, 0, LVIS_SELECTED);
  562. }
  563. m_List4.SetFocus ();
  564. *pResult = 0;
  565. }
  566. void SetDesignNo::OnClickList4(NMHDR* pNMHDR, LRESULT* pResult)
  567. {
  568. // TODO: Add your control notification handler code here
  569. POSITION ppos;
  570. ppos=m_List1.GetFirstSelectedItemPosition();
  571. if(ppos==NULL)
  572. {
  573. return;
  574. }
  575. int iItem=m_List1.GetNextSelectedItem(ppos);
  576. CString title="$"+m_List1.GetItemText (iItem, 0)+":";
  577. CString sel,temp;
  578. {//
  579. POSITION pos;
  580. pos=m_List4.GetFirstSelectedItemPosition();
  581. while (pos)
  582. {
  583. iItem=m_List4.GetNextSelectedItem(pos);
  584. sel+=m_List4.GetItemText (iItem, 0);
  585. sel+=",";
  586. }
  587. sel.TrimRight (",");
  588. }//
  589. // m_designno="$10x18寸晶透水晶\\005:001,002,003$10x28寸晶透水晶\\005:001,002,003$10x18寸晶透水晶\\005:001,002,003";
  590. //$xxxx:001,002,003,004$
  591. int pos=m_designno.Find (title);
  592. if(pos!=-1)
  593. {
  594. temp=m_designno.Right (m_designno.GetLength ()-pos-title.GetLength ());
  595. int pos2=temp.Find ("$");
  596. if(pos2!=-1)
  597. temp=temp.Right (temp.GetLength ()-pos2);
  598. else
  599. temp.Empty ();
  600. m_designno=m_designno.Left (pos+title.GetLength ());
  601. m_designno+=sel;
  602. m_designno+=temp;
  603. }
  604. else
  605. {
  606. m_designno+=title;
  607. m_designno+=sel;
  608. }
  609. *pResult = 0;
  610. }
  611. void SetDesignNo::OnOK()
  612. {
  613. // TODO: Add extra validation here
  614. CString sql="update dindan set designno='"+m_designno+"' where id='"+m_id+"'";
  615. g_sendhead.bsql=1;
  616. g_pMainWnd->ProcessChatMessageRequest2(sql);
  617. if(g_bSendOK==0)return;
  618. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  619. }
  620. void SetDesignNo::OnPaint()
  621. {
  622. CPaintDC dc(this); // device context for painting
  623. // TODO: Add your message handler code here
  624. if(m_image)
  625. {
  626. CRect rc;
  627. GetDlgItem(IDC_STATIC3)->GetWindowRect(rc);
  628. ScreenToClient(rc);
  629. RectFitDes(m_image->GetWidth(), m_image->GetHeight(), rc);
  630. Graphics dcgraph(dc.GetSafeHdc());
  631. Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ());
  632. dcgraph.DrawImage(m_image, destinationRect, 0,0,m_image->GetWidth(), m_image->GetHeight(),UnitPixel);
  633. }
  634. // Do not call CDialog::OnPaint() for painting messages
  635. }