SetDesignNo.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  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. m_patharray1.RemoveAll ();
  356. m_path2.MakeLower ();
  357. CStringArray dirarray;
  358. CString str;
  359. if(1)
  360. {
  361. using namespace helper_coffs;
  362. ffsco o;
  363. o.dirs(1);
  364. o.find(LPCSTR(m_path2), LPCSTR("*.*"));
  365. ffsco::typeT coo;
  366. ffsco::typeT::iterator it;
  367. coo = o.co_dir();
  368. for (it = coo.begin();
  369. coo.end() != it;
  370. it ++)
  371. {
  372. str=(*it).c_str();
  373. if(FindArray(&dirarray, str)==-1)
  374. {
  375. dirarray.Add (str);
  376. }
  377. }
  378. }
  379. if(1)
  380. {
  381. for(int i=0; i<dirarray.GetSize (); i++)
  382. {
  383. using namespace helper_coffs;
  384. ffsco o;
  385. o.dirs(0);
  386. o.find(LPCSTR(dirarray.ElementAt (i)), LPCSTR("*.jpg"));
  387. ffsco::typeT coo;
  388. ffsco::typeT::iterator it;
  389. coo = o.co_file();
  390. for (it = coo.begin();
  391. coo.end() != it;
  392. it ++)
  393. {
  394. str=(*it).c_str();
  395. if(str.GetAt (str.ReverseFind ('\\')+1)=='s')continue;
  396. if(str.GetAt (str.ReverseFind ('\\')+1)=='m')continue;
  397. str.MakeLower ();
  398. m_patharray1.Add (str);
  399. }
  400. }
  401. }
  402. CStringArray *pArray=&m_patharray1;
  403. m_vFileName.clear();
  404. for(int i=0; i<pArray->GetSize (); i++)
  405. {
  406. CString filePath=pArray->ElementAt (i);
  407. filePath.MakeLower();
  408. m_vFileName.push_back(filePath);
  409. }
  410. LoadThumbImages();
  411. /////////////
  412. m_path=g_path1+"\\";
  413. m_path+=m_id;
  414. m_path +="\\";
  415. m_patharray2.RemoveAll ();
  416. m_path.MakeLower ();
  417. dirarray.RemoveAll ();
  418. if(1)
  419. {
  420. using namespace helper_coffs;
  421. ffsco o;
  422. o.dirs(1);
  423. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  424. ffsco::typeT coo;
  425. ffsco::typeT::iterator it;
  426. coo = o.co_dir();
  427. for (it = coo.begin();
  428. coo.end() != it;
  429. it ++)
  430. {
  431. str=(*it).c_str();
  432. if(FindArray(&dirarray, str)==-1)
  433. {
  434. dirarray.Add (str);
  435. }
  436. }
  437. }
  438. if(1)
  439. {
  440. for(int i=0; i<dirarray.GetSize (); i++)
  441. {
  442. using namespace helper_coffs;
  443. ffsco o;
  444. o.dirs(0);
  445. o.find(LPCSTR(dirarray.ElementAt (i)), LPCSTR("*.jpg"));
  446. ffsco::typeT coo;
  447. ffsco::typeT::iterator it;
  448. coo = o.co_file();
  449. for (it = coo.begin();
  450. coo.end() != it;
  451. it ++)
  452. {
  453. str=(*it).c_str();
  454. if(str.GetAt (str.ReverseFind ('\\')+1)=='s')continue;
  455. if(str.GetAt (str.ReverseFind ('\\')+1)=='m')continue;
  456. str.MakeLower ();
  457. m_patharray2.Add (str);
  458. }
  459. }
  460. }
  461. if(m_bRunning2)return;
  462. pArray=&m_patharray2;
  463. m_vFileName2.clear();
  464. for( i=0; i<pArray->GetSize (); i++)
  465. {
  466. CString filePath=pArray->ElementAt (i);
  467. filePath.MakeLower();
  468. m_vFileName2.push_back(filePath);
  469. }
  470. TerminateThread2();
  471. m_hThread2 = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail12,(LPVOID)this,0,&m_dwThreadID2);
  472. m_bRunning2=true;
  473. }
  474. BOOL SetDesignNo::TerminateThread2()
  475. {
  476. if ( !m_bRunning2 )
  477. return TRUE;
  478. m_bTerminate2=true;
  479. for( ; ; )
  480. {
  481. if ( ::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0 )
  482. break;
  483. MSG msg;
  484. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  485. {
  486. if (!AfxGetApp()->PumpMessage())
  487. break;
  488. }
  489. }
  490. ::CloseHandle(m_hThread2);
  491. return TRUE;
  492. }
  493. void SetDesignNo::OnDblclkList4(NMHDR* pNMHDR, LRESULT* pResult)
  494. {
  495. // TODO: Add your control notification handler code here
  496. POSITION pos;
  497. pos=m_List4.GetFirstSelectedItemPosition();
  498. if(pos==NULL)
  499. {
  500. return;
  501. }
  502. int iItem=m_List4.GetNextSelectedItem(pos);
  503. ShowPic22 dlg;
  504. dlg.m_pos=iItem;
  505. dlg.m_pPathArray=&m_patharray2;
  506. dlg.DoModal ();
  507. *pResult = 0;
  508. }
  509. HBRUSH SetDesignNo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  510. {
  511. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  512. // TODO: Change any attributes of the DC here
  513. if (nCtlColor==CTLCOLOR_STATIC && pWnd->GetDlgCtrlID ()==IDC_STATIC1)
  514. {
  515. pDC-> SetBkMode(TRANSPARENT); //设置字体背景为透明
  516. return (HBRUSH)::GetStockObject(WHITE_BRUSH); // 设置背景色
  517. }
  518. // TODO: Return a different brush if the default is not desired
  519. // TODO: Return a different brush if the default is not desired
  520. return hbr;
  521. }
  522. void SetDesignNo::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
  523. {
  524. // TODO: Add your control notification handler code here
  525. POSITION ppos;
  526. ppos=m_List1.GetFirstSelectedItemPosition();
  527. if(ppos==NULL)
  528. {
  529. return;
  530. }
  531. int iItem=m_List1.GetNextSelectedItem(ppos);
  532. CString title="$"+m_List1.GetItemText (iItem, 0)+":";
  533. CString str,spath;
  534. if(m_image)delete m_image;m_image=NULL;
  535. str=m_patharray1.ElementAt (iItem);
  536. spath=str.Left (str.ReverseFind ('\\')+1);
  537. spath+="s";
  538. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  539. if(::CheckFileExist (spath))
  540. ::LoadImageFromBuf (&m_image, spath);
  541. else
  542. ::LoadImageFromBuf (&m_image, str);
  543. CRect rc;
  544. GetDlgItem(IDC_STATIC3)->GetWindowRect(rc);
  545. ScreenToClient(rc);
  546. InvalidateRect(rc);
  547. CString sel;
  548. // m_designno="$10x8寸晶透水晶\\005:001,002,003";
  549. //$xxxx:001,002,003,004$
  550. int pos=m_designno.Find (title);
  551. if(pos!=-1)
  552. {
  553. sel=m_designno.Right (m_designno.GetLength ()-pos);
  554. sel=sel.Right (sel.GetLength ()-title.GetLength ());
  555. pos=sel.Find ("$");
  556. if(pos!=-1)
  557. sel=sel.Left (pos);
  558. sel.TrimLeft (",");
  559. sel.TrimRight (",");
  560. sel=","+sel+",";
  561. }
  562. for(int i=0; i<m_List4.GetItemCount (); i++)
  563. {
  564. title=","+m_List4.GetItemText (i, 0)+",";
  565. if(sel.Find (title)!=-1)
  566. m_List4.SetItemState (i, LVIS_SELECTED, LVIS_SELECTED);
  567. else
  568. m_List4.SetItemState (i, 0, LVIS_SELECTED);
  569. }
  570. m_List4.SetFocus ();
  571. *pResult = 0;
  572. }
  573. void SetDesignNo::OnClickList4(NMHDR* pNMHDR, LRESULT* pResult)
  574. {
  575. // TODO: Add your control notification handler code here
  576. POSITION ppos;
  577. ppos=m_List1.GetFirstSelectedItemPosition();
  578. if(ppos==NULL)
  579. {
  580. return;
  581. }
  582. int iItem=m_List1.GetNextSelectedItem(ppos);
  583. CString title="$"+m_List1.GetItemText (iItem, 0)+":";
  584. CString sel,temp;
  585. {//
  586. POSITION pos;
  587. pos=m_List4.GetFirstSelectedItemPosition();
  588. while (pos)
  589. {
  590. iItem=m_List4.GetNextSelectedItem(pos);
  591. sel+=m_List4.GetItemText (iItem, 0);
  592. sel+=",";
  593. }
  594. sel.TrimRight (",");
  595. }//
  596. // m_designno="$10x18寸晶透水晶\\005:001,002,003$10x28寸晶透水晶\\005:001,002,003$10x18寸晶透水晶\\005:001,002,003";
  597. //$xxxx:001,002,003,004$
  598. int pos=m_designno.Find (title);
  599. if(pos!=-1)
  600. {
  601. temp=m_designno.Right (m_designno.GetLength ()-pos-title.GetLength ());
  602. int pos2=temp.Find ("$");
  603. if(pos2!=-1)
  604. temp=temp.Right (temp.GetLength ()-pos2);
  605. else
  606. temp.Empty ();
  607. m_designno=m_designno.Left (pos+title.GetLength ());
  608. m_designno+=sel;
  609. m_designno+=temp;
  610. }
  611. else
  612. {
  613. m_designno+=title;
  614. m_designno+=sel;
  615. }
  616. *pResult = 0;
  617. }
  618. void SetDesignNo::OnOK()
  619. {
  620. // TODO: Add extra validation here
  621. CString sql="update dindan set designno='"+m_designno+"' where id='"+m_id+"'";
  622. g_sendhead.bsql=1;
  623. g_pMainWnd->ProcessChatMessageRequest2(sql);
  624. if(g_bSendOK==0)return;
  625. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  626. }
  627. void SetDesignNo::OnPaint()
  628. {
  629. CPaintDC dc(this); // device context for painting
  630. // TODO: Add your message handler code here
  631. if(m_image)
  632. {
  633. CRect rc;
  634. GetDlgItem(IDC_STATIC3)->GetWindowRect(rc);
  635. ScreenToClient(rc);
  636. RectFitDes(m_image->GetWidth(), m_image->GetHeight(), rc);
  637. Graphics dcgraph(dc.GetSafeHdc());
  638. Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ());
  639. dcgraph.DrawImage(m_image, destinationRect, 0,0,m_image->GetWidth(), m_image->GetHeight(),UnitPixel);
  640. }
  641. // Do not call CDialog::OnPaint() for painting messages
  642. }