SetDesignNo.cpp 18 KB

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