aa

MoveWindow(0,0,925,620);
 GetDlgItem(IDC_STATIC_MAP)->MoveWindow(0,0,650,575,TRUE);

 GetDlgItem(IDC_STATIC_FLOOR)->MoveWindow(660,0,230,12,TRUE);
 GetDlgItem(IDC_STATIC_SMALLMAP)->MoveWindow(660,13,250,50,TRUE);
 
 GetDlgItem(IDC_STATIC_OBJECT)->MoveWindow(660,70,230,12,TRUE);
 GetDlgItem(IDC_STATIC_OBJECT_BOX)->MoveWindow(660,85,250,375,TRUE);

 GetDlgItem(IDC_STATIC_PLAYER)->MoveWindow(660,462,50,12,TRUE);
 GetDlgItem(IDC_STATIC_PLAYER_BOX)->MoveWindow(660,475,75,75,TRUE);

 GetDlgItem(IDC_STATIC_ATTR)->MoveWindow(740,462,50,12,TRUE);
 GetDlgItem(IDC_STATIC_ATTR_BOX)->MoveWindow(740,475,170,75,TRUE);
 
 GetDlgItem(IDC_BUTTON_NEW)->MoveWindow(663,553,80,19,TRUE);
 GetDlgItem(IDC_BUTTON_EDIT)->MoveWindow(745,553,80,19,TRUE);
 GetDlgItem(IDC_BUTTON_SAVE)->MoveWindow(827,553,80,19,TRUE);
 
 GetDlgItem(IDC_STATIC_STATUS)->MoveWindow(0,576,160,19,TRUE);
 GetDlgItem(IDC_PROGRESS)->MoveWindow(162,576,300,19,TRUE);
 GetDlgItem(IDC_BUTTON_HELP)->MoveWindow(470,576,60,19,TRUE);
 GetDlgItem(IDC_STATIC_COPYRIGHT)->MoveWindow(530,576,380,19,TRUE);
 
 // Add "About..." menu item to system menu.

 // IDM_ABOUTBOX must be in the system command range.
 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
 ASSERT(IDM_ABOUTBOX < 0xF000);

 CMenu* pSysMenu = GetSystemMenu(FALSE);
 if (pSysMenu != NULL)
 {
  CString strAboutMenu;
  strAboutMenu.LoadString(IDS_ABOUTBOX);
  if (!strAboutMenu.IsEmpty())
  {
   pSysMenu->AppendMenu(MF_SEPARATOR);
   pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  }
 }

 // Set the icon for this dialog.  The framework does this automatically
 //  when the application's main window is not a dialog
 SetIcon(m_hIcon, TRUE);   // Set big icon
 SetIcon(m_hIcon, FALSE);  // Set small icon
 
 // TODO: Add extra initialization here

 if (dlgBase.DoModal() == IDOK)
 {

 }

 return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMapEditDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
 if ((nID & 0xFFF0) == IDM_ABOUTBOX)
 {
  CAboutDlg dlgAbout;
  dlgAbout.DoModal();
 }
 else
 {
  CDialog::OnSysCommand(nID, lParam);
 }
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMapEditDlg::OnPaint()
{
 DrawLine();
 if (IsIconic())
 {
  CPaintDC dc(this); // device context for painting

  SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

  // Center icon in client rectangle
  int cxIcon = GetSystemMetrics(SM_CXICON);
  int cyIcon = GetSystemMetrics(SM_CYICON);
  CRect rect;
  GetClientRect(&rect);
  int x = (rect.Width() - cxIcon + 1) / 2;
  int y = (rect.Height() - cyIcon + 1) / 2;

  // Draw the icon
  dc.DrawIcon(x, y, m_hIcon);
  
 }
 else
 {
  //DrawLine();
  CDialog::OnPaint();
 }
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMapEditDlg::OnQueryDragIcon()
{
 return (HCURSOR) m_hIcon;
}


void CMapEditDlg::OnButtonNew()
{
 // TODO: Add your control notification handler code here
 dlgBase.DoModal();
}

void CMapEditDlg::OnButtonEdit()
{
 // TODO: Add your control notification handler code here
 CFileDialog dlgFile(TRUE,"map",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"MAP File (*.map)|*.map||",this);
 dlgFile.DoModal();
}

void CMapEditDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 
 CDialog::OnRButtonDown(nFlags, point);
}

void CMapEditDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
 
 // TODO: Add your message handler code here and/or call default
 int nPositionX = point.x;
 int nPositionY = point.y;
 if ((0 < nPositionX) && (650 > nPositionX) && ( 0 < nPositionY) && ( 575 > nPositionY))
 {
  // main
  
  int nRow = (nPositionY -25)/50;
  int nCol = nPositionX / 50;
  int nPosX = nCol * 50;
  int nPosY = nRow * 50 + 25;
  // test
  CString csOutMsg = _T("");
  csOutMsg.Format("Row = %d, Col = %d",nRow,nCol);
        CString csOutMsg1 = _T("");
  csOutMsg1.Format("nPosX = %d, nPosY = %d",nPosX,nPosY);
  csOutMsg += csOutMsg1;
        MessageBox(csOutMsg);
  
 // TextOut(this,0,0,csOutMsg,sizeof(csOutMsg));
  //operate obj[nRow][nCol]
 }
 else if((660 < nPositionX) && (910 > nPositionX) && ( 13 < nPositionY) && ( 63 > nPositionY))
 {
  //floor
  DrawLine();
  MessageBox("floor window");
 }
 else if((660 < nPositionX) && (910 > nPositionX) && ( 85 < nPositionY) && ( 485 > nPositionY))
 {
  //object
 // MessageBox("object window");
  CString csTemp = _T("");
  csTemp.Format(_T(" Width = %d /r/n Height = %d /r/n Move = %d /r/n Bomb out = %d"),5,4,3,1);

  m_csAttr.SetWindowText(csTemp);
 }
 else if((660 < nPositionX) && (710 > nPositionX) && ( 500 < nPositionY) && ( 550 > nPositionY))
 {
  //player
  MessageBox("Player window");
 }
 CDialog::OnLButtonDown(nFlags, point);
}

void CMapEditDlg::OnMouseMove(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 int nPositionX = point.x;
 int nPositionY = point.y;
 int nRow = 0;
 int nCol = 0;
 CString csOutMsg = _T("");
 if ((0 < nPositionX) && (650 > nPositionX) && ( 0 < nPositionY) && ( 575 > nPositionY))
 {
  // main
  nRow = (nPositionY -25)/50;
  nCol = nPositionX / 50;
  csOutMsg.Format("Row = %d, Col = %d",nRow,nCol);
 }
 else
 {
  csOutMsg = "Row = OUT, Col = OUT";
 }
 m_csOutMsg.SetWindowText(csOutMsg);
 CDialog::OnMouseMove(nFlags, point);
}
void CMapEditDlg::DrawLine()
{
 
 CClientDC dc_line(this);
 CPen pen(PS_SOLID,1,RGB(0,128,0));
 CPen *pOldPen=dc_line.SelectObject(&pen);

 for (int nRow = 0; nRow < 11; nRow++)
 {
  int nTempRow = nRow*50+25;
  dc_line.MoveTo(0, nTempRow);
  dc_line.LineTo(648, nTempRow);
 }
 for (int nCol = 0; nCol < 13; nCol++)
 {
  int nTempCol = nCol*50;
  dc_line.MoveTo(nTempCol, 0);
  dc_line.LineTo(nTempCol, 573);
 }
 dc_line.SelectObject(pOldPen);
}

 

void CMapEditDlg::OnButtonHelp()
{
 // TODO: Add your control notification handler code here
 CAboutDlg dlg_about;
 dlg_about.DoModal();
}
 

 

 

 

 

 

 

 

 

黑色背景

HDC hScrDC=CreateDC("DISPLAY", NULL, NULL, NULL);
 hBkDC =CreateCompatibleDC(hScrDC);
 HBITMAP bit =CreateCompatibleBitmap(hScrDC,650,575);
 SelectObject(hBkDC,bit);
 BitBlt(dc_line.m_hDC,0,0,650,575,hBkDC,0,0,SRCCOPY);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值