ChoosePhotoSkin.cpp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. // ChoosePhotoSkin.cpp: implementation of the ChoosePhotoSkin class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "LYFZIPManage.h"
  6. #include "ChoosePhotoSkin.h"
  7. #include "SearchClient.h"
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char THIS_FILE[]=__FILE__;
  11. #define new DEBUG_NEW
  12. #endif
  13. extern void WriteTitle(CString str);
  14. //////////////////////////////////////////////////////////////////////
  15. // Construction/Destruction
  16. //////////////////////////////////////////////////////////////////////
  17. ChoosePhotoSkin::ChoosePhotoSkin()
  18. {
  19. m_mode=0;
  20. m_exitcode=0;
  21. m_bsave=0;
  22. g_pMainWnd->GetSkin();
  23. }
  24. ChoosePhotoSkin::~ChoosePhotoSkin()
  25. {
  26. }
  27. void ChoosePhotoSkin::OnFSCommand(LPCTSTR command, LPCTSTR args)
  28. {
  29. }
  30. void ChoosePhotoSkin::Init()
  31. {
  32. #ifdef MNLS_VERSION
  33. if(m_mode==0)
  34. ((MyBmpButton2*)m_picarray.ElementAt (5))->ShowWindow (SW_HIDE);
  35. else
  36. ((MyBmpButton2*)m_picarray.ElementAt (5))->EnableWindow (0);
  37. #else
  38. Graphics graph(m_pBk);
  39. Image *img=NULL;
  40. if(m_mode==0)
  41. ::LoadImageFromBuf (&img, g_mainpath+"\\skin\\标题-选片.jpg");
  42. else
  43. ::LoadImageFromBuf (&img, g_mainpath+"\\skin\\标题-看设计.jpg");
  44. graph.DrawImage(img, 0,0);
  45. delete img;
  46. ((MyBmpButton2*)m_picarray.ElementAt (5))->ShowWindow (SW_HIDE);
  47. #endif
  48. m_combobox.Create(WS_VSCROLL|WS_CHILD|CBS_DROPDOWN,m_rcarray.ElementAt (2),this,100);
  49. m_combobox.ShowWindow(SW_SHOW);
  50. CRect rc=m_rcarray.ElementAt (2);
  51. rc.bottom +=200;
  52. m_combobox.MoveWindow (rc);
  53. m_combobox.GetWindowRect (rc);
  54. int hei=rc.Height ();
  55. rc=m_rcarray.ElementAt (3);
  56. rc.bottom =rc.top +hei+5;
  57. m_edit.Create(ES_AUTOHSCROLL|WS_CHILD|ES_LEFT|WS_BORDER|ES_PASSWORD|WS_EX_WINDOWEDGE,rc,this,200);
  58. m_edit.ShowWindow(SW_SHOW);
  59. rc=m_rcarray.ElementAt (4);
  60. rc.bottom =rc.top +13;
  61. rc.right =rc.left +13;
  62. m_button.Create("",WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX|BS_FLAT, rc,this,300);
  63. tpFont.CreatePointFont (180, _T("黑体"));
  64. m_edit.SetFont(&tpFont);
  65. m_combobox.SetFont(&tpFont);
  66. /////////////////////////
  67. g_sendhead.bsql=0;
  68. g_sendhead.code[0]=23;
  69. g_sendhead.code[1]=24;
  70. g_sendhead.code[2]=29;
  71. g_sendhead.code[3]=5;
  72. g_sendhead.code[4]=1;
  73. g_sendhead.tabcount=5;
  74. int g_nYearposTemp=g_nYearpos;
  75. g_nYearpos=-1;
  76. g_pMainWnd->ProcessChatMessageRequest2(1);
  77. g_nYearpos=g_nYearposTemp;
  78. if(g_bSendOK==0)
  79. {
  80. CDialog::OnCancel();
  81. return;
  82. }
  83. CArray<CStringArray, CStringArray>patharray;
  84. DataToArray(&m_List1array,&g_cominfoarray,&patharray,&g_userarray,&g_hisyeararray);
  85. //#ifdef MNLS_VERSION
  86. if(g_cominfoarray.ElementAt(0).ElementAt(0)!="102")
  87. {
  88. AfxMessageBox("您必须更新软件才能继续使用, 请与系统管理员联系!", MB_ICONINFORMATION);
  89. CDialog::OnCancel();
  90. g_pMainWnd->AutoUpdate();
  91. return;
  92. }
  93. //#endif
  94. g_title=g_cominfoarray.ElementAt (0).ElementAt (10);
  95. WriteTitle(g_cominfoarray.ElementAt (0).ElementAt (10));
  96. g_date=g_cominfoarray.ElementAt(0).ElementAt(1);
  97. if(g_hisyeararray.GetSize())
  98. {
  99. g_pMainWnd->AddHistoryMenu(&g_hisyeararray);
  100. }
  101. if(g_server=="127.0.0.1")
  102. {
  103. g_sendhead.bsql=0;
  104. g_sendhead.code[0]=63;
  105. g_sendhead.tabcount=1;
  106. g_pMainWnd->ProcessChatMessageRequest2(1);
  107. if(g_bSendOK==0)
  108. {
  109. CDialog::OnCancel();
  110. return;
  111. }
  112. DataToArray(&g_List1array);
  113. g_path1=g_List1array.ElementAt(0).ElementAt(0)+"\\客户原片(管理软件)$";
  114. g_path2=g_List1array.ElementAt(0).ElementAt(0)+"\\修好的片(管理软件)$";
  115. g_path3=g_List1array.ElementAt(0).ElementAt(0)+"\\设计好的片(管理软件)$";
  116. g_path4=g_List1array.ElementAt(0).ElementAt(0)+"\\精修好的片(管理软件)$";
  117. }
  118. else if(patharray.GetSize())
  119. {
  120. g_path1=patharray.ElementAt(0).ElementAt(0);
  121. g_path2=patharray.ElementAt(0).ElementAt(1);
  122. g_path3=patharray.ElementAt(0).ElementAt(2);
  123. g_path4=patharray.ElementAt(0).ElementAt(3);
  124. g_path1="\\\\"+g_path1+"\\客户原片(管理软件)$";
  125. g_path2="\\\\"+g_path2+"\\修好的片(管理软件)$";
  126. g_path3="\\\\"+g_path3+"\\设计好的片(管理软件)$";
  127. g_path4="\\\\"+g_path4+"\\精修好的片(管理软件)$";
  128. }
  129. try
  130. {
  131. CFile fp;
  132. if(fp.Open (g_mainpath+"\\loginuser.dat", CFile::modeRead))
  133. {
  134. DWORD length=fp.GetLength ();
  135. if(!length)return;
  136. CArchive ar(&fp, CArchive::load);
  137. m_userarray.Serialize (ar);
  138. fp.Close ();
  139. for(int i=0; i<m_userarray.GetSize (); i++)
  140. {
  141. m_combobox.AddString (m_userarray.ElementAt (i));
  142. }
  143. if(m_combobox.GetCount ()>0)
  144. {
  145. m_combobox.SetCurSel (0);
  146. m_combobox.GetLBText (0, m_account);
  147. }
  148. if(!m_account.IsEmpty ())
  149. {
  150. CString version = _T ("Version 1.0");
  151. m_psw=AfxGetApp()->GetProfileString (version, _T (m_account));
  152. if(!m_psw.IsEmpty ())
  153. m_bsave=TRUE;
  154. }
  155. // SetDlgItemText(100, m_account);
  156. SetDlgItemText(200, m_psw);
  157. m_button.SetCheck (m_bsave);
  158. }
  159. }
  160. catch(...)
  161. {
  162. }
  163. }
  164. void ChoosePhotoSkin::Destory()
  165. {
  166. }
  167. void ChoosePhotoSkin::BtnClick(WPARAM wParam, LPARAM lParam)
  168. {
  169. int id=lParam;
  170. id-=99;
  171. switch(id)
  172. {
  173. case 1:
  174. {
  175. m_combobox.GetWindowText (m_account);
  176. // GetDlgItemText(100, m_account);
  177. GetDlgItemText(200, m_psw);
  178. m_bsave= m_button.GetCheck ();
  179. if(m_account.IsEmpty())
  180. {
  181. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  182. return;
  183. }
  184. for(int i=0; i<m_List1array.GetSize(); i++)
  185. {
  186. if(m_account==m_List1array.ElementAt(i).ElementAt(0))
  187. {
  188. if(m_psw!=m_List1array.ElementAt(i).ElementAt(2))
  189. {
  190. AfxMessageBox("密码错误, 请重新输入!", MB_ICONINFORMATION);return;
  191. }
  192. else
  193. {
  194. g_user.bLongin=1;
  195. g_user.name=m_List1array.ElementAt(i).ElementAt(1);
  196. g_user.rights=m_List1array.ElementAt(i).ElementAt(3);
  197. SaveLongin();
  198. CString str;
  199. str="当前用户:"+g_user.name;
  200. SearchClient dlg;
  201. dlg.m_mode=m_mode;
  202. dlg.SetLiaPath ("2.lia");
  203. if(dlg.DoModal ()!=IDOK)
  204. return;
  205. m_exitcode=dlg.m_exitcode;
  206. CDialog::OnOK ();
  207. return;
  208. }
  209. }
  210. }
  211. AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION);
  212. }
  213. break;
  214. case 2:
  215. CDialog::OnCancel ();
  216. break;
  217. }
  218. }
  219. BOOL ChoosePhotoSkin::PreTransMsg(MSG* pMsg)
  220. {
  221. if(pMsg->message==WM_KEYDOWN)
  222. {
  223. switch (pMsg->wParam)
  224. {
  225. case VK_F2:
  226. if(m_mode)
  227. m_exitcode=2;
  228. CDialog::OnOK ();
  229. return 1;
  230. case VK_F3:
  231. if(m_mode==0)
  232. m_exitcode=3;
  233. CDialog::OnOK ();
  234. return 1;
  235. case VK_RETURN:
  236. BtnClick(0, 100);
  237. return 1;
  238. }
  239. }
  240. else if(pMsg->message==WM_LBUTTONDOWN)
  241. {
  242. g_bNeedDrawParent=1;
  243. CPoint pt;
  244. ::GetCursorPos (&pt);
  245. ScreenToClient(&pt);
  246. CRect rc;
  247. m_button.GetWindowRect (rc);
  248. ScreenToClient(rc);
  249. if(rc.PtInRect (pt))return CDialog::PreTranslateMessage(pMsg);
  250. if(m_rcarray.ElementAt (4).PtInRect (pt))
  251. {
  252. m_button.SetCheck (!m_button.GetCheck ());
  253. }
  254. }
  255. return CDialog::PreTranslateMessage(pMsg);
  256. }
  257. void ChoosePhotoSkin::SaveLongin()
  258. {
  259. CString version = _T ("Version 1.0");
  260. if(m_bsave)
  261. {
  262. AfxGetApp()->WriteProfileString (version, _T (m_account), m_psw);
  263. }
  264. else
  265. {
  266. AfxGetApp()->WriteProfileString (version, _T (m_account), "");
  267. }
  268. if(m_userarray.GetSize ())
  269. {
  270. if(m_userarray.ElementAt (0)!=m_account)
  271. {
  272. RemoveExist(m_account);
  273. m_userarray.InsertAt (0,m_account);
  274. if(m_userarray.GetSize ()>30)
  275. m_userarray.SetSize (30);
  276. }
  277. }
  278. else
  279. {
  280. m_userarray.Add (m_account);
  281. }
  282. CFile f;
  283. if(!f.Open (g_mainpath+"\\loginuser.dat", CFile::modeWrite|CFile::modeCreate))return ;
  284. CArchive ar(&f, CArchive::store);
  285. m_userarray.Serialize (ar);
  286. ar.Close();
  287. f.Close ();
  288. }
  289. void ChoosePhotoSkin::RemoveExist(CString str)
  290. {
  291. for(int i=0; i<m_userarray.GetSize(); i++)
  292. {
  293. if(str==m_userarray.ElementAt(i))
  294. {
  295. m_userarray.RemoveAt(i);
  296. return;
  297. }
  298. }
  299. }