CMainWnd.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. #include "../pch/pch.h"
  2. #include "CMainWnd.h"
  3. #include "CLoginWnd.h"
  4. #include "../control/ControlEx.h"
  5. #include "../page/CWaimaiOrderInfoPageUI.h"
  6. #include "../network/CMessagePush.h"
  7. #include <urlmon.h>
  8. void CMainWnd::Init()
  9. {
  10. m_pCloseBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("closebtn")));
  11. m_pMaxBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("maxbtn")));
  12. m_pRestoreBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("restorebtn")));
  13. m_pMinBtn = static_cast<CButtonUI*>(m_pm.FindControl(_T("minbtn")));
  14. //默认选择点单页面
  15. this->SwitchPage(DIANDAN);
  16. //登录成功,启动消息和任务处理
  17. m_push = new CMessagePush(m_hWnd);
  18. m_push->Start();
  19. //启动一个线程,开始同步商品图片
  20. std::thread(&CMainWnd::UpdateFoodImage, this).detach();
  21. }
  22. void CMainWnd::UpdateFoodImage()
  23. {
  24. //先判断并创建临时目录
  25. string folderPath = CLewaimaiString::UnicodeToANSI(CSystem::GetProgramDir()) + "\\tmp\\image";
  26. std::wstring ws_folderPath = CLewaimaiString::ANSIToUnicode(folderPath);
  27. if (!CSystem::IsDirExist(ws_folderPath))
  28. {
  29. LOG_INFO("folderPath:" << folderPath.c_str() << ",没有找到对应的目录,即将创建");
  30. CSystem::CreateMultiLevel(folderPath);
  31. }
  32. CSqlite3 sqlite;
  33. std::vector<CFood> foodlist = sqlite.GetFoodByTypeid("0", true);
  34. for (std::vector<CFood>::iterator it = foodlist.begin(); it != foodlist.end(); it++)
  35. {
  36. CFood food = *it;
  37. if (food.goods_img.size() == 0)
  38. {
  39. //没有图片,直接跳过
  40. continue;
  41. }
  42. std::wstring ws_goods_img = food.getImageUrl();
  43. ws_goods_img += L"!max200"; //下载小图
  44. wstring imagePath = food.getImageTmpPath();
  45. if (CSystem::IsFileExist(imagePath))
  46. {
  47. //如果图片文件已经存在,直接跳过
  48. continue;
  49. }
  50. //图片还不存在,开始下载
  51. if (URLDownloadToFile(NULL, ws_goods_img.c_str(), imagePath.c_str(), 0, NULL) == S_OK)
  52. {
  53. //图片下载成功了,发个消息,更新图片
  54. }
  55. else
  56. {
  57. LOG_INFO("URLDownloadToFile Fail,Error"<<GetLastError());
  58. }
  59. }
  60. //再处理商品套餐的图片
  61. std::vector<CFoodpackage> foodpackagelist = sqlite.GetFoodpackages(true);
  62. for (std::vector<CFoodpackage>::iterator it = foodpackagelist.begin(); it != foodpackagelist.end(); it++)
  63. {
  64. CFoodpackage food = *it;
  65. if (food.goods_img.size() == 0)
  66. {
  67. //没有图片,直接跳过
  68. continue;
  69. }
  70. std::wstring ws_goods_img = food.getImageUrl();
  71. ws_goods_img += L"!max200"; //下载小图
  72. wstring imagePath = food.getImageTmpPath();
  73. if (CSystem::IsFileExist(imagePath))
  74. {
  75. //如果图片文件已经存在,直接跳过
  76. continue;
  77. }
  78. //图片还不存在,开始下载
  79. if (URLDownloadToFile(NULL, ws_goods_img.c_str(), imagePath.c_str(), 0, NULL) == S_OK)
  80. {
  81. //图片下载成功了,发个消息,更新图片
  82. }
  83. else
  84. {
  85. LOG_INFO("URLDownloadToFile Fail,Error" << GetLastError());
  86. }
  87. }
  88. }
  89. void CMainWnd::SwitchPage(MainPageName name)
  90. {
  91. if (m_curPageName == name)
  92. {
  93. return;
  94. }
  95. //先删除现在的子对象
  96. CContainerUI* pMainContentLayout = static_cast<CContainerUI*>(m_pm.FindControl(_T("main_content_layout")));
  97. pMainContentLayout->RemoveAll();
  98. //再创建一个对象
  99. CDialogBuilder builder;
  100. CDialogBuilderCallbackEx cb;
  101. CBasePageUI* pChildContainer = NULL;
  102. //注意事项:所有的子页面中的option不能带有selected="true"属性,如果带有这个属性,在下面的Create调用的时候就直接会生成一个selectchanged事件,但是这个时候
  103. //页面才刚刚Create,还没加入到窗口中,相关的变量对应关系也还没设置成功,会导致事件处理对象出现问题
  104. if (name == DIANDAN)
  105. {
  106. pChildContainer = static_cast<CBasePageUI*>(builder.Create(_T("diandan_page.xml"), (UINT)0, &cb, &m_pm));
  107. }
  108. else if (name == DINGDAN)
  109. {
  110. pChildContainer = static_cast<CBasePageUI*>(builder.Create(_T("waimaiorder_list_page.xml"), (UINT)0, &cb, &m_pm));
  111. }
  112. else if (name == SHEZHI)
  113. {
  114. pChildContainer = static_cast<CBasePageUI*>(builder.Create(_T("setting_page.xml"), (UINT)0, &cb, &m_pm));
  115. }
  116. else if (name == WAIMAIINFO)
  117. {
  118. pChildContainer = static_cast<CBasePageUI*>(builder.Create(_T("waimaiorder_info_page.xml"), (UINT)0, &cb, &m_pm));
  119. CWaimaiOrderInfoPageUI* pInfoPage = static_cast<CWaimaiOrderInfoPageUI*>(pChildContainer);
  120. pInfoPage->m_order_id = m_infopage_waimaiorder_id;
  121. pInfoPage->m_order_no = m_infopage_waimaiorder_no;
  122. }
  123. pChildContainer->SetMainWnd(this);
  124. pMainContentLayout->Add(pChildContainer);
  125. m_curPageName = name;
  126. m_curPageUI = pChildContainer;
  127. pChildContainer->InitShow();
  128. }
  129. LRESULT CMainWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  130. {
  131. LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
  132. styleValue &= ~WS_CAPTION;
  133. ::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
  134. m_pm.Init(m_hWnd);
  135. CDialogBuilder builder;
  136. CDialogBuilderCallbackEx cb;
  137. CControlUI* pRoot = builder.Create(_T("main.xml"), (UINT)0, &cb, &m_pm);
  138. ASSERT(pRoot && "Failed to parse XML");
  139. m_pm.AttachDialog(pRoot);
  140. m_pm.AddNotifier(this);
  141. Init();
  142. return 0;
  143. }
  144. void CMainWnd::Notify(TNotifyUI& msg)
  145. {
  146. if(msg.sType == _T("windowinit"))
  147. {
  148. }
  149. else if(msg.sType == _T("click"))
  150. {
  151. HandleClickMsg(msg);
  152. }
  153. else if(msg.sType == _T("selectchanged"))
  154. {
  155. HandleSelectChangeMsg(msg);
  156. }
  157. else if(msg.sType == _T("itemclick"))
  158. {
  159. }
  160. else if(msg.sType == _T("itemactivate"))
  161. {
  162. }
  163. else if(msg.sType == _T("itemselect"))
  164. {
  165. HandleItemSelectMsg(msg);
  166. }
  167. }
  168. void CMainWnd::HandleClickMsg(TNotifyUI& msg)
  169. {
  170. if(msg.pSender == m_pCloseBtn)
  171. {
  172. if(CSetting::GetParam("setting_is_close_min") == "1")
  173. {
  174. AddTrayIcon();
  175. }
  176. else
  177. {
  178. PostQuitMessage(0);
  179. }
  180. return;
  181. }
  182. else if(msg.pSender == m_pMinBtn)
  183. {
  184. SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
  185. return;
  186. }
  187. else if(msg.pSender == m_pMaxBtn)
  188. {
  189. SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
  190. return;
  191. }
  192. else if(msg.pSender == m_pRestoreBtn)
  193. {
  194. SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
  195. return;
  196. }
  197. CDuiString name = msg.pSender->GetName();
  198. if(name == _T("quitbtn"))
  199. {
  200. /*Close()*/
  201. PostQuitMessage(0); // 因为activex的原因,使用close可能会出现错误
  202. }
  203. else
  204. {
  205. this->m_curPageUI->HandleClickMsg(msg);
  206. }
  207. }
  208. /**
  209. * 这个处理Option的切换
  210. */
  211. void CMainWnd::HandleSelectChangeMsg(TNotifyUI& msg)
  212. {
  213. CDuiString name = msg.pSender->GetName();
  214. //先判断主页面的tab
  215. if (name == _T("main_diandan"))
  216. {
  217. this->SwitchPage(DIANDAN);
  218. }
  219. else if(name == _T("main_waimai"))
  220. {
  221. this->SwitchPage(DINGDAN);
  222. }
  223. else if(name == _T("main_setting"))
  224. {
  225. this->SwitchPage(SHEZHI);
  226. }
  227. else
  228. {
  229. //除了主界面固定区域的事件,其他的事件全部分发给子页面
  230. this->m_curPageUI->HandleSelectChangeMsg(msg);
  231. }
  232. }
  233. void CMainWnd::HandleItemSelectMsg(TNotifyUI& msg)
  234. {
  235. this->m_curPageUI->HandleItemSelectMsg(msg);
  236. }
  237. LRESULT CMainWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
  238. {
  239. LRESULT lRes = 0;
  240. BOOL bHandled = TRUE;
  241. switch(uMsg)
  242. {
  243. case WM_CREATE:
  244. lRes = OnCreate(uMsg, wParam, lParam, bHandled);
  245. break;
  246. case WM_CLOSE:
  247. lRes = OnClose(uMsg, wParam, lParam, bHandled);
  248. break;
  249. case WM_DESTROY:
  250. lRes = OnDestroy(uMsg, wParam, lParam, bHandled);
  251. break;
  252. case WM_NCACTIVATE:
  253. lRes = OnNcActivate(uMsg, wParam, lParam, bHandled);
  254. break;
  255. case WM_NCCALCSIZE:
  256. lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled);
  257. break;
  258. case WM_NCPAINT:
  259. lRes = OnNcPaint(uMsg, wParam, lParam, bHandled);
  260. break;
  261. case WM_NCHITTEST:
  262. lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled);
  263. break;
  264. case WM_SIZE:
  265. lRes = OnSize(uMsg, wParam, lParam, bHandled);
  266. break;
  267. case WM_GETMINMAXINFO:
  268. lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled);
  269. break;
  270. case WM_SYSCOMMAND:
  271. lRes = OnSysCommand(uMsg, wParam, lParam, bHandled);
  272. break;
  273. case WM_SHOWTASK:
  274. lRes = OnTrayIcon(uMsg, wParam, lParam, bHandled);
  275. break;
  276. default:
  277. bHandled = FALSE;
  278. }
  279. if(bHandled)
  280. {
  281. return lRes;
  282. }
  283. //走到这里,说明消息还没有处理,应该是自定义的消息
  284. bool ret = this->HandleCustomMessage(uMsg, wParam, lParam);
  285. if (ret)
  286. {
  287. //自定义消息已经处理
  288. return 0;
  289. }
  290. if(m_pm.MessageHandler(uMsg, wParam, lParam, lRes))
  291. {
  292. return lRes;
  293. }
  294. return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
  295. }
  296. bool CMainWnd::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
  297. {
  298. if (uMsg == WM_ORDERLIST_REFRESH)
  299. {
  300. if (m_curPageName != DINGDAN)
  301. {
  302. return true;
  303. }
  304. static_cast<CWaimaiOrderListPageUI*>(this->m_curPageUI)->DoRefresh();
  305. return true;
  306. }
  307. else if (uMsg == WM_LOGIN_AGAIN_OUT)
  308. {
  309. LoginOut(2);
  310. return true;
  311. }
  312. return false;
  313. }
  314. LRESULT CMainWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
  315. {
  316. return false;
  317. }
  318. LRESULT CMainWnd::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  319. {
  320. // 有时会在收到WM_NCDESTROY后收到wParam为SC_CLOSE的WM_SYSCOMMAND
  321. if(wParam == SC_CLOSE)
  322. {
  323. ::PostQuitMessage(0L);
  324. bHandled = TRUE;
  325. return 0;
  326. }
  327. BOOL bZoomed = ::IsZoomed(*this);
  328. LRESULT lRes = CWindowWnd::HandleMessage(uMsg, wParam, lParam);
  329. if(::IsZoomed(*this) != bZoomed)
  330. {
  331. if(!bZoomed)
  332. {
  333. CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn")));
  334. if(pControl)
  335. {
  336. pControl->SetVisible(false);
  337. }
  338. pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn")));
  339. if(pControl)
  340. {
  341. pControl->SetVisible(true);
  342. }
  343. }
  344. else
  345. {
  346. CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("maxbtn")));
  347. if(pControl)
  348. {
  349. pControl->SetVisible(true);
  350. }
  351. pControl = static_cast<CControlUI*>(m_pm.FindControl(_T("restorebtn")));
  352. if(pControl)
  353. {
  354. pControl->SetVisible(false);
  355. }
  356. }
  357. }
  358. return lRes;
  359. }
  360. LRESULT CMainWnd::OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  361. {
  362. int primaryMonitorWidth = ::GetSystemMetrics(SM_CXSCREEN);
  363. int primaryMonitorHeight = ::GetSystemMetrics(SM_CYSCREEN);
  364. MONITORINFO oMonitor = {};
  365. oMonitor.cbSize = sizeof(oMonitor);
  366. ::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTOPRIMARY), &oMonitor);
  367. CDuiRect rcWork = oMonitor.rcWork;
  368. rcWork.Offset(-oMonitor.rcMonitor.left, -oMonitor.rcMonitor.top);
  369. if(rcWork.right > primaryMonitorWidth)
  370. {
  371. rcWork.right = primaryMonitorWidth;
  372. }
  373. if(rcWork.bottom > primaryMonitorHeight)
  374. {
  375. rcWork.right = primaryMonitorHeight;
  376. }
  377. LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
  378. lpMMI->ptMaxPosition.x = rcWork.left;
  379. lpMMI->ptMaxPosition.y = rcWork.top;
  380. lpMMI->ptMaxSize.x = rcWork.right;
  381. lpMMI->ptMaxSize.y = rcWork.bottom;
  382. bHandled = FALSE;
  383. return 0;
  384. }
  385. LRESULT CMainWnd::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  386. {
  387. SIZE szRoundCorner = m_pm.GetRoundCorner();
  388. if(!::IsIconic(*this) && (szRoundCorner.cx != 0 || szRoundCorner.cy != 0))
  389. {
  390. CDuiRect rcWnd;
  391. ::GetWindowRect(*this, &rcWnd);
  392. rcWnd.Offset(-rcWnd.left, -rcWnd.top);
  393. rcWnd.right++;
  394. rcWnd.bottom++;
  395. HRGN hRgn = ::CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, szRoundCorner.cx, szRoundCorner.cy);
  396. ::SetWindowRgn(*this, hRgn, TRUE);
  397. ::DeleteObject(hRgn);
  398. }
  399. bHandled = FALSE;
  400. return 0;
  401. }
  402. LRESULT CMainWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  403. {
  404. bHandled = FALSE;
  405. return 0;
  406. }
  407. /*
  408. *这个是窗口被销毁的时候调用的
  409. **/
  410. LRESULT CMainWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  411. {
  412. //直接退出程序,或者退出登录都会执行这个
  413. m_push->Stop();
  414. bHandled = FALSE;
  415. return 0;
  416. }
  417. LRESULT CMainWnd::OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  418. {
  419. if(::IsIconic(*this))
  420. {
  421. bHandled = FALSE;
  422. }
  423. return (wParam == 0) ? TRUE : FALSE;
  424. }
  425. LRESULT CMainWnd::OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  426. {
  427. return 0;
  428. }
  429. LRESULT CMainWnd::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  430. {
  431. return 0;
  432. }
  433. LRESULT CMainWnd::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  434. {
  435. POINT pt;
  436. pt.x = GET_X_LPARAM(lParam);
  437. pt.y = GET_Y_LPARAM(lParam);
  438. ::ScreenToClient(*this, &pt);
  439. RECT rcClient;
  440. ::GetClientRect(*this, &rcClient);
  441. if(!::IsZoomed(*this))
  442. {
  443. RECT rcSizeBox = m_pm.GetSizeBox();
  444. if(pt.y < rcClient.top + rcSizeBox.top)
  445. {
  446. if(pt.x < rcClient.left + rcSizeBox.left)
  447. {
  448. return HTTOPLEFT;
  449. }
  450. if(pt.x > rcClient.right - rcSizeBox.right)
  451. {
  452. return HTTOPRIGHT;
  453. }
  454. return HTTOP;
  455. }
  456. else if(pt.y > rcClient.bottom - rcSizeBox.bottom)
  457. {
  458. if(pt.x < rcClient.left + rcSizeBox.left)
  459. {
  460. return HTBOTTOMLEFT;
  461. }
  462. if(pt.x > rcClient.right - rcSizeBox.right)
  463. {
  464. return HTBOTTOMRIGHT;
  465. }
  466. return HTBOTTOM;
  467. }
  468. if(pt.x < rcClient.left + rcSizeBox.left)
  469. {
  470. return HTLEFT;
  471. }
  472. if(pt.x > rcClient.right - rcSizeBox.right)
  473. {
  474. return HTRIGHT;
  475. }
  476. }
  477. RECT rcCaption = m_pm.GetCaptionRect();
  478. if(pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right \
  479. && pt.y >= rcCaption.top && pt.y < rcCaption.bottom)
  480. {
  481. CControlUI* pControl = static_cast<CControlUI*>(m_pm.FindControl(pt));
  482. if(pControl && _tcscmp(pControl->GetClass(), DUI_CTR_BUTTON) != 0 &&
  483. _tcscmp(pControl->GetClass(), DUI_CTR_OPTION) != 0 &&
  484. _tcscmp(pControl->GetClass(), DUI_CTR_TEXT) != 0)
  485. {
  486. return HTCAPTION;
  487. }
  488. }
  489. return HTCLIENT;
  490. }
  491. void CMainWnd::AddTrayIcon()
  492. {
  493. memset(&m_trayIcon, 0, sizeof(NOTIFYICONDATA));
  494. m_trayIcon.cbSize = sizeof(NOTIFYICONDATA);
  495. m_trayIcon.hIcon = ::LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON_DUILIB));
  496. m_trayIcon.hWnd = m_hWnd;
  497. lstrcpy(m_trayIcon.szTip, _T("智铺子收银系统"));
  498. m_trayIcon.uCallbackMessage = WM_SHOWTASK;
  499. m_trayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
  500. Shell_NotifyIcon(NIM_ADD, &m_trayIcon);
  501. ShowWindow(SW_HIDE);
  502. }
  503. LRESULT CMainWnd::OnTrayIcon(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  504. {
  505. //如果在图标中单击左键则还原
  506. if(lParam == WM_LBUTTONDOWN)
  507. {
  508. //删除托盘图标
  509. Shell_NotifyIcon(NIM_DELETE, &m_trayIcon);
  510. //显示主窗口
  511. ShowWindow(SW_SHOWNORMAL);
  512. //窗口最大化
  513. SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
  514. }
  515. //如果在图标中单击右键则弹出声明式菜单
  516. if(lParam == WM_RBUTTONDOWN)
  517. {
  518. //获取鼠标坐标
  519. POINT pt;
  520. GetCursorPos(&pt);
  521. //右击后点别地可以清除“右击出来的菜单”
  522. SetForegroundWindow(m_hWnd);
  523. //托盘菜单 win32程序使用的是HMENU,如果是MFC程序可以使用CMenu
  524. HMENU hMenu;
  525. //生成托盘菜单
  526. hMenu = CreatePopupMenu();
  527. //添加菜单,关键在于设置的一个标识符 WM_ONCLOSE 点击后会用到
  528. AppendMenu(hMenu, MF_STRING, WM_ONCLOSE, _T("退出"));
  529. //弹出菜单,并把用户所选菜单项的标识符返回
  530. int cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, NULL, m_hWnd, NULL);
  531. //如果标识符是WM_ONCLOSE则关闭
  532. if(cmd == WM_ONCLOSE)
  533. {
  534. m_trayIcon.hIcon = NULL;
  535. Shell_NotifyIcon(NIM_DELETE, &m_trayIcon);
  536. //退出程序
  537. ::PostQuitMessage(0);
  538. }
  539. }
  540. bHandled = true;
  541. return 0;
  542. }
  543. void CMainWnd::LoginOut(int mode)
  544. {
  545. CSetting::SetParam("setting_is_auto_login", "0", true);
  546. CLoginWnd* pLogin = new CLoginWnd();
  547. if(pLogin == NULL)
  548. {
  549. return;
  550. }
  551. //设置模式
  552. pLogin->SetMode(mode);
  553. pLogin->Create(NULL, _T("智铺子收银系统登录"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
  554. pLogin->SetIcon(IDI_ICON_DUILIB);
  555. pLogin->CenterWindow();
  556. ::ShowWindow(*pLogin, SW_SHOWNORMAL);
  557. Close();
  558. }
  559. CMessagePush* CMainWnd::getMessagePush()
  560. {
  561. return m_push;
  562. }
  563. void CMainWnd::SetInfopageWaimaiorderParam(std::string order_id, std::string order_no)
  564. {
  565. m_infopage_waimaiorder_id = order_id;
  566. m_infopage_waimaiorder_no = order_no;
  567. }