topbardlg.cpp
上传用户:swkcbjrc
上传日期:2016-04-02
资源大小:45277k
文件大小:5k
源码类别:

游戏

开发平台:

Visual C++

  1. // topbardlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "..GameHigh.h"
  5. #include "..includetopbardlg.h"
  6. #include "mainfrm.h"
  7. #include "macros.h"
  8. #include "baseFunction.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CTopBarDlg dialog
  16. CTopBarDlg::CTopBarDlg(CWnd* pParent /*=NULL*/)
  17. : CDialog(CTopBarDlg::IDD, pParent)
  18. {
  19. //{{AFX_DATA_INIT(CTopBarDlg)
  20. // NOTE: the ClassWizard will add member initialization here
  21. //}}AFX_DATA_INIT
  22. hBkBrush =::CreateSolidBrush(RGB(123, 178, 206));
  23. }
  24. CTopBarDlg::~CTopBarDlg()
  25. {
  26. SAFE_CHECKPOINTER(hBkBrush)
  27. {
  28. ::DeleteObject(hBkBrush);
  29. hBkBrush =NULL;
  30. }
  31. }
  32. void CTopBarDlg::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CDialog::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CTopBarDlg)
  36. DDX_Control(pDX, ID_DELACCOUNT, m_DelAccount);
  37. DDX_Control(pDX, ID_HELPINFO, m_HelpInfo);
  38. DDX_Control(pDX, ID_MODIFYINFO, m_ModifyInfo);
  39. DDX_Control(pDX, ID_QUITGAME, m_QuitGame);
  40. DDX_Control(pDX, ID_PUBLIC, m_Public);
  41. DDX_Control(pDX, ID_NETWORKTOOL, m_NetworkTool);
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CTopBarDlg, CDialog)
  45. //{{AFX_MSG_MAP(CTopBarDlg)
  46. ON_WM_PAINT()
  47. ON_WM_CREATE()
  48. ON_WM_SIZE()
  49. ON_BN_CLICKED(ID_QUITGAME, OnQuitgame)
  50. ON_WM_CTLCOLOR()
  51. ON_WM_ERASEBKGND()
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CTopBarDlg message handlers
  56. BOOL CTopBarDlg::Create(CWnd* pParentWnd) 
  57. {
  58. // TODO: Add your specialized code here and/or call the base class
  59. return CDialog::Create(IDD, pParentWnd);
  60. }
  61. void CTopBarDlg::OnPaint() 
  62. {
  63. CPaintDC dc(this); // device context for painting
  64. CBrush m_Brush;
  65. COLORREF clrBk =RGB(124, 176, 201);
  66. m_Brush.CreateSolidBrush(clrBk);
  67. RECT rect;
  68. memset(&rect, 0, sizeof(RECT));
  69. this->GetClientRect(&rect);
  70. dc.FillRect(&rect, &m_Brush);
  71. m_Brush.DeleteObject();
  72. /* memset(&rect, 0, sizeof(RECT));
  73. CPictureEx* pAdvertWnd =&m_wndAdvertWnd;
  74. SAFE_CHECKWND(pAdvertWnd)
  75. {
  76. pAdvertWnd->GetWindowRect(&rect);
  77. this->ScreenToClient(&rect);
  78. LOGBRUSH lb;
  79. memset(&lb, 0, sizeof(LOGBRUSH));
  80. lb.lbColor =clrBk;
  81. lb.lbStyle =BS_NULL;
  82. CBrush m_Brush;
  83. m_Brush.CreateBrushIndirect(&lb);
  84. CBrush* pOldBrush =(CBrush*)dc.SelectObject(&m_Brush);
  85. CPen m_Pen;
  86. m_Pen.CreatePen(PS_SOLID, 3, RGB(7,47, 136));
  87. CPen* pOldPen =(CPen*)dc.SelectObject(&m_Pen);
  88. dc.Rectangle(&rect);
  89. dc.SelectObject(pOldBrush);
  90. dc.SelectObject(pOldPen);
  91. m_Pen.DeleteObject();
  92. m_Brush.DeleteObject();
  93. }
  94. */
  95. }
  96. int CTopBarDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  97. {
  98. if (CDialog::OnCreate(lpCreateStruct) == -1)
  99. return -1;
  100. RECT rect;
  101. memset(&rect, 0, sizeof(RECT));
  102. m_wndShowIpWnd.Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect, this, 0, NULL);
  103. memset(&rect, 0, sizeof(RECT));
  104. m_wndAdvertWnd.Create("", WS_VISIBLE | WS_CHILD | SS_CENTER, rect, this, 0);
  105. char buffer[MAX_PATH];
  106. memset(buffer, 0, sizeof(char) * MAX_PATH);
  107. GetCurrentPath(buffer);
  108. strcat(buffer, "ad\1.gif");
  109. m_wndAdvertWnd.Load(buffer);
  110. m_wndAdvertWnd.Draw();
  111. return 0;
  112. }
  113. void CTopBarDlg::OnSize(UINT nType, int cx, int cy) 
  114. {
  115. CDialog::OnSize(nType, cx, cy);
  116. int nLeftx =0;
  117. CPictureEx* pAdvertWnd =&m_wndAdvertWnd;
  118. SAFE_CHECKWND(pAdvertWnd)
  119. {
  120. CSize m_Size =pAdvertWnd->GetSize();
  121. RECT rect;
  122. memset(&rect, 0, sizeof(RECT));
  123. this->GetClientRect(&rect);
  124. rect.left =2;
  125. rect.top +=2;
  126. rect.bottom -=2;
  127. rect.right =rect.left + m_Size.cx;
  128. pAdvertWnd->MoveWindow(&rect, TRUE);
  129. nLeftx =rect.right;
  130. }
  131. CWnd* pWnd=&m_wndShowIpWnd;
  132. SAFE_CHECKWND(pWnd)
  133. {
  134. RECT rect;
  135. memset(&rect, 0, sizeof(RECT));
  136. this->GetClientRect(&rect);
  137. rect.left =nLeftx + 2;
  138. rect.top +=1;
  139. rect.right =rect.left + 250;
  140. rect.bottom -=1;
  141. pWnd->MoveWindow(&rect, TRUE);
  142. nLeftx =rect.right;
  143. }
  144. const int nwidth =65;
  145. const int nheight =15;
  146. POINT ptStart;
  147. memset(&ptStart, 0, sizeof(POINT));
  148. int nleft1 =nLeftx + 4;
  149. int nleft2 =nleft1 + 65;
  150. ptStart.x =nleft1;
  151. ptStart.y =4;
  152. FixButtonSize((CWnd*)&m_NetworkTool, ptStart, nwidth, nheight);
  153. ptStart.x =nleft2;
  154. ptStart.y =4;
  155. FixButtonSize((CWnd*)&m_Public, ptStart, nwidth, nheight);
  156. ptStart.y +=nheight;
  157. ptStart.x =nleft1;
  158. FixButtonSize((CWnd*)&m_ModifyInfo, ptStart, nwidth, nheight);
  159. ptStart.x =nleft2;
  160. FixButtonSize((CWnd*)&m_DelAccount, ptStart, nwidth, nheight);
  161. ptStart.y +=nheight;
  162. ptStart.x =nleft1;
  163. FixButtonSize((CWnd*)&m_HelpInfo, ptStart, nwidth, nheight);
  164. ptStart.x =nleft2;
  165. FixButtonSize((CWnd*)&m_QuitGame, ptStart, nwidth, nheight);
  166. }
  167. void CTopBarDlg::FixButtonSize(CWnd* pWnd, POINT& ptStart, int nwidth, int nheight)
  168. {
  169. SAFE_CHECKWND(pWnd)
  170. {
  171. RECT rect;
  172. memset(&rect, 0, sizeof(RECT));
  173. rect.left =ptStart.x;
  174. rect.top =ptStart.y;
  175. rect.right =rect.left + nwidth;
  176. rect.bottom =rect.top + nheight;
  177. pWnd->MoveWindow(&rect, TRUE);
  178. }
  179. }
  180. void CTopBarDlg::OnQuitgame() 
  181. {
  182. CWnd* pFrame =::AfxGetMainWnd();
  183. SAFE_CHECKWND(pFrame)
  184. {
  185. pFrame->PostMessage(WM_CLOSE, 0, 0);
  186. }
  187. }
  188. HBRUSH CTopBarDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
  189. {
  190. return NULL;
  191. }
  192. BOOL CTopBarDlg::OnEraseBkgnd(CDC* pDC) 
  193. {
  194. return TRUE;
  195. }