topbardlg.cpp
资源名称:1731.rar [点击查看]
上传用户:swkcbjrc
上传日期:2016-04-02
资源大小:45277k
文件大小:5k
源码类别:
游戏
开发平台:
Visual C++
- // topbardlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "..GameHigh.h"
- #include "..includetopbardlg.h"
- #include "mainfrm.h"
- #include "macros.h"
- #include "baseFunction.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CTopBarDlg dialog
- CTopBarDlg::CTopBarDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CTopBarDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CTopBarDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- hBkBrush =::CreateSolidBrush(RGB(123, 178, 206));
- }
- CTopBarDlg::~CTopBarDlg()
- {
- SAFE_CHECKPOINTER(hBkBrush)
- {
- ::DeleteObject(hBkBrush);
- hBkBrush =NULL;
- }
- }
- void CTopBarDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CTopBarDlg)
- DDX_Control(pDX, ID_DELACCOUNT, m_DelAccount);
- DDX_Control(pDX, ID_HELPINFO, m_HelpInfo);
- DDX_Control(pDX, ID_MODIFYINFO, m_ModifyInfo);
- DDX_Control(pDX, ID_QUITGAME, m_QuitGame);
- DDX_Control(pDX, ID_PUBLIC, m_Public);
- DDX_Control(pDX, ID_NETWORKTOOL, m_NetworkTool);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CTopBarDlg, CDialog)
- //{{AFX_MSG_MAP(CTopBarDlg)
- ON_WM_PAINT()
- ON_WM_CREATE()
- ON_WM_SIZE()
- ON_BN_CLICKED(ID_QUITGAME, OnQuitgame)
- ON_WM_CTLCOLOR()
- ON_WM_ERASEBKGND()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CTopBarDlg message handlers
- BOOL CTopBarDlg::Create(CWnd* pParentWnd)
- {
- // TODO: Add your specialized code here and/or call the base class
- return CDialog::Create(IDD, pParentWnd);
- }
- void CTopBarDlg::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- CBrush m_Brush;
- COLORREF clrBk =RGB(124, 176, 201);
- m_Brush.CreateSolidBrush(clrBk);
- RECT rect;
- memset(&rect, 0, sizeof(RECT));
- this->GetClientRect(&rect);
- dc.FillRect(&rect, &m_Brush);
- m_Brush.DeleteObject();
- /* memset(&rect, 0, sizeof(RECT));
- CPictureEx* pAdvertWnd =&m_wndAdvertWnd;
- SAFE_CHECKWND(pAdvertWnd)
- {
- pAdvertWnd->GetWindowRect(&rect);
- this->ScreenToClient(&rect);
- LOGBRUSH lb;
- memset(&lb, 0, sizeof(LOGBRUSH));
- lb.lbColor =clrBk;
- lb.lbStyle =BS_NULL;
- CBrush m_Brush;
- m_Brush.CreateBrushIndirect(&lb);
- CBrush* pOldBrush =(CBrush*)dc.SelectObject(&m_Brush);
- CPen m_Pen;
- m_Pen.CreatePen(PS_SOLID, 3, RGB(7,47, 136));
- CPen* pOldPen =(CPen*)dc.SelectObject(&m_Pen);
- dc.Rectangle(&rect);
- dc.SelectObject(pOldBrush);
- dc.SelectObject(pOldPen);
- m_Pen.DeleteObject();
- m_Brush.DeleteObject();
- }
- */
- }
- int CTopBarDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CDialog::OnCreate(lpCreateStruct) == -1)
- return -1;
- RECT rect;
- memset(&rect, 0, sizeof(RECT));
- m_wndShowIpWnd.Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect, this, 0, NULL);
- memset(&rect, 0, sizeof(RECT));
- m_wndAdvertWnd.Create("", WS_VISIBLE | WS_CHILD | SS_CENTER, rect, this, 0);
- char buffer[MAX_PATH];
- memset(buffer, 0, sizeof(char) * MAX_PATH);
- GetCurrentPath(buffer);
- strcat(buffer, "ad\1.gif");
- m_wndAdvertWnd.Load(buffer);
- m_wndAdvertWnd.Draw();
- return 0;
- }
- void CTopBarDlg::OnSize(UINT nType, int cx, int cy)
- {
- CDialog::OnSize(nType, cx, cy);
- int nLeftx =0;
- CPictureEx* pAdvertWnd =&m_wndAdvertWnd;
- SAFE_CHECKWND(pAdvertWnd)
- {
- CSize m_Size =pAdvertWnd->GetSize();
- RECT rect;
- memset(&rect, 0, sizeof(RECT));
- this->GetClientRect(&rect);
- rect.left =2;
- rect.top +=2;
- rect.bottom -=2;
- rect.right =rect.left + m_Size.cx;
- pAdvertWnd->MoveWindow(&rect, TRUE);
- nLeftx =rect.right;
- }
- CWnd* pWnd=&m_wndShowIpWnd;
- SAFE_CHECKWND(pWnd)
- {
- RECT rect;
- memset(&rect, 0, sizeof(RECT));
- this->GetClientRect(&rect);
- rect.left =nLeftx + 2;
- rect.top +=1;
- rect.right =rect.left + 250;
- rect.bottom -=1;
- pWnd->MoveWindow(&rect, TRUE);
- nLeftx =rect.right;
- }
- const int nwidth =65;
- const int nheight =15;
- POINT ptStart;
- memset(&ptStart, 0, sizeof(POINT));
- int nleft1 =nLeftx + 4;
- int nleft2 =nleft1 + 65;
- ptStart.x =nleft1;
- ptStart.y =4;
- FixButtonSize((CWnd*)&m_NetworkTool, ptStart, nwidth, nheight);
- ptStart.x =nleft2;
- ptStart.y =4;
- FixButtonSize((CWnd*)&m_Public, ptStart, nwidth, nheight);
- ptStart.y +=nheight;
- ptStart.x =nleft1;
- FixButtonSize((CWnd*)&m_ModifyInfo, ptStart, nwidth, nheight);
- ptStart.x =nleft2;
- FixButtonSize((CWnd*)&m_DelAccount, ptStart, nwidth, nheight);
- ptStart.y +=nheight;
- ptStart.x =nleft1;
- FixButtonSize((CWnd*)&m_HelpInfo, ptStart, nwidth, nheight);
- ptStart.x =nleft2;
- FixButtonSize((CWnd*)&m_QuitGame, ptStart, nwidth, nheight);
- }
- void CTopBarDlg::FixButtonSize(CWnd* pWnd, POINT& ptStart, int nwidth, int nheight)
- {
- SAFE_CHECKWND(pWnd)
- {
- RECT rect;
- memset(&rect, 0, sizeof(RECT));
- rect.left =ptStart.x;
- rect.top =ptStart.y;
- rect.right =rect.left + nwidth;
- rect.bottom =rect.top + nheight;
- pWnd->MoveWindow(&rect, TRUE);
- }
- }
- void CTopBarDlg::OnQuitgame()
- {
- CWnd* pFrame =::AfxGetMainWnd();
- SAFE_CHECKWND(pFrame)
- {
- pFrame->PostMessage(WM_CLOSE, 0, 0);
- }
- }
- HBRUSH CTopBarDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- return NULL;
- }
- BOOL CTopBarDlg::OnEraseBkgnd(CDC* pDC)
- {
- return TRUE;
- }