ProcessADlg.cpp
上传用户:xinsanhua
上传日期:2022-05-17
资源大小:80k
文件大小:6k
源码类别:

通讯编程

开发平台:

Visual C++

  1. #include "..processbprocessbdlg.cpp"
  2. // ProcessADlg.cpp : 备泅 颇老
  3. //
  4. #include "stdafx.h"
  5. #include "ProcessA.h"
  6. #include "ProcessADlg.h"
  7. #include ".processadlg.h"
  8. #include "BookInfo.h"
  9. #include "Protocol.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #endif
  13. // 览侩 橇肺弊伐 沥焊俊 荤侩登绰 CAboutDlg 措拳 惑磊涝聪促.
  14. class CAboutDlg : public CDialog
  15. {
  16. public:
  17. CAboutDlg();
  18. // 措拳 惑磊 单捞磐
  19. enum { IDD = IDD_ABOUTBOX };
  20. protected:
  21. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 瘤盔
  22. // 备泅
  23. protected:
  24. DECLARE_MESSAGE_MAP()
  25. // virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  26. };
  27. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  28. {
  29. }
  30. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. }
  34. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  35. // ON_WM_COPYDATA()
  36. END_MESSAGE_MAP()
  37. // CProcessADlg 措拳 惑磊
  38. CProcessADlg::CProcessADlg(CWnd* pParent /*=NULL*/)
  39. : CDialog(CProcessADlg::IDD, pParent)
  40. {
  41. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  42. }
  43. void CProcessADlg::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CDialog::DoDataExchange(pDX);
  46. }
  47. BEGIN_MESSAGE_MAP(CProcessADlg, CDialog)
  48. ON_WM_SYSCOMMAND()
  49. ON_WM_PAINT()
  50. ON_WM_QUERYDRAGICON()
  51. //}}AFX_MSG_MAP
  52. ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
  53. ON_WM_COPYDATA()
  54. END_MESSAGE_MAP()
  55. // CProcessADlg 皋矫瘤 贸府扁
  56. BOOL CProcessADlg::OnInitDialog()
  57. {
  58. CDialog::OnInitDialog();
  59. // 矫胶袍 皋春俊 "沥焊..." 皋春 亲格阑 眠啊钦聪促.
  60. // IDM_ABOUTBOX绰 矫胶袍 疙飞 裹困俊 乐绢具 钦聪促.
  61. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  62. ASSERT(IDM_ABOUTBOX < 0xF000);
  63. CMenu* pSysMenu = GetSystemMenu(FALSE);
  64. if (pSysMenu != NULL)
  65. {
  66. CString strAboutMenu;
  67. strAboutMenu.LoadString(IDS_ABOUTBOX);
  68. if (!strAboutMenu.IsEmpty())
  69. {
  70. pSysMenu->AppendMenu(MF_SEPARATOR);
  71. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  72. }
  73. }
  74. // 捞 措拳 惑磊狼 酒捞能阑 汲沥钦聪促. 览侩 橇肺弊伐狼 林 芒捞 措拳 惑磊啊 酒匆 版快俊绰
  75. // 橇饭烙况农啊 捞 累诀阑 磊悼栏肺 荐青钦聪促.
  76. SetIcon(m_hIcon, TRUE); // 奴 酒捞能阑 汲沥钦聪促.
  77. SetIcon(m_hIcon, FALSE); // 累篮 酒捞能阑 汲沥钦聪促.
  78. // TODO: 咯扁俊 眠啊 檬扁拳 累诀阑 眠啊钦聪促.
  79. return TRUE;  // 牧飘费俊 措茄 器目胶甫 汲沥窍瘤 臼阑 版快 TRUE甫 馆券钦聪促.
  80. }
  81. void CProcessADlg::OnSysCommand(UINT nID, LPARAM lParam)
  82. {
  83. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  84. {
  85. CAboutDlg dlgAbout;
  86. dlgAbout.DoModal();
  87. }
  88. else
  89. {
  90. CDialog::OnSysCommand(nID, lParam);
  91. }
  92. }
  93. // 措拳 惑磊俊 弥家拳 窜眠甫 眠啊且 版快 酒捞能阑 弊府妨搁 
  94. // 酒贰 内靛啊 鞘夸钦聪促. 巩辑/轰 葛胆阑 荤侩窍绰 MFC 览侩 橇肺弊伐狼 版快俊绰
  95. // 橇饭烙况农俊辑 捞 累诀阑 磊悼栏肺 荐青钦聪促.
  96. void CProcessADlg::OnPaint() 
  97. {
  98. if (IsIconic())
  99. {
  100. CPaintDC dc(this); // 弊府扁甫 困茄 叼官捞胶 牧咆胶飘
  101. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  102. // 努扼捞攫飘 荤阿屈俊辑 酒捞能阑 啊款单俊 嘎娩聪促.
  103. int cxIcon = GetSystemMetrics(SM_CXICON);
  104. int cyIcon = GetSystemMetrics(SM_CYICON);
  105. CRect rect;
  106. GetClientRect(&rect);
  107. int x = (rect.Width() - cxIcon + 1) / 2;
  108. int y = (rect.Height() - cyIcon + 1) / 2;
  109. // 酒捞能阑 弊赋聪促.
  110. dc.DrawIcon(x, y, m_hIcon);
  111. }
  112. else
  113. {
  114. CDialog::OnPaint();
  115. }
  116. }
  117. // 荤侩磊啊 弥家拳等 芒阑 掺绰 悼救俊 目辑啊 钎矫登档废 矫胶袍俊辑
  118. //  捞 窃荐甫 龋免钦聪促. 
  119. HCURSOR CProcessADlg::OnQueryDragIcon()
  120. {
  121. return static_cast<HCURSOR>(m_hIcon);
  122. }
  123. BOOL CProcessADlg::PreTranslateMessage(MSG* pMsg)
  124. {
  125. // TODO: Add your specialized code here and/or call the base class
  126. switch(pMsg->message)
  127. {
  128. case WM_KEYDOWN:
  129. {
  130. switch(pMsg->wParam)
  131. {
  132. case VK_ESCAPE:
  133. case VK_RETURN:
  134. return TRUE;
  135. }
  136. }
  137. }
  138. return CDialog::PreTranslateMessage(pMsg);
  139. }
  140. void CProcessADlg::OnBnClickedButton1()
  141. {
  142. // TODO: Add your control notification handler code here
  143. //
  144. // 单捞磐甫 傈价 且 橇肺技胶狼 勤甸阑 捞侩窍扁 困秦 扩档快 按眉甫 掘绢 可聪促.
  145. //
  146. CWnd* pWnd = FindWindow(NULL, "ProcessB");
  147. ASSERT(pWnd);
  148. //
  149. // 傈价且 单捞磐甫 悸泼钦聪促.
  150. //
  151. BookInfo bookInfo = {1000, {0, }};
  152. TCHAR* szName = _T("Keep going ..");
  153. bookInfo.m_nID = 1000;
  154. _tcsncpy(bookInfo.m_szName, szName, _tcslen(szName));
  155. //
  156. // 傈价且 单捞磐甫 COPYDATASTURCT俊 悸泼窍绊 傈价钦聪促.
  157. //
  158. COPYDATASTRUCT cds;
  159. cds.dwData = Protocol::PROTOCOL_BOOKINFO;
  160. cds.cbData = sizeof(bookInfo);
  161. cds.lpData = (LPVOID)&bookInfo;
  162. ::SendMessage(pWnd->m_hWnd, WM_COPYDATA, (WPARAM)GetSafeHwnd(), (LPARAM)&cds);
  163. }
  164. LRESULT CProcessADlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  165. {
  166. // TODO: Add your specialized code here and/or call the base class
  167. switch(message)
  168. {
  169. case WM_COPYDATA:
  170. {
  171. PCOPYDATASTRUCT pcds = (PCOPYDATASTRUCT) lParam;
  172. //
  173. // 橇肺配妮俊 蝶弗 贸府甫 困秦辑 ..
  174. //
  175. switch(pcds->dwData)
  176. {
  177. case Protocol::PROTOCOL_BOOKINFO:
  178. {
  179. //
  180. // 傈价罐篮 单捞磐(COPYDATASTRUCT 备炼眉)甫 钱绢辑 BookInfo俊 悸泼钦聪促.
  181. //
  182. BookInfo bookInfo;
  183. bookInfo.m_nID = ((BookInfo*)pcds->lpData)->m_nID;
  184. _tcsncpy(bookInfo.m_szName, ((BookInfo*)pcds->lpData)->m_szName, pcds->cbData - sizeof(int));
  185. //
  186. // 傈价罐篮 单捞磐甫 皋矫瘤 冠胶甫 免仿钦聪促.
  187. //
  188. CString strReceiveMsg;
  189. strReceiveMsg.Format(_T("ID : %dtName : %s"), bookInfo.m_nID, bookInfo.m_szName);
  190. AfxMessageBox(strReceiveMsg);
  191. break;
  192. }
  193. case Protocol::PROTOCOL_COOKINFO:
  194. {
  195. // Do something ..
  196. break;
  197. }
  198. }
  199. }
  200. }
  201. return CDialog::WindowProc(message, wParam, lParam);
  202. }