⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tooldlg.cpp

📁 EVC开发的手持导航的用户操作界面
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// ToolDlg.cpp : implementation file
//

#include "stdafx.h"
#include "GPS.h"
#include "ToolDlg.h"
#include "ErrorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////

// CToolDlg dialog


CToolDlg::CToolDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CToolDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CToolDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CToolDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CToolDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CToolDlg, CDialog)
	//{{AFX_MSG_MAP(CToolDlg)
	ON_WM_ERASEBKGND()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_PAINT()
	ON_WM_KEYDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CToolDlg message handlers

BOOL CToolDlg::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	BITMAP bmpInfo;
	m_BackScreenBitmap.GetBitmap(&bmpInfo);
	
	// Create an in-memory DC compatible with the
	// display DC we're using to paint
	CDC dcMemory;
	dcMemory.CreateCompatibleDC(pDC);
	
	
	// Select the bitmap into the in-memory DC
	CBitmap* pOldBitmap = dcMemory.SelectObject(&m_BackScreenBitmap);
	
	// Find a centerpoint for the bitmap in the client area
	CRect rect;
	GetClientRect(&rect);
	
	// Copy the bits from the in-memory DC into the on-
	// screen DC to actually do the painting. Use the centerpoint
	// we computed for the target offset.
	pDC->BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory, 
		0, 0, SRCCOPY);
	
	dcMemory.SelectObject(pOldBitmap);
	return TRUE;
}

void CToolDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	m_prePick = m_currentPick ;

	for ( int i = 0 ; i < 6 ; i ++ ) 
	{		
		if (  m_rect[i].PtInRect (point)   )
		{									
		
			{	
				
				CDC* pDC = GetDC () ;
				CDC  memDC ;
				memDC.CreateCompatibleDC ( pDC ) ;
				
				CBitmap bmp ;
				
				switch ( m_prePick )
				{
				case 0:
					{//白
						bmp.LoadBitmap ( IDB_TOOL_CALC_W ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp ) ;
						
						pDC->BitBlt ( m_rect[m_prePick].TopLeft().x, m_rect[m_prePick].TopLeft().y, m_rect[m_prePick].Width(), 
							m_rect[m_prePick].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;						
						
						break ;
					}
				case 1:
					{
						bmp.LoadBitmap ( IDB_TOOL_CLOCK_W ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp ) ;
						
						pDC->BitBlt ( m_rect[m_prePick].TopLeft().x, m_rect[m_prePick].TopLeft().y, m_rect[m_prePick].Width(), 
							m_rect[m_prePick].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						break ;
					}
				case 2:
					{
						bmp.LoadBitmap ( IDB_TOOL_TAG_W ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp ) ;
						
						pDC->BitBlt ( m_rect[m_prePick].TopLeft().x, m_rect[m_prePick].TopLeft().y, m_rect[m_prePick].Width(), 
							m_rect[m_prePick].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						break ;
					}
				case 3:
					{
						bmp.LoadBitmap ( IDB_TOOL_BOOK_W ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp ) ;
						
						pDC->BitBlt ( m_rect[m_prePick].TopLeft().x, m_rect[m_prePick].TopLeft().y, m_rect[m_prePick].Width(), 
							m_rect[m_prePick].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						break ;
					}	
				case 4:
					{
						bmp.LoadBitmap ( IDB_TOOL_TEST_W ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp ) ;
						
						pDC->BitBlt ( m_rect[m_prePick].TopLeft().x, m_rect[m_prePick].TopLeft().y, m_rect[m_prePick].Width(), 
							m_rect[m_prePick].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						break ;
					}		
				case 5:
					{
						bmp.LoadBitmap ( IDB_TOOL_CANCEL_W ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp ) ;
						
						pDC->BitBlt ( m_rect[m_prePick].TopLeft().x, m_rect[m_prePick].TopLeft().y, m_rect[m_prePick].Width(), 
							m_rect[m_prePick].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						break ;
					}		
					
				
				}
				
				CBitmap   bmp1 ;
				switch ( i )
				{
				case 0:
					{			
						//load the bitmap	
						//黑
						bmp1.LoadBitmap ( IDB_TOOL_CALC_B ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp1 ) ;
						
						pDC->BitBlt ( m_rect[i].TopLeft().x, m_rect[i].TopLeft().y, m_rect[i].Width(), 
							m_rect[i].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						
						break ;
					}
				case 1:			
					{				
						//load the bitmap
						
						bmp1.LoadBitmap ( IDB_TOOL_CLOCK_B ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp1 ) ;
						
						pDC->BitBlt ( m_rect[i].TopLeft().x, m_rect[i].TopLeft().y, m_rect[i].Width(), 
							m_rect[i].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						
						break ;
					}
				case 2:
					{							
						//load the bitmap
						
						bmp1.LoadBitmap ( IDB_TOOL_TAG_B ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp1 ) ;
						
						pDC->BitBlt ( m_rect[i].TopLeft().x, m_rect[i].TopLeft().y, m_rect[i].Width(), 
							m_rect[i].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						
						break ;
					}
				case 3:
					{
						//load the bitmap
						
						bmp1.LoadBitmap ( IDB_TOOL_BOOK_B ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp1 ) ;
						
						pDC->BitBlt ( m_rect[i].TopLeft().x, m_rect[i].TopLeft().y, m_rect[i].Width(), 
							m_rect[i].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						break ;
					}
					case 4:
					{
						//load the bitmap
						
						bmp1.LoadBitmap ( IDB_TOOL_TEST_B) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp1 ) ;
						
						pDC->BitBlt ( m_rect[i].TopLeft().x, m_rect[i].TopLeft().y, m_rect[i].Width(), 
							m_rect[i].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						break ;
					}
					case 5:
					{
						//load the bitmap
						
						bmp1.LoadBitmap ( IDB_TOOL_CANCEL_B ) ;
						
						CBitmap* pOldBitmap = memDC.SelectObject ( &bmp1 ) ;
						
						pDC->BitBlt ( m_rect[i].TopLeft().x, m_rect[i].TopLeft().y, m_rect[i].Width(), 
							m_rect[i].Height(), &memDC, 0, 0, SRCCOPY ) ;
						
						memDC.SelectObject ( pOldBitmap ) ;
						break ;
					}
					
				
				}
				
				memDC.DeleteDC () ;
				ReleaseDC ( pDC ) ;
				
				m_currentPick = i ;				
			}	

		}
	}
}

void CToolDlg::OnLButtonUp(UINT nFlags, CPoint point) 
{

	PROCESS_INFORMATION info;
	CErrorDlg error_dlg;
	CopyBMP(IDB_TOOL_CALC_W,0);
	CopyBMP(IDB_TOOL_CLOCK_W,1);
	CopyBMP(IDB_TOOL_TAG_W,2);
	CopyBMP(IDB_TOOL_BOOK_W,3);
	CopyBMP(IDB_TOOL_TEST_W,4);
	CopyBMP(IDB_TOOL_CANCEL_W,5);
		m_bIsExecute = FALSE ;
	for ( int i = 0 ; i < 6 ; i ++ ) 
	{		
		if (  m_rect[i].PtInRect (point)   )
		{
			if ( m_currentPick == i)
			{
				m_bIsExecute =TRUE ;
				switch (i)
				{
				case 0:	
						if(!(CreateProcess(TEXT("\\Storage Card\\calculator.exe"),NULL,NULL,NULL,NULL,CREATE_NEW_CONSOLE,
							NULL,NULL,NULL, &info)))
						{
							error_dlg.m_strError = " 请检查SD卡计算器文件! ";
							error_dlg.DoModal();
						}
	
						break ;
				case 1:
						break ;
				case 2:
						
						break ;
				case 3:					
						break ;
				case 4:			
					
						break ;
				case 5:		
						CDialog::OnCancel();
						break ;
				default:
						break ;
				}
			}
		}
		
	}
	
}

void CToolDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	DrawInterface(dc);
	// Do not call CDialog::OnPaint() for painting messages
}

BOOL CToolDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_Left=0;
	m_Top=0;
	m_Width=320;
	m_Height=240;
	::SetWindowPos(this->GetSafeHwnd(),HWND_TOP,m_Left, m_Top, 
		m_Width, m_Height,SWP_SHOWWINDOW);
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen
	// TODO: Add extra initialization here
	m_BackScreenBitmap.LoadBitmap(IDB_TOOL_BKG);

	SetToolRectangle();

	m_prePick=-1;
	m_currentPick=0;
	m_bIsExecute=FALSE ;
	
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void CToolDlg::SetToolRectangle()
{

	m_rect [0].SetRect(153,26,205,95);
	m_rect [1].SetRect(235,29,279,95);
	m_rect [2].SetRect(153,95,204,160);
	m_rect [3].SetRect(233,95,281,161);
	m_rect [4].SetRect(145,163,209,214);
	m_rect [5].SetRect(275,198,310,233);
	

//	logo.SetRect(9,11,151,41);
}

void CToolDlg::DrawInterface(CDC &dc)
{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -