YLGL.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. // YLGL.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "YLGL.h"
  5. #include "ChildFrm.h"
  6. #include "YLGLDoc.h"
  7. #include "YLGLView.h"
  8. #include "ChoosePhotoSkin.h"
  9. #include "DBConfig.h"
  10. #include "Lzari.h"
  11. #include "library.h"
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. MainFrimDlg2 *g_pMainWnd2 = NULL;
  18. FILE *g_pf; // add by Jeff 2014.05.24
  19. #define _USE_CONSOLE_FOR_DEBUG 0 // add by Jeff 2014.05.24
  20. BEGIN_MESSAGE_MAP(CYLGLApp, CWinApp)
  21. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  22. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  23. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  24. END_MESSAGE_MAP()
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CYLGLApp construction
  27. // Jeff remark;
  28. DEVMODE g_dm; // 打印或显示设备的预设值和环境值;
  29. CYLGLApp::CYLGLApp()
  30. {
  31. // Place all significant initialization in InitInstance g_gridcol1
  32. g_dm.dmSize = sizeof(DEVMODE);
  33. EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &g_dm); // 返回显示设备的当前设置的绘图模式;
  34. CRect rc;
  35. HWND wnd = GetDesktopWindow();
  36. if (wnd)
  37. {
  38. ::GetWindowRect(wnd, &rc);
  39. g_screenwid = rc.Width();
  40. g_screenhei = rc.Height();
  41. }
  42. else
  43. {
  44. g_screenwid = g_dm.dmPelsWidth;
  45. g_screenhei = g_dm.dmPelsHeight;
  46. }
  47. g_fscalex = (float)g_screenwid / 1024.0;
  48. g_fscaley = (float)g_screenhei / 768.0;
  49. /* begin Jeff 这段代码未有使用意义 */
  50. wnd = ::FindWindow("Shell_TrayWnd", 0);
  51. ::GetWindowRect(wnd, &rc);
  52. int hei = rc.Height();
  53. rc = CRect(0, 0, g_screenwid, g_screenhei - hei);
  54. /* end Jeff 这段代码未有使用意义 */
  55. g_fscalex = (float)g_screenwid / 2000.0;
  56. g_fscaley = (float)(g_screenhei - hei) / 1400.0;
  57. }
  58. CYLGLApp theApp;
  59. class CAboutDlg : public CDialog
  60. {
  61. public:
  62. CAboutDlg();
  63. enum { IDD = IDD_ABOUTBOX };
  64. protected:
  65. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  66. protected:
  67. DECLARE_MESSAGE_MAP()
  68. };
  69. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  70. {
  71. }
  72. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  73. {
  74. CDialog::DoDataExchange(pDX);
  75. }
  76. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  77. END_MESSAGE_MAP()
  78. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CYLGLApp message handlers
  81. BOOL CYLGLApp::InitInstance()
  82. {
  83. /************************************************************************/
  84. #if _USE_CONSOLE_FOR_DEBUG // Jeff.控制台输出信息;
  85. AllocConsole(); // 开辟控制台
  86. SetConsoleTitle(_T("+lyfz:调试信息输出++++++")); // 设置控制台窗口标题
  87. freopen("CONOUT$","w+t",stdout); // 重定向输出
  88. freopen("CONIN$","r+t",stdin); // 重定向输入
  89. #endif
  90. //printf("Jeff:m_lpCmdLine = %s\n\n",m_lpCmdLine);//Jeffprintf
  91. // Jeff.命令行genbranchdata值,由本机服务端DBServer.exe执行输入;
  92. // 使用批处理可以指定这个命令行的内容
  93. //
  94. // ---------批处理---------------
  95. // @echo off
  96. // start %~dp0YLGL.exe genbranchdata
  97. // ---------批处理--------------
  98. //
  99. // DBServer.exe调用Shell命令传入该命令行genbranchdata值;
  100. if (m_lpCmdLine[0] == _T('\0')) //没有命令行参数
  101. {
  102. // return false;
  103. //WriteClientLog("无命令行输入");
  104. }
  105. else
  106. {
  107. CString str = m_lpCmdLine;
  108. if (str == "genbranchdata")
  109. {
  110. //WriteClientLog("命令行=genbranchdata");
  111. g_bGenBranchData = 1;
  112. }
  113. }
  114. if (g_bGenBranchData == 0)
  115. {
  116. HANDLE hObject = CreateMutex(NULL, FALSE, _T("CYLGLAppXiao"));
  117. if (GetLastError() == ERROR_ALREADY_EXISTS)
  118. {
  119. AfxMessageBox("提醒:软件已启动!", MB_ICONINFORMATION);
  120. }
  121. }
  122. AfxEnableControlContainer();
  123. g_listctrlfont.CreatePointFont(110, _T("System"));
  124. #ifdef _AFXDLL
  125. Enable3dControls(); // Call this when using MFC in a shared DLL
  126. #else
  127. Enable3dControlsStatic(); // Call this when linking to MFC statically
  128. #endif
  129. GetDebugPriv();
  130. // 获取升级的产品版本;
  131. GetProductVersion(NULL, g_arrFileVersion);
  132. // Jeff:dbconfig.dat里的信息,可以包含*.ly.com和计算机名称、IP地址三种;
  133. // 1.*.ly.com的需要解析出分店的IP地址;
  134. // 2.*.ly.com的解析是需要连接到公司服务器软件,然后返回ip地址,保存在ip.txt里;
  135. // Jeff.dbconfig.dat里保存的是*.ly.com信息,一般是用在外网访问花生壳域名的服务端软件;
  136. char path[MAX_PATH];
  137. ::GetModuleFileName(NULL, path, MAX_PATH);
  138. g_mainpath = path;
  139. g_mainpath = g_mainpath.Left(g_mainpath.ReverseFind('\\'));
  140. CString configpath = g_mainpath + "\\dbconfig.dat";
  141. // 1.初始化SOCKET
  142. int nResult = Transport_Init();
  143. if (TRANSPORT_OK != nResult)
  144. {
  145. WriteClientLog("网络初始化失败,软件退出!");
  146. return false;
  147. }
  148. // 2.获取服务器地址;
  149. if (g_bGenBranchData)
  150. {
  151. // Jeff.启动g_bGenBranchData功能,是指由服务器DBServer.exe使用Shell命令来调用YLGL.exe并传入genbranchdata命令行
  152. // 而此时YLGL.exe读取本机计算机名;
  153. char server[50];
  154. DWORD leng = 50;
  155. ::GetComputerName(server, &leng);
  156. g_serverbak = g_server = server;
  157. g_serverbak.TrimLeft();
  158. g_serverbak.TrimRight(".");
  159. g_serverbak.TrimRight();
  160. // Jeff. find(.ly.com)是不需要判断的一步;
  161. if (g_server.Find(".ly.com") == -1 && g_server.Find("192.168.") == -1)
  162. MyGetIPByName(g_server);
  163. if (g_server.Find("192.168.") != -1)
  164. g_serverarray.Add(g_server);
  165. // printf("Jeff.g_bGenBranchData=1,g_server=%s,g_serverbak=%s\n\n",g_server,g_serverbak);//Jeffprintf
  166. }
  167. else
  168. {
  169. GetSysIniInfo();
  170. g_serverbak = g_server = g_szHostComputerIP;
  171. g_serverbak.TrimLeft();
  172. g_serverbak.TrimRight(".");
  173. g_serverbak.TrimRight();
  174. if (g_server.Find(".ly.com") == -1 && g_server.Find("192.168.") == -1)
  175. MyGetIPByName(g_server);
  176. if (g_server.Find("192.168.") != -1)
  177. g_serverarray.Add(g_server);
  178. if (g_server.IsEmpty())
  179. {
  180. AfxMessageBox("获取IP失败! 请确认服务器名 " + g_serverbak + " 是否正确? 或修改网络设置或与系统hosts文件!");
  181. // g_serverarray.Add (g_serverbak);
  182. // g_server=g_serverbak;
  183. return 0;
  184. }
  185. IsShareFolderExist(g_szHostComputerIP);// add by Jeff,检测共享目录是否存在可写;
  186. // 10.0.0.0/8:10.0.0.0~10.255.255.255
  187. // 172.16.0.0/12:172.16.0.0~172.31.255.255
  188. // 192.168.0.0/16:192.168.0.0~192.168.255.255
  189. if (g_server.Find("10.") != -1 || g_server.Find("172.") != -1 || g_server.Find("192.168") != -1)
  190. {
  191. }
  192. else
  193. {
  194. // g_serverbak="localserver";
  195. }
  196. }
  197. CStdioFile fp2;
  198. if (fp2.Open(g_mainpath + "\\title.txt", CFile::modeRead))
  199. {
  200. fp2.ReadString(g_title);
  201. fp2.Close();
  202. }
  203. //free((void*)m_pszAppName);
  204. m_pszAppName = _tcsdup(g_title + "影楼管理系统");
  205. g_titlefont.CreatePointFont(160, _T("宋体"));
  206. SetRegistryKey(_T("LYFZ-YLGL"));
  207. CString version = _T("Version 1.0");
  208. g_bRedSkin = AfxGetApp()->GetProfileInt(version, "redskin", 0);
  209. if (g_bRedSkin)
  210. {
  211. g_gridcol1 = RGB(241, 180, 198);
  212. g_gridcol2 = RGB(237, 157, 182);
  213. g_bkcol = RGB(235, 149, 174);
  214. }//184, 184
  215. g_editbkbrush.CreateSolidBrush(g_bkcol);
  216. LoadStdProfileSettings(); // Load standard INI file options (including MRU)
  217. GdiplusStartupInput gdiplusStartupInput;
  218. GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
  219. // Jeff.若程序没有足够的权限,则会注册失败;
  220. // Jeff..若文件不存在呢,注册就无意义;
  221. CString temp;
  222. temp.Format("%s\\MSCHRT20.OCX", g_mainpath);
  223. OFSTRUCT ofStruct;
  224. OpenFile(temp, &ofStruct, OF_EXIST);
  225. if (ERROR_FILE_NOT_FOUND != GetLastError())
  226. {
  227. RegisterOcx(temp);
  228. }
  229. // Jeff.IRStartup属于换肤库的启动函数;
  230. HINSTANCE hModule = GetModuleHandle(NULL);
  231. IRStartup(hModule, GetCurrentThreadId());
  232. CMultiDocTemplate* pDocTemplate;
  233. pDocTemplate = new CMultiDocTemplate(
  234. IDR_MAINFRAME,
  235. NULL,
  236. RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  237. RUNTIME_CLASS(CYLGLView));
  238. AddDocTemplate(pDocTemplate);
  239. // create main MDI Frame window
  240. CMainFrame* pMainFrame = new CMainFrame;
  241. if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) // LoadFrame调用OnCreate
  242. {
  243. return FALSE;
  244. }
  245. m_pMainWnd = pMainFrame;
  246. // 加载OfficeXP风格菜单
  247. #ifndef NEW_SKIN
  248. CMenu* pMenu = m_pMainWnd->GetMenu();
  249. if (pMenu)pMenu->DestroyMenu();
  250. HMENU hMenu = ((CMainFrame*) m_pMainWnd)->NewMenu();
  251. pMenu = CMenu::FromHandle( hMenu );
  252. m_pMainWnd->SetMenu(pMenu);
  253. ((CMainFrame*)m_pMainWnd)->m_hMenuDefault = hMenu;
  254. #endif
  255. // Parse command line for standard shell commands, DDE, file open
  256. ////////////////////////////////////////////////////
  257. // 禁止自动新建子窗口
  258. // CCommandLineInfo cmdInfo;
  259. // ParseCommandLine(cmdInfo);
  260. // // Dispatch commands specified on the command line
  261. // if (!ProcessShellCommand(cmdInfo))
  262. // return FALSE;
  263. m_pMainWnd->SetWindowText(g_title + "影楼管理系统");
  264. m_pMainWnd->UpdateWindow();
  265. SetDialogBkColor(g_bkcol, RGB(0, 0, 0));
  266. return TRUE;
  267. }
  268. BOOL CYLGLApp::IsShareFolderExist(char *szServerName)
  269. {
  270. char szPath1[MAX_PATH] = { 0 };
  271. sprintf(szPath1, "\\\\%s\\%s", szServerName, "电话录音(管理软件)$");
  272. IsExistFolder(szPath1);
  273. sprintf(szPath1, "\\\\%s\\%s", szServerName, "客户原片(管理软件)$");
  274. IsExistFolder(szPath1);
  275. sprintf(szPath1, "\\\\%s\\%s", szServerName, "精修好的片(管理软件)$");
  276. IsExistFolder(szPath1);
  277. sprintf(szPath1, "\\\\%s\\%s", szServerName, "礼服图片(管理软件)$");
  278. IsExistFolder(szPath1);
  279. sprintf(szPath1, "\\\\%s\\%s", szServerName, "设计好的片(管理软件)$");
  280. IsExistFolder(szPath1);
  281. sprintf(szPath1, "\\\\%s\\%s", szServerName, "修好的片(管理软件)$");
  282. IsExistFolder(szPath1);
  283. return TRUE;
  284. }
  285. int CYLGLApp::DoMessageBox(LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt)
  286. {
  287. return CWinApp::DoMessageBox(lpszPrompt, nType, nIDPrompt);
  288. }
  289. // App command to run the dialog
  290. void CYLGLApp::OnAppAbout()
  291. {
  292. CAboutDlg aboutDlg;
  293. aboutDlg.DoModal();
  294. }
  295. int CYLGLApp::ExitInstance()
  296. {
  297. //关闭gdiplus的环境
  298. GdiplusShutdown(gdiplusToken);
  299. for (int i = 0; i < g_pointerarray.GetSize(); i++)
  300. delete[](g_pointerarray.ElementAt(i));
  301. IRComplete();
  302. #if _USE_CONSOLE_FOR_DEBUG
  303. FreeConsole(); //释放控制台;
  304. #endif
  305. //WriteLog("退出系统");//Jeff.add
  306. return CWinApp::ExitInstance();
  307. }
  308. int GetPos(DWORD leng)
  309. {
  310. if (g_lengarray.GetSize() == 0)
  311. {
  312. g_sendhead.bsql = 0;
  313. g_sendhead.code[0] = 105; //Jeff.服务器返回10.lia文件的数据、文件大小;
  314. g_sendhead.tabcount = 1;
  315. g_pMainWnd->ProcessChatMessageRequest2(1);
  316. if (g_bSendOK == 0) return -1;
  317. DWORD leng;
  318. DWORD readbytes = 0;
  319. // Jeff.remark.2014.06.26
  320. // g_pData 里此时保存的是10.lia文件内容;
  321. // 根据10.lia的结构,解释其它内部数据;
  322. // 目前没有其结构文档解释,暂时未知10.lia内含什么数据种类;
  323. // 以下是根据代码假设的内容:
  324. // -------------------------------
  325. // 4 byte.某文件A大小,用dwLengthA表示;
  326. // dwLengthA byte:文件A的数据
  327. // 4 byte.某文件B大小,用dwLengthB表示;
  328. // dwLengthB byte:文件B的数据;
  329. // ------以下文件组C-------------
  330. // 4 byte.某文件组C大小,用dwLengthC表示;
  331. // dwLengthC:某文件组C的数据;
  332. // 某文件C的数据结构:RESDATA2
  333. // 文件组C文件个数nCount = dwLengthC/sizeof(RESDATA2);
  334. //---------------------------------------
  335. // 10.lia文件总大小:dwSum = dwLengthA+dwLengthB+dwLengthC;
  336. // 10.lia文件内数据结构种类有三种:A,B,C 其中C为一组同类型数据;
  337. // 10.lia文件内数据结构个数: 2 + nCount;
  338. // --------------------------------
  339. ENCODE_START
  340. memcpy(&leng, g_pData + readbytes, sizeof(DWORD));
  341. readbytes += sizeof(DWORD);
  342. {
  343. CMemFile memfile;
  344. memfile.Attach(g_pData + readbytes, leng);
  345. readbytes += leng;
  346. CArchive ar(&memfile, CArchive::load);
  347. g_lengarray.Serialize(ar);
  348. ar.Close();
  349. memfile.Detach();
  350. }
  351. memcpy(&leng, g_pData + readbytes, sizeof(DWORD));
  352. readbytes += sizeof(DWORD);
  353. {
  354. CMemFile memfile;
  355. memfile.Attach(g_pData + readbytes, leng);
  356. readbytes += leng;
  357. CArchive ar(&memfile, CArchive::load);
  358. g_btnlengarray.Serialize(ar);
  359. ar.Close();
  360. memfile.Detach();
  361. }
  362. memcpy(&leng, g_pData + readbytes, sizeof(DWORD));
  363. readbytes += sizeof(DWORD);
  364. ENCODE_END
  365. int count = leng / sizeof(RESDATA2);
  366. for (int i = 0; i < count; i++)
  367. {
  368. BYTE *pData = new BYTE[sizeof(RESDATA2)];
  369. memcpy(pData, g_pData + readbytes, sizeof(RESDATA2));
  370. readbytes += sizeof(RESDATA2);
  371. g_pointerarray.Add(pData);
  372. }
  373. }
  374. for (int i = 0; i < g_lengarray.GetSize(); i++)
  375. {
  376. if (leng == g_lengarray.ElementAt(i))
  377. {
  378. return i;
  379. }
  380. }
  381. return -1;
  382. }
  383. extern void SizeToContent(HWND hwnd, Image *img);
  384. BOOL LoadLia(CString path, BYTE **pData, BYTE **pDataBegin, Image **pBk, HWND hwnd)
  385. {
  386. try
  387. {
  388. CFile fp;
  389. if (!fp.Open(path, CFile::modeRead))
  390. {
  391. exit(0);
  392. }
  393. DWORD dwFileLength = fp.GetLength(); // dwFileLength文件长度;
  394. // 1.读取文件内容,存储在pData数组中;
  395. *pData = new BYTE[dwFileLength];
  396. fp.Read(*pData, dwFileLength);
  397. fp.Close();
  398. // 2.保存文件头指针;
  399. *pDataBegin = *pData;
  400. /////////////
  401. CStringArray strChildArray;
  402. DWORD dwChildLength;
  403. // 3.获取头4个字节内容,保存在dwChildLength中;
  404. memcpy(&dwChildLength, *pData, sizeof(DWORD));
  405. *pData += sizeof(DWORD);
  406. // 4.获取第4个字节后dwChildLength长度内容,保存在pChildData数组中;
  407. BYTE *pChildData = new BYTE[dwChildLength];
  408. memcpy(pChildData, *pData, dwChildLength);
  409. *pData += dwChildLength;
  410. // 5.将pChildData数据附加到内存文件中;
  411. CMemFile memfile;
  412. memfile.Attach(pChildData, dwChildLength);
  413. // 6.将内存文件memfile序列化存储到CArchive对象中;
  414. CArchive ar(&memfile, CArchive::load);
  415. // 7.CArray对象strChildArray从CArchive对象中序列化加载数据;
  416. strChildArray.Serialize(ar);
  417. // 8.strChildArray加载完成,释放内存;
  418. ar.Close();
  419. memfile.Detach();
  420. delete[]pChildData;
  421. //////////////////////
  422. int pos = GetPos(dwFileLength);
  423. if (pos == -1)
  424. {
  425. exit(0);
  426. }
  427. DWORD leng1, leng2, leng3, leng4, leng5, leng6, leng7, leng8;
  428. leng1 = g_btnlengarray.ElementAt(pos * 8 + 0);
  429. leng2 = g_btnlengarray.ElementAt(pos * 8 + 1);
  430. leng3 = g_btnlengarray.ElementAt(pos * 8 + 2);
  431. leng4 = g_btnlengarray.ElementAt(pos * 8 + 3);
  432. leng5 = g_btnlengarray.ElementAt(pos * 8 + 4);
  433. leng6 = g_btnlengarray.ElementAt(pos * 8 + 5);
  434. leng7 = g_btnlengarray.ElementAt(pos * 8 + 6);
  435. leng8 = g_btnlengarray.ElementAt(pos * 8 + 7);
  436. /* if( pos %4==0)
  437. DeCodelong1( (long&)leng1, (long&)leng2, (long&)leng3, (long&)leng4, (long&)leng5, (long&)leng6, (long&)leng7, (long&)leng8 );
  438. else if( pos %4==1)
  439. DeCodelong2( (long&)leng1, (long&)leng2, (long&)leng3, (long&)leng4, (long&)leng5, (long&)leng6, (long&)leng7, (long&)leng8 );
  440. else if( pos %4==2)
  441. DeCodelong3( (long&)leng1, (long&)leng2, (long&)leng3, (long&)leng4, (long&)leng5, (long&)leng6, (long&)leng7, (long&)leng8 );
  442. else
  443. DeCodelong4( (long&)leng1, (long&)leng2, (long&)leng3, (long&)leng4, (long&)leng5, (long&)leng6, (long&)leng7, (long&)leng8 );
  444. */
  445. CArray<DWORD, DWORD>dataarray;
  446. dataarray.Add(pos);
  447. dataarray.Add(leng1);
  448. dataarray.Add(leng2);
  449. dataarray.Add(leng3);
  450. dataarray.Add(leng4);
  451. dataarray.Add(leng5);
  452. dataarray.Add(leng6);
  453. dataarray.Add(leng7);
  454. dataarray.Add(leng8);
  455. memcpy(&g_resdata2, g_pointerarray.ElementAt(pos), sizeof(RESDATA2));
  456. RESDATA2 *pRes = &g_resdata2;
  457. /*
  458. DeCodelong1( (long&)(pRes->rect[0].right), (long&)(pRes->rect[1].right), (long&)(pRes->rect[2].right), (long&)(pRes->rect[3].right), (long&)(pRes->rect[4].right), (long&)(pRes->rect[5].right), (long&)(pRes->rect[6].right), (long&)(pRes->rect[7].right) );
  459. DeCodelong2( (long&)(pRes->rect[8].right), (long&)(pRes->rect[9].right), (long&)(pRes->rect[10].right), (long&)(pRes->rect[11].right), (long&)(pRes->rect[12].right), (long&)(pRes->rect[13].right), (long&)(pRes->rect[14].right), (long&)(pRes->rect[15].right) );
  460. DeCodelong3( (long&)(pRes->rect[0].left), (long&)(pRes->rect[1].left), (long&)(pRes->rect[2].left), (long&)(pRes->rect[3].left), (long&)(pRes->rect[4].left), (long&)(pRes->rect[5].left), (long&)(pRes->rect[6].left), (long&)(pRes->rect[7].left) );
  461. DeCodelong4( (long&)(pRes->rect[8].left), (long&)(pRes->rect[9].left), (long&)(pRes->rect[10].left), (long&)(pRes->rect[11].left), (long&)(pRes->rect[12].left), (long&)(pRes->rect[13].left), (long&)(pRes->rect[14].left), (long&)(pRes->rect[15].left) );
  462. */
  463. dataarray.Add(pRes->rect[0].right);
  464. dataarray.Add(pRes->rect[1].right);
  465. dataarray.Add(pRes->rect[2].right);
  466. dataarray.Add(pRes->rect[3].right);
  467. dataarray.Add(pRes->rect[4].right);
  468. dataarray.Add(pRes->rect[5].right);
  469. dataarray.Add(pRes->rect[6].right);
  470. dataarray.Add(pRes->rect[7].right);
  471. dataarray.Add(pRes->rect[8].right);
  472. dataarray.Add(pRes->rect[9].right);
  473. dataarray.Add(pRes->rect[10].right);
  474. dataarray.Add(pRes->rect[11].right);
  475. dataarray.Add(pRes->rect[12].right);
  476. dataarray.Add(pRes->rect[13].right);
  477. dataarray.Add(pRes->rect[14].right);
  478. dataarray.Add(pRes->rect[15].right);
  479. dataarray.Add(pRes->rect[0].left);
  480. dataarray.Add(pRes->rect[1].left);
  481. dataarray.Add(pRes->rect[2].left);
  482. dataarray.Add(pRes->rect[3].left);
  483. dataarray.Add(pRes->rect[4].left);
  484. dataarray.Add(pRes->rect[5].left);
  485. dataarray.Add(pRes->rect[6].left);
  486. dataarray.Add(pRes->rect[7].left);
  487. dataarray.Add(pRes->rect[8].left);
  488. dataarray.Add(pRes->rect[9].left);
  489. dataarray.Add(pRes->rect[10].left);
  490. dataarray.Add(pRes->rect[11].left);
  491. dataarray.Add(pRes->rect[12].left);
  492. dataarray.Add(pRes->rect[13].left);
  493. dataarray.Add(pRes->rect[14].left);
  494. dataarray.Add(pRes->rect[15].left);
  495. dataarray.Add(g_resdata2.nPicCount);
  496. dataarray.Add(g_resdata2.nPicCount2);
  497. DWORD bkleng, bkleng2;
  498. ::memcpy(&bkleng2, *pData, sizeof(DWORD));
  499. *pData += sizeof(DWORD);
  500. ::memcpy(&bkleng, *pData, sizeof(DWORD));
  501. *pData += sizeof(DWORD);
  502. dataarray.Add(bkleng);
  503. dataarray.Add(bkleng2);
  504. ENCODE_START
  505. {
  506. CMemFile memfile;
  507. CArchive ar(&memfile, CArchive::store);
  508. dataarray.Serialize(ar);
  509. ar.Close();
  510. int length = memfile.GetLength();
  511. BYTE *pMemData = memfile.Detach();
  512. g_nSendCode = 7;
  513. g_pMainWnd->ProcessChatMessageRequest2(pMemData, length);
  514. g_nSendCode = 0;
  515. delete[]pMemData;
  516. if (g_bSendOK == 0)
  517. {
  518. //AfxMessageBox("g_bSendOK==0");
  519. return 0;
  520. }
  521. }
  522. ENCODE_END
  523. // 将g_nSendCode = 7的返回值装载到CMemFile;
  524. {
  525. dataarray.RemoveAll();
  526. CMemFile memfile;
  527. memfile.Attach(g_pData, g_nLeng);
  528. CArchive ar(&memfile, CArchive::load);
  529. dataarray.Serialize(ar);
  530. ar.Close();
  531. memfile.Detach();
  532. ENCODE_START
  533. int i = 0;
  534. for ( i = 0; i < 8; i++)
  535. g_btnleng[i] = dataarray.ElementAt(i + 1);
  536. g_btnlengpos = 0;
  537. for (i = 9; i < 25; i++)
  538. pRes->rect[i - 9].right = dataarray.ElementAt(i);
  539. for (i = 25; i < 41; i++)
  540. pRes->rect[i - 25].left = dataarray.ElementAt(i);
  541. g_resdata2.nPicCount = dataarray.ElementAt(41);
  542. g_resdata2.nPicCount2 = dataarray.ElementAt(42);
  543. bkleng = dataarray.ElementAt(43);
  544. bkleng2 = dataarray.ElementAt(44);
  545. ENCODE_END
  546. }
  547. if (g_resdata2.bHasBk)
  548. {
  549. BYTE *m_pSaveBk = NULL;
  550. MyBmpButton2::ReadBK(pData, &m_pSaveBk, bkleng);
  551. LoadImageFromBuf(pBk, m_pSaveBk, bkleng);
  552. delete[]m_pSaveBk;
  553. if ((*pBk)->GetWidth() == 633 && (*pBk)->GetHeight() == 50)//picbar
  554. {
  555. }
  556. else if ((*pBk)->GetWidth() == 2000)
  557. {
  558. CRect rc;
  559. HWND wnd = ::FindWindow("Shell_TrayWnd", 0);
  560. ::GetWindowRect(wnd, &rc);
  561. int hei = rc.Height();
  562. rc = CRect(0, 0, g_screenwid, g_screenhei - hei);
  563. g_fscalex = (float)g_screenwid / 2000.0;
  564. g_fscaley = (float)(g_screenhei - hei) / 1400.0;
  565. }
  566. else if ((*pBk)->GetWidth() == 600 && (*pBk)->GetHeight() == 371)
  567. {
  568. g_fscalex = (float)g_screenwid / 1024.0;
  569. g_fscaley = (float)g_screenhei / 768.0;
  570. }
  571. else //if((*pBk)->GetWidth()==1024 )
  572. {
  573. g_fscalex = (float)g_screenwid / 1024.0;
  574. g_fscaley = (float)g_screenhei / 768.0;
  575. }
  576. SizeToContent(hwnd, *pBk);
  577. if ((*pBk)->GetWidth() == 1024 && (*pBk)->GetHeight() == 768)
  578. ::SetWindowPos(hwnd, HWND_TOP, 0, 0, g_screenwid, g_screenhei, SWP_SHOWWINDOW);
  579. if ((*pBk)->GetWidth() == 2000 && (*pBk)->GetHeight() == 1399)
  580. ::SetWindowPos(hwnd, HWND_TOP, 0, 0, g_screenwid, g_screenhei, SWP_SHOWWINDOW);
  581. }
  582. // DeCodePicCount((long&)g_resdata2.nPicCount, (long&)g_resdata2.nPicCount2);
  583. return 1;
  584. }
  585. catch (...)
  586. {
  587. return 0;
  588. }
  589. }
  590. CString GetModifyTime(CString path)
  591. {
  592. HANDLE hFile;
  593. WIN32_FIND_DATA wfd;
  594. // SYSTEMTIME systime;
  595. FILETIME localtime;
  596. CString stime; //输出时间
  597. memset(&wfd, 0, sizeof(wfd));
  598. if ((hFile = FindFirstFile(path, &wfd)) == INVALID_HANDLE_VALUE)
  599. return "";
  600. //ok,转换时间
  601. FileTimeToLocalFileTime(&wfd.ftLastWriteTime, &localtime);
  602. stime.Format("%16d%16d", localtime.dwHighDateTime, localtime.dwLowDateTime);
  603. return stime;
  604. }
  605. BOOL CheckBadWords2(CString str, BOOL bMsg)
  606. {
  607. return 1;
  608. }