YLGL.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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, &g_rcScreen);
  39. g_screenwid = g_rcScreen.Width();
  40. g_screenhei = g_rcScreen.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. return CWinApp::ExitInstance();
  306. }
  307. int GetPos(DWORD leng)
  308. {
  309. if (g_lengarray.GetSize() == 0)
  310. {
  311. g_sendhead.bsql = 0;
  312. g_sendhead.code[0] = 105; //Jeff.服务器返回10.lia文件的数据、文件大小;
  313. g_sendhead.tabcount = 1;
  314. g_pMainWnd->ProcessChatMessageRequest2(1);
  315. if (g_bSendOK == 0) return -1;
  316. DWORD leng;
  317. DWORD readbytes = 0;
  318. // Jeff.remark.2014.06.26
  319. // g_pData 里此时保存的是10.lia文件内容;
  320. // 根据10.lia的结构,解释其它内部数据;
  321. // 目前没有其结构文档解释,暂时未知10.lia内含什么数据种类;
  322. // 以下是根据代码假设的内容:
  323. // -------------------------------
  324. // 4 byte.某文件A大小,用dwLengthA表示;
  325. // dwLengthA byte:文件A的数据
  326. // 4 byte.某文件B大小,用dwLengthB表示;
  327. // dwLengthB byte:文件B的数据;
  328. // ------以下文件组C-------------
  329. // 4 byte.某文件组C大小,用dwLengthC表示;
  330. // dwLengthC:某文件组C的数据;
  331. // 某文件C的数据结构:RESDATA2
  332. // 文件组C文件个数nCount = dwLengthC/sizeof(RESDATA2);
  333. //---------------------------------------
  334. // 10.lia文件总大小:dwSum = dwLengthA+dwLengthB+dwLengthC;
  335. // 10.lia文件内数据结构种类有三种:A,B,C 其中C为一组同类型数据;
  336. // 10.lia文件内数据结构个数: 2 + nCount;
  337. // --------------------------------
  338. ENCODE_START
  339. memcpy(&leng, g_pData + readbytes, sizeof(DWORD));
  340. readbytes += sizeof(DWORD);
  341. {
  342. CMemFile memfile;
  343. memfile.Attach(g_pData + readbytes, leng);
  344. readbytes += leng;
  345. CArchive ar(&memfile, CArchive::load);
  346. g_lengarray.Serialize(ar);
  347. ar.Close();
  348. memfile.Detach();
  349. }
  350. memcpy(&leng, g_pData + readbytes, sizeof(DWORD));
  351. readbytes += sizeof(DWORD);
  352. {
  353. CMemFile memfile;
  354. memfile.Attach(g_pData + readbytes, leng);
  355. readbytes += leng;
  356. CArchive ar(&memfile, CArchive::load);
  357. g_btnlengarray.Serialize(ar);
  358. ar.Close();
  359. memfile.Detach();
  360. }
  361. memcpy(&leng, g_pData + readbytes, sizeof(DWORD));
  362. readbytes += sizeof(DWORD);
  363. ENCODE_END
  364. int count = leng / sizeof(RESDATA2);
  365. for (int i = 0; i < count; i++)
  366. {
  367. BYTE *pData = new BYTE[sizeof(RESDATA2)];
  368. memcpy(pData, g_pData + readbytes, sizeof(RESDATA2));
  369. readbytes += sizeof(RESDATA2);
  370. g_pointerarray.Add(pData);
  371. }
  372. }
  373. for (int i = 0; i < g_lengarray.GetSize(); i++)
  374. {
  375. if (leng == g_lengarray.ElementAt(i))
  376. {
  377. return i;
  378. }
  379. }
  380. return -1;
  381. }
  382. extern void SizeToContent(HWND hwnd, Image *img);
  383. BOOL LoadLia(CString path, BYTE **pData, BYTE **pDataBegin, Image **pBk, HWND hwnd)
  384. {
  385. try
  386. {
  387. CFile fp;
  388. if (!fp.Open(path, CFile::modeRead))
  389. {
  390. exit(0);
  391. }
  392. DWORD dwFileLength = fp.GetLength(); // dwFileLength文件长度;
  393. // 1.读取文件内容,存储在pData数组中;
  394. *pData = new BYTE[dwFileLength];
  395. fp.Read(*pData, dwFileLength);
  396. fp.Close();
  397. // 2.保存文件头指针;
  398. *pDataBegin = *pData;
  399. /////////////
  400. CStringArray strChildArray;
  401. DWORD dwChildLength;
  402. // 3.获取头4个字节内容,保存在dwChildLength中;
  403. memcpy(&dwChildLength, *pData, sizeof(DWORD));
  404. *pData += sizeof(DWORD);
  405. // 4.获取第4个字节后dwChildLength长度内容,保存在pChildData数组中;
  406. BYTE *pChildData = new BYTE[dwChildLength];
  407. memcpy(pChildData, *pData, dwChildLength);
  408. *pData += dwChildLength;
  409. // 5.将pChildData数据附加到内存文件中;
  410. CMemFile memfile;
  411. memfile.Attach(pChildData, dwChildLength);
  412. // 6.将内存文件memfile序列化存储到CArchive对象中;
  413. CArchive ar(&memfile, CArchive::load);
  414. // 7.CArray对象strChildArray从CArchive对象中序列化加载数据;
  415. strChildArray.Serialize(ar);
  416. // 8.strChildArray加载完成,释放内存;
  417. ar.Close();
  418. memfile.Detach();
  419. delete[]pChildData;
  420. //////////////////////
  421. int pos = GetPos(dwFileLength);
  422. if (pos == -1)
  423. {
  424. exit(0);
  425. }
  426. DWORD leng1, leng2, leng3, leng4, leng5, leng6, leng7, leng8;
  427. leng1 = g_btnlengarray.ElementAt(pos * 8 + 0);
  428. leng2 = g_btnlengarray.ElementAt(pos * 8 + 1);
  429. leng3 = g_btnlengarray.ElementAt(pos * 8 + 2);
  430. leng4 = g_btnlengarray.ElementAt(pos * 8 + 3);
  431. leng5 = g_btnlengarray.ElementAt(pos * 8 + 4);
  432. leng6 = g_btnlengarray.ElementAt(pos * 8 + 5);
  433. leng7 = g_btnlengarray.ElementAt(pos * 8 + 6);
  434. leng8 = g_btnlengarray.ElementAt(pos * 8 + 7);
  435. /* if( pos %4==0)
  436. DeCodelong1( (long&)leng1, (long&)leng2, (long&)leng3, (long&)leng4, (long&)leng5, (long&)leng6, (long&)leng7, (long&)leng8 );
  437. else if( pos %4==1)
  438. DeCodelong2( (long&)leng1, (long&)leng2, (long&)leng3, (long&)leng4, (long&)leng5, (long&)leng6, (long&)leng7, (long&)leng8 );
  439. else if( pos %4==2)
  440. DeCodelong3( (long&)leng1, (long&)leng2, (long&)leng3, (long&)leng4, (long&)leng5, (long&)leng6, (long&)leng7, (long&)leng8 );
  441. else
  442. DeCodelong4( (long&)leng1, (long&)leng2, (long&)leng3, (long&)leng4, (long&)leng5, (long&)leng6, (long&)leng7, (long&)leng8 );
  443. */
  444. CArray<DWORD, DWORD>dataarray;
  445. dataarray.Add(pos);
  446. dataarray.Add(leng1);
  447. dataarray.Add(leng2);
  448. dataarray.Add(leng3);
  449. dataarray.Add(leng4);
  450. dataarray.Add(leng5);
  451. dataarray.Add(leng6);
  452. dataarray.Add(leng7);
  453. dataarray.Add(leng8);
  454. memcpy(&g_resdata2, g_pointerarray.ElementAt(pos), sizeof(RESDATA2));
  455. RESDATA2 *pRes = &g_resdata2;
  456. /*
  457. 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) );
  458. 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) );
  459. 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) );
  460. 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) );
  461. */
  462. dataarray.Add(pRes->rect[0].right);
  463. dataarray.Add(pRes->rect[1].right);
  464. dataarray.Add(pRes->rect[2].right);
  465. dataarray.Add(pRes->rect[3].right);
  466. dataarray.Add(pRes->rect[4].right);
  467. dataarray.Add(pRes->rect[5].right);
  468. dataarray.Add(pRes->rect[6].right);
  469. dataarray.Add(pRes->rect[7].right);
  470. dataarray.Add(pRes->rect[8].right);
  471. dataarray.Add(pRes->rect[9].right);
  472. dataarray.Add(pRes->rect[10].right);
  473. dataarray.Add(pRes->rect[11].right);
  474. dataarray.Add(pRes->rect[12].right);
  475. dataarray.Add(pRes->rect[13].right);
  476. dataarray.Add(pRes->rect[14].right);
  477. dataarray.Add(pRes->rect[15].right);
  478. dataarray.Add(pRes->rect[0].left);
  479. dataarray.Add(pRes->rect[1].left);
  480. dataarray.Add(pRes->rect[2].left);
  481. dataarray.Add(pRes->rect[3].left);
  482. dataarray.Add(pRes->rect[4].left);
  483. dataarray.Add(pRes->rect[5].left);
  484. dataarray.Add(pRes->rect[6].left);
  485. dataarray.Add(pRes->rect[7].left);
  486. dataarray.Add(pRes->rect[8].left);
  487. dataarray.Add(pRes->rect[9].left);
  488. dataarray.Add(pRes->rect[10].left);
  489. dataarray.Add(pRes->rect[11].left);
  490. dataarray.Add(pRes->rect[12].left);
  491. dataarray.Add(pRes->rect[13].left);
  492. dataarray.Add(pRes->rect[14].left);
  493. dataarray.Add(pRes->rect[15].left);
  494. dataarray.Add(g_resdata2.nPicCount);
  495. dataarray.Add(g_resdata2.nPicCount2);
  496. DWORD bkleng, bkleng2;
  497. ::memcpy(&bkleng2, *pData, sizeof(DWORD));
  498. *pData += sizeof(DWORD);
  499. ::memcpy(&bkleng, *pData, sizeof(DWORD));
  500. *pData += sizeof(DWORD);
  501. dataarray.Add(bkleng);
  502. dataarray.Add(bkleng2);
  503. ENCODE_START
  504. {
  505. CMemFile memfile;
  506. CArchive ar(&memfile, CArchive::store);
  507. dataarray.Serialize(ar);
  508. ar.Close();
  509. int length = memfile.GetLength();
  510. BYTE *pMemData = memfile.Detach();
  511. g_nSendCode = 7;
  512. g_pMainWnd->ProcessChatMessageRequest2(pMemData, length);
  513. g_nSendCode = 0;
  514. delete[]pMemData;
  515. if (g_bSendOK == 0)
  516. {
  517. //AfxMessageBox("g_bSendOK==0");
  518. return 0;
  519. }
  520. }
  521. ENCODE_END
  522. // 将g_nSendCode = 7的返回值装载到CMemFile;
  523. {
  524. dataarray.RemoveAll();
  525. CMemFile memfile;
  526. memfile.Attach(g_pData, g_nLeng);
  527. CArchive ar(&memfile, CArchive::load);
  528. dataarray.Serialize(ar);
  529. ar.Close();
  530. memfile.Detach();
  531. ENCODE_START
  532. int i = 0;
  533. for ( i = 0; i < 8; i++)
  534. g_btnleng[i] = dataarray.ElementAt(i + 1);
  535. g_btnlengpos = 0;
  536. for (i = 9; i < 25; i++)
  537. pRes->rect[i - 9].right = dataarray.ElementAt(i);
  538. for (i = 25; i < 41; i++)
  539. pRes->rect[i - 25].left = dataarray.ElementAt(i);
  540. g_resdata2.nPicCount = dataarray.ElementAt(41);
  541. g_resdata2.nPicCount2 = dataarray.ElementAt(42);
  542. bkleng = dataarray.ElementAt(43);
  543. bkleng2 = dataarray.ElementAt(44);
  544. ENCODE_END
  545. }
  546. if (g_resdata2.bHasBk)
  547. {
  548. BYTE *m_pSaveBk = NULL;
  549. MyBmpButton2::ReadBK(pData, &m_pSaveBk, bkleng);
  550. LoadImageFromBuf(pBk, m_pSaveBk, bkleng);
  551. delete[]m_pSaveBk;
  552. if ((*pBk)->GetWidth() == 633 && (*pBk)->GetHeight() == 50)//picbar
  553. {
  554. }
  555. else if ((*pBk)->GetWidth() == 2000)
  556. {
  557. CRect rc;
  558. HWND wnd = ::FindWindow("Shell_TrayWnd", 0);
  559. ::GetWindowRect(wnd, &rc);
  560. int hei = rc.Height();
  561. rc = CRect(0, 0, g_screenwid, g_screenhei - hei);
  562. g_fscalex = (float)g_screenwid / 2000.0;
  563. g_fscaley = (float)(g_screenhei - hei) / 1400.0;
  564. }
  565. else if ((*pBk)->GetWidth() == 600 && (*pBk)->GetHeight() == 371)
  566. {
  567. g_fscalex = (float)g_screenwid / 1024.0;
  568. g_fscaley = (float)g_screenhei / 768.0;
  569. }
  570. else //if((*pBk)->GetWidth()==1024 )
  571. {
  572. g_fscalex = (float)g_screenwid / 1024.0;
  573. g_fscaley = (float)g_screenhei / 768.0;
  574. }
  575. SizeToContent(hwnd, *pBk);
  576. if ((*pBk)->GetWidth() == 1024 && (*pBk)->GetHeight() == 768)
  577. ::SetWindowPos(hwnd, HWND_TOP, 0, 0, g_screenwid, g_screenhei, SWP_SHOWWINDOW);
  578. if ((*pBk)->GetWidth() == 2000 && (*pBk)->GetHeight() == 1399)
  579. ::SetWindowPos(hwnd, HWND_TOP, 0, 0, g_screenwid, g_screenhei, SWP_SHOWWINDOW);
  580. }
  581. // DeCodePicCount((long&)g_resdata2.nPicCount, (long&)g_resdata2.nPicCount2);
  582. return 1;
  583. }
  584. catch (...)
  585. {
  586. return 0;
  587. }
  588. }
  589. CString GetModifyTime(CString path)
  590. {
  591. HANDLE hFile;
  592. WIN32_FIND_DATA wfd;
  593. // SYSTEMTIME systime;
  594. FILETIME localtime;
  595. CString stime; //输出时间
  596. memset(&wfd, 0, sizeof(wfd));
  597. if ((hFile = FindFirstFile(path, &wfd)) == INVALID_HANDLE_VALUE)
  598. return "";
  599. //ok,转换时间
  600. FileTimeToLocalFileTime(&wfd.ftLastWriteTime, &localtime);
  601. stime.Format("%16d%16d", localtime.dwHighDateTime, localtime.dwLowDateTime);
  602. return stime;
  603. }
  604. BOOL CheckBadWords2(CString str, BOOL bMsg)
  605. {
  606. return 1;
  607. }
  608. inline BOOL WriteLog(CString strLogType, CString strLogOpt, CString strLogGenerant, CString strLogContent)
  609. {
  610. CString strSQL = _T("");
  611. strSQL.Format(_T("insert into [log](log_type, log_opt, log_date, log_generant, log_content) values ('%s', '%s', '%s', '%s', '%s')"),
  612. strLogType,
  613. strLogOpt,
  614. CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")),
  615. strLogGenerant,
  616. strLogContent);
  617. g_sendhead.bsql = TRUE;
  618. g_pMainWnd->ProcessChatMessageRequest2(strSQL);
  619. return g_bSendOK;
  620. }