outsourcingDlg.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. // outsourcingDlg.cpp : impleme ntation file
  2. //
  3. #include "stdafx.h"
  4. #include "uphonebox.h"
  5. #include "outsourcingDlg.h"
  6. #include <afxtempl.h>
  7. #include "UPhoneBoxDlg.h"
  8. #include "ShowHeader.h"
  9. #include "./helper/ffsco.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. extern CArray<int, int>yearposarray[10];
  16. extern CStringArray idarray[10];
  17. #pragma comment(lib, "Shlwapi.lib")
  18. /////////////////////////////////////////////////////////////////////////////
  19. // outsourcingDlg dialog IDC_EDITstatus1
  20. outsourcingDlg::outsourcingDlg(CWnd* pParent /*=NULL*/)
  21. : CDialog(outsourcingDlg::IDD, pParent)
  22. {
  23. //{{AFX_DATA_INIT(outsourcingDlg)
  24. m_name1 = _T("");
  25. m_name2 = _T("");
  26. m_id = _T("");
  27. m_money1 = _T("");
  28. m_money2 = _T("");
  29. m_money3 = _T("");
  30. m_tx = _T("");
  31. m_status1 = _T("");
  32. m_status2 = _T("");
  33. m_status3 = _T("");
  34. m_status4 = _T("");
  35. m_status5 = _T("");
  36. m_status6 = _T("");
  37. m_status7 = _T("");
  38. m_waiter = _T("");
  39. m_date1 = _T("");
  40. m_date2 = _T("");
  41. m_date3 = _T("");
  42. m_date4 = _T("");
  43. m_date5 = _T("");
  44. //}}AFX_DATA_INIT
  45. m_pos = 0;
  46. m_linepos = 0;
  47. m_pImg = NULL;
  48. m_headerpos = 0;
  49. m_headerhwnd = NULL;
  50. }
  51. void outsourcingDlg::DoDataExchange(CDataExchange* pDX)
  52. {
  53. CDialog::DoDataExchange(pDX);
  54. //{{AFX_DATA_MAP(outsourcingDlg)
  55. DDX_Control(pDX, IDC_LIST1, m_List1);
  56. DDX_Text(pDX, IDC_EDITname1, m_name1);
  57. DDX_Text(pDX, IDC_EDITname2, m_name2);
  58. DDX_Text(pDX, IDC_EDITid2, m_id);
  59. DDX_Text(pDX, IDC_EDITmoney1, m_money1);
  60. DDX_Text(pDX, IDC_EDITmoney2, m_money2);
  61. DDX_Text(pDX, IDC_EDITmoney3, m_money3);
  62. DDX_Text(pDX, IDC_EDITid3, m_tx);
  63. DDX_Text(pDX, IDC_EDITstatus1, m_status1);
  64. DDX_Text(pDX, IDC_EDITstatus2, m_status2);
  65. DDX_Text(pDX, IDC_EDITstatus3, m_status3);
  66. DDX_Text(pDX, IDC_EDITstatus4, m_status4);
  67. DDX_Text(pDX, IDC_EDITstatus5, m_status5);
  68. DDX_Text(pDX, IDC_EDITstatus6, m_status6);
  69. DDX_Text(pDX, IDC_EDITstatus7, m_status7);
  70. DDX_Text(pDX, IDC_EDITwaiter, m_waiter);
  71. DDX_Text(pDX, IDC_EDITdate1, m_date1);
  72. DDX_Text(pDX, IDC_EDITdate2, m_date2);
  73. DDX_Text(pDX, IDC_EDITdate3, m_date3);
  74. DDX_Text(pDX, IDC_EDITdate4, m_date4);
  75. DDX_Text(pDX, IDC_EDITdate5, m_date5);
  76. //}}AFX_DATA_MAP
  77. }
  78. BEGIN_MESSAGE_MAP(outsourcingDlg, CDialog)
  79. //{{AFX_MSG_MAP(outsourcingDlg)
  80. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  81. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  82. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  83. ON_BN_CLICKED(IDC_STATIC2, OnStatic2)
  84. ON_WM_PAINT()
  85. ON_WM_DESTROY()
  86. ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
  87. ON_WM_TIMER()
  88. ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
  89. ON_MESSAGE(WM_USER + 111, OnCloseWin)
  90. //}}AFX_MSG_MAP
  91. ON_WM_CLOSE()
  92. END_MESSAGE_MAP()
  93. //
  94. /////////////////////////////////////////////////////////////////////////////
  95. // outsourcingDlg message handlers
  96. BOOL outsourcingDlg::OnInitDialog()
  97. {
  98. CDialog::OnInitDialog();
  99. SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
  100. g_hwnd[m_linepos] = this->m_hWnd;
  101. // TODO: Add extra initialization here
  102. if (idarray[m_linepos].GetSize() > 1)
  103. {
  104. GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_SHOW);
  105. GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW);
  106. GetDlgItem(IDC_STATIC1)->ShowWindow(SW_SHOW);
  107. }
  108. if (idarray[m_linepos].GetSize() > 1)
  109. {
  110. GetDlgItem(IDC_BUTTON1)->EnableWindow(1);
  111. GetDlgItem(IDC_BUTTON2)->EnableWindow(1);
  112. }
  113. CString str;
  114. str.Format("找到%d个客户", idarray[m_linepos].GetSize());
  115. SetDlgItemText(IDC_STATIC1, str);
  116. m_List1.InitStyle();
  117. m_List1.InsertColumn(0, _T("商品名称"), LVCFMT_LEFT, 120);
  118. m_List1.InsertColumn(1, _T("数量"), LVCFMT_LEFT, 50);
  119. m_List1.InsertColumn(2, _T("加急"), LVCFMT_LEFT, 50);
  120. m_List1.InsertColumn(3, _T("取件日期"), LVCFMT_LEFT, 80);
  121. m_List1.InsertColumn(4, _T("发出"), LVCFMT_LEFT, 80);
  122. m_List1.InsertColumn(5, _T("发出日期"), LVCFMT_LEFT, 120);
  123. m_List1.InsertColumn(6, _T("返工"), LVCFMT_LEFT, 50);
  124. m_List1.InsertColumn(7, _T("返工日期"), LVCFMT_LEFT, 120);
  125. m_List1.InsertColumn(8, _T("完成"), LVCFMT_LEFT, 60);
  126. m_List1.InsertColumn(9, _T("完成日期"), LVCFMT_LEFT, 120);
  127. m_List1.InsertColumn(10, _T("取走"), LVCFMT_LEFT, 50);
  128. m_List1.InsertColumn(11, _T("取走日期"), LVCFMT_LEFT, 120);
  129. ShowClient();
  130. return TRUE; // return TRUE unless you set the focus to a control
  131. // EXCEPTION: OCX Property Pages should return FALSE
  132. }
  133. CString outsourcingDlg::GetLB(CString name)
  134. {
  135. return "";
  136. }
  137. void ConvertToPrice(CString &str)
  138. {
  139. if (str.Find('.') == -1)return;
  140. str.TrimRight('0');
  141. str.TrimRight('.');
  142. }
  143. void LoadImageFromBuf(Image **img, BYTE *pData, DWORD leng)
  144. {
  145. try
  146. {
  147. if (pData == NULL)return;
  148. if (*img)delete *img;
  149. *img = NULL;
  150. // Allocate global memory on which to create stream
  151. HGLOBAL m_hMem = GlobalAlloc(GMEM_MOVEABLE, leng);
  152. if (m_hMem == NULL)return;
  153. BYTE* pmem = (BYTE*)GlobalLock(m_hMem);
  154. memcpy(pmem, pData, leng);
  155. IStream* pstm;
  156. CreateStreamOnHGlobal(m_hMem, TRUE, &pstm);
  157. // load from stream
  158. *img = Gdiplus::Image::FromStream(pstm);
  159. // free/release stuff
  160. GlobalUnlock(m_hMem);
  161. pstm->Release();
  162. }
  163. catch (...)
  164. {
  165. }
  166. }
  167. void LoadImageFromBuf(Image **img, CString path)
  168. {
  169. try
  170. {
  171. CFile fp;
  172. if (fp.Open(path, CFile::modeRead))
  173. {
  174. DWORD leng = fp.GetLength();
  175. BYTE *pData = new BYTE[leng];
  176. fp.Read(pData, leng);
  177. fp.Close();
  178. LoadImageFromBuf(img, pData, leng);
  179. delete[]pData;
  180. }
  181. }
  182. catch (...)
  183. {
  184. }
  185. }
  186. extern CString g_headerpath;
  187. extern int g_nYearpos;
  188. extern BOOL g_bReturned2;
  189. extern CUPhoneBoxDlg *g_pMainWnd;
  190. extern void DataToArray(CArray<CStringArray, CStringArray>*List1array, CArray<CStringArray, CStringArray>*List2array, CArray<CStringArray, CStringArray>*List3array);
  191. void outsourcingDlg::ShowClient()
  192. {
  193. m_id = idarray[m_linepos].ElementAt(m_pos);
  194. CString filter = "id='" + m_id + "' and kind<>'5' and name<>'入册';id='" + m_id + "';id='" + m_id + "'";
  195. g_nYearpos = yearposarray[m_linepos].ElementAt(m_pos);
  196. /* g_sendhead.code[0]=56;
  197. g_sendhead.code[1]=11;
  198. g_sendhead.code[2]=181;
  199. g_sendhead.tabcount=3;
  200. g_sendhead.bsql=0;
  201. g_pMainWnd->ProcessChatMessageRequest2(filter);
  202. for(int i=0; i<20; i++)
  203. {
  204. if(g_bReturned2)break;
  205. ::Sleep (500);
  206. }
  207. if(i>=20)
  208. {
  209. nNeedConn2=1;
  210. return;
  211. }*/
  212. CArray<CStringArray, CStringArray>List1array;
  213. CArray<CStringArray, CStringArray>List2array;
  214. CArray<CStringArray, CStringArray>m_sparray;
  215. // DataToArray(&m_sparray,&List1array,&List2array);
  216. GetListData(56, &m_sparray, m_id, g_nYearpos + 1, 0);
  217. GetListData(11, &List1array, m_id, g_nYearpos + 1, 1);
  218. GetListData(181, &List2array, m_id, g_nYearpos + 1, 0);
  219. m_List1.DeleteAllItems();
  220. int listpos[3] = { 0 };
  221. CComboBoxListCtrl *pList[1] = { &m_List1 };
  222. int pos = 0;
  223. int i;
  224. for ( i = 0; i < m_sparray.GetSize(); i++)
  225. {
  226. pList[pos]->InsertItem(listpos[pos], m_sparray.ElementAt(i).ElementAt(0));
  227. pList[pos]->SetItemText(listpos[pos], 1, m_sparray.ElementAt(i).ElementAt(1));
  228. pList[pos]->SetItemText(listpos[pos], 2, m_sparray.ElementAt(i).ElementAt(18));
  229. pList[pos]->SetItemText(listpos[pos], 3, m_sparray.ElementAt(i).ElementAt(19));
  230. pList[pos]->SetItemText(listpos[pos], 4, m_sparray.ElementAt(i).ElementAt(2));
  231. pList[pos]->SetItemText(listpos[pos], 5, m_sparray.ElementAt(i).ElementAt(9) + "/" + m_sparray.ElementAt(i).ElementAt(10));
  232. pList[pos]->SetItemText(listpos[pos], 6, m_sparray.ElementAt(i).ElementAt(3));
  233. pList[pos]->SetItemText(listpos[pos], 7, m_sparray.ElementAt(i).ElementAt(11) + "/" + m_sparray.ElementAt(i).ElementAt(12));
  234. pList[pos]->SetItemText(listpos[pos], 8, m_sparray.ElementAt(i).ElementAt(4));
  235. pList[pos]->SetItemText(listpos[pos], 9, m_sparray.ElementAt(i).ElementAt(13) + "/" + m_sparray.ElementAt(i).ElementAt(14));
  236. pList[pos]->SetItemText(listpos[pos], 10, m_sparray.ElementAt(i).ElementAt(5));
  237. pList[pos]->SetItemText(listpos[pos], 11, m_sparray.ElementAt(i).ElementAt(15) + "/" + m_sparray.ElementAt(i).ElementAt(16));
  238. listpos[pos]++;
  239. }
  240. if (List1array.GetSize())
  241. {
  242. CString m_taoxijiage = List1array.ElementAt(0).ElementAt(8);
  243. CString m_payed4 = List1array.ElementAt(0).ElementAt(19);
  244. CString m_payed5 = List1array.ElementAt(0).ElementAt(20);
  245. m_money1 = List1array.ElementAt(0).ElementAt(1);
  246. m_money2.Format("%f", atof(m_payed5) + atof(m_money1));
  247. m_money1.Format("%f", atof(m_taoxijiage) + atof(m_payed4));
  248. m_money3.Format("%f", atof(m_money1) - atof(m_money2));
  249. ConvertToPrice(m_money1);
  250. ConvertToPrice(m_money2);
  251. ConvertToPrice(m_money3);
  252. m_name1 = List1array.ElementAt(0).ElementAt(4);
  253. m_name2 = List1array.ElementAt(0).ElementAt(5);
  254. m_tx = List1array.ElementAt(0).ElementAt(7);
  255. m_waiter = List1array.ElementAt(0).ElementAt(14);
  256. m_status1 = List2array.ElementAt(0).ElementAt(5 + 3);
  257. m_status2 = List2array.ElementAt(0).ElementAt(6 + 3);
  258. m_status3 = List2array.ElementAt(0).ElementAt(7 + 3);
  259. m_status4 = List2array.ElementAt(0).ElementAt(8 + 3);
  260. m_status5 = List2array.ElementAt(0).ElementAt(9 + 3);
  261. m_status6 = List2array.ElementAt(0).ElementAt(10 + 3);
  262. m_status7 = List2array.ElementAt(0).ElementAt(11 + 3);
  263. m_date1 = List2array.ElementAt(0).ElementAt(12 + 3);
  264. m_date2 = List2array.ElementAt(0).ElementAt(13 + 3);
  265. m_date3 = List2array.ElementAt(0).ElementAt(14 + 3);
  266. m_date4 = List2array.ElementAt(0).ElementAt(15 + 3);
  267. m_date5 = List2array.ElementAt(0).ElementAt(16 + 3);
  268. UpdateData(false);
  269. }
  270. ::SetForegroundWindow(m_hWnd);
  271. CString path = g_headerpath + m_id + "\\";
  272. CString str;
  273. m_headerarray.RemoveAll();
  274. for (i = 0; i < 100; i++)
  275. {
  276. str.Format("%s%03d.jpg", path, i);
  277. if (::PathFileExists(str))
  278. {
  279. m_headerarray.Add(str);
  280. }
  281. }
  282. if (m_headerarray.GetSize() == 0)
  283. {
  284. str = "客人头像\\";
  285. CString defaultpath = g_headerpath.Left(g_headerpath.GetLength() - str.GetLength());
  286. defaultpath += m_id + "\\";
  287. using namespace helper_coffs;
  288. ffsco o;
  289. o.dirs(1);
  290. o.find(LPCSTR(defaultpath), LPCSTR("*.jpg"));
  291. ffsco::typeT coo;
  292. ffsco::typeT::iterator it;
  293. coo = o.co_file();
  294. for (it = coo.begin();coo.end() != it;it++)
  295. {
  296. str = (*it).c_str();
  297. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  298. m_headerarray.Add(str);
  299. if (m_headerarray.GetSize() > 10)break;
  300. }
  301. }
  302. if (m_headerarray.GetSize() <= 1)
  303. {
  304. GetDlgItem(IDC_BUTTON4)->EnableWindow(0);
  305. GetDlgItem(IDC_BUTTON5)->EnableWindow(0);
  306. }
  307. if (m_headerarray.GetSize())
  308. {
  309. m_headerpos = -1;
  310. OnButton5();
  311. }
  312. }
  313. void outsourcingDlg::OnButton1()
  314. {
  315. // TODO: Add your control notification handler code here
  316. m_pos--;
  317. if (m_pos < 0)
  318. m_pos = idarray[m_linepos].GetSize() - 1;
  319. ShowClient();
  320. }
  321. void outsourcingDlg::OnButton2()
  322. {
  323. // TODO: Add your control notification handler code here
  324. m_pos++;
  325. if (m_pos >= idarray[m_linepos].GetSize())
  326. m_pos = 0;
  327. ShowClient();
  328. }
  329. CString g_id;
  330. CString g_name1;
  331. CString g_name2;
  332. void outsourcingDlg::OnButton3()
  333. {
  334. // TODO: Add your control notification handler code here
  335. g_id = m_id;
  336. g_name1 = m_name1;
  337. g_name2 = m_name2;
  338. // g_pMainWnd->ClientBooking(m_id, m_name1, m_name2);
  339. g_pMainWnd->SetTimer(4, 200, NULL);
  340. }
  341. BOOL outsourcingDlg::PreTranslateMessage(MSG* pMsg)
  342. {
  343. // TODO: Add your specialized code here and/or call the base class
  344. if (pMsg->message == WM_LBUTTONDBLCLK)
  345. {
  346. return 1;
  347. }
  348. return CDialog::PreTranslateMessage(pMsg);
  349. }
  350. LRESULT outsourcingDlg::OnCloseWin(WPARAM wParam, LPARAM lParam)
  351. {
  352. // TODO: Add your message handler code here and/or call default
  353. #if _DEBUG
  354. TRACE("订单顾客来电对话框关闭\n");
  355. #endif
  356. if (m_headerhwnd)
  357. {
  358. ::SendMessage(m_headerhwnd, WM_CLOSE, 0, 0);
  359. m_headerhwnd = NULL;
  360. }
  361. if (wParam)
  362. {
  363. if (::PathFileExists(g_recordpath[m_linepos]))
  364. {
  365. CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  366. CString sql;
  367. sql.Format("insert into [phonerecord]([id],[datetime],[phoneno])values(\
  368. '%s','%s','%s')", m_id, datetime, m_phone);
  369. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89)))
  370. {
  371. CString content = g_cominfoarray.ElementAt(0).ElementAt(92);
  372. if (content != "" && CheckExist(m_phone) == 0)
  373. {
  374. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  375. int count = GetLengthEx(content) / 70;
  376. if (GetLengthEx(content) % 70)
  377. count++;
  378. CString scount;
  379. scount.Format("%d", count);
  380. CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
  381. ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  382. sql += sql2;
  383. }
  384. }
  385. g_sendhead.bsql = 1;
  386. g_nYearpos = -1;
  387. g_pMainWnd->ProcessChatMessageRequest2(sql);
  388. int i;
  389. for ( i = 0; i < 20; i++)
  390. {
  391. if (g_bReturned2)break;
  392. ::Sleep(500);
  393. }
  394. if (i >= 20)
  395. {
  396. nNeedConn2 = 1;
  397. CDialog::OnCancel();
  398. return 1;
  399. }
  400. datetime.Replace(":", "");
  401. ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\客户电话", NULL);
  402. ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\客户电话\\" + m_id, NULL);
  403. CString m_savepath = "\\\\" + g_server2 + "\\电话录音(管理软件)$\\客户电话\\" + m_id + "\\" + datetime + ".mp3";
  404. if (::PathFileExists(g_recordpath[m_linepos]))
  405. {
  406. ::CopyFile(g_recordpath[m_linepos], m_savepath, 0);
  407. }
  408. }
  409. }
  410. else
  411. {
  412. CString name;
  413. if (!m_name1.IsEmpty())
  414. name = m_name1 + ",";
  415. name += m_name2;
  416. name.TrimRight(",");
  417. CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  418. CString sql, sql2;
  419. sql.Format("insert into [misscallrecord]([phone],[datetime],[name],[type])values(\
  420. '%s','%s','%s','%s')", m_phone, datetime, name, "订单客户来电");
  421. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89)))
  422. {
  423. CString content = g_cominfoarray.ElementAt(0).ElementAt(92);
  424. if (content != "" && CheckExist(m_phone) == 0)
  425. {
  426. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  427. int count = GetLengthEx(content) / 70;
  428. if (GetLengthEx(content) % 70)
  429. count++;
  430. CString scount;
  431. scount.Format("%d", count);
  432. CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
  433. ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  434. sql += sql2;
  435. }
  436. }
  437. g_sendhead.bsql = 1;
  438. g_nYearpos = -1;
  439. g_pMainWnd->ProcessChatMessageRequest2(sql);
  440. int i;
  441. for ( i = 0; i < 20; i++)
  442. {
  443. if (g_bReturned2)break;
  444. ::Sleep(500);
  445. }
  446. if (i >= 20)
  447. {
  448. nNeedConn2 = 1;
  449. CDialog::OnCancel();
  450. return 1;
  451. }
  452. }
  453. ::DeleteFile(g_recordpath[m_linepos]);
  454. DestroyWindow();
  455. // CDialog::OnCancel ();
  456. }
  457. void outsourcingDlg::OnOK()
  458. {
  459. // TODO: Add extra validation here
  460. }
  461. void outsourcingDlg::OnCancel()
  462. {
  463. // TODO: Add extra cleanup here
  464. }
  465. void RectFitDes(int width, int height, CRect &rc)
  466. {
  467. try
  468. {
  469. if (width == 0 || height == 0)return;
  470. float fscale = (float)width / (float)height;
  471. float rcscale = ((float)rc.Width()) / ((float)rc.Height());
  472. int rcwid = rc.Width();
  473. int rchei = rc.Height();
  474. int dt = 0;
  475. if (rcscale < fscale)
  476. {
  477. dt = (rchei - rcwid / fscale) / 2;
  478. rc.top += dt;
  479. rc.bottom -= dt;
  480. }
  481. else
  482. {
  483. dt = (rcwid - rchei*fscale) / 2;
  484. rc.left += dt;
  485. rc.right -= dt;
  486. }
  487. }
  488. catch (...)
  489. {
  490. }
  491. }
  492. void outsourcingDlg::OnPaint()
  493. {
  494. CPaintDC dc(this); // device context for painting
  495. // TODO: Add your message handler code here
  496. if (m_pImg)
  497. {
  498. CRect rc;
  499. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  500. ScreenToClient(rc);
  501. RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc);
  502. Graphics dcgraph(dc.GetSafeHdc());
  503. Rect destinationRect(rc.left, rc.top, rc.Width(), rc.Height());
  504. dcgraph.DrawImage(m_pImg, destinationRect, 0, 0, m_pImg->GetWidth(), m_pImg->GetHeight(), UnitPixel);
  505. }
  506. // Do not call CDialog::OnPaint() for painting messages
  507. }
  508. void outsourcingDlg::OnStatic2()
  509. {
  510. // TODO: Add your control notification handler code here
  511. if (m_pImg)
  512. {
  513. ShowHeader dlg;
  514. dlg.m_pheaderhwnd = &m_headerhwnd;
  515. dlg.m_pImg = m_pImg;
  516. dlg.DoModal();
  517. }
  518. }
  519. void outsourcingDlg::OnDestroy()
  520. {
  521. CDialog::OnDestroy();
  522. // TODO: Add your message handler code here
  523. if (m_pImg)delete m_pImg; m_pImg = NULL;
  524. }
  525. void outsourcingDlg::OnButton4()
  526. {
  527. // TODO: Add your control notification handler code here
  528. m_headerpos--;
  529. if (m_headerpos == -1)
  530. m_headerpos = m_headerarray.GetSize() - 1;
  531. CString path = m_headerarray.ElementAt(m_headerpos);
  532. if (m_pImg)delete m_pImg; m_pImg = NULL;
  533. ::LoadImageFromBuf(&m_pImg, path);
  534. CRect rc;
  535. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  536. ScreenToClient(rc);
  537. InvalidateRect(rc);
  538. }
  539. void outsourcingDlg::OnButton5()
  540. {
  541. // TODO: Add your control notification handler code here
  542. m_headerpos++;
  543. if (m_headerarray.GetSize() <= m_headerpos)
  544. m_headerpos = 0;
  545. CString path = m_headerarray.ElementAt(m_headerpos);
  546. if (m_pImg)delete m_pImg; m_pImg = NULL;
  547. ::LoadImageFromBuf(&m_pImg, path);
  548. CRect rc;
  549. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  550. ScreenToClient(rc);
  551. InvalidateRect(rc);
  552. }
  553. void outsourcingDlg::OnClose()
  554. {
  555. // TODO: 在此添加消息处理程序代码和/或调用默认值
  556. CDialog::OnClose();
  557. }