www.pudn.com > HPMapx.rar > GISSymble.cpp


// GISSymble.cpp 
 
#include "stdafx.h" 
#include "GISSymble.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
CGISSymble::CGISSymble() 
{ 
	bIsCreated = false; 
	m_nWidth=0; 
	m_nHeight=0; 
} 
 
CGISSymble::~CGISSymble() 
{ 
	m_Bitmap.DeleteObject(); 
} 
 
BEGIN_MESSAGE_MAP(CGISSymble, CButton) 
	//{{AFX_MSG_MAP(CGISSymble) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
void CGISSymble::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)  
{ 
	CDC dc; 
	dc.Attach(lpDrawItemStruct->hDC ); 
	DrawBitmaps( &dc ); 
	dc.Detach(); 
} 
 
BOOL CGISSymble::LoadBitmap(UINT id) 
{ 
	if(!m_Bitmap.LoadBitmap(id)) 
	{ 
		return FALSE; 
	} 
	 
	BITMAP bmpinfo; 
	m_Bitmap.GetBitmap(&bmpinfo); 
	m_nWidth  = bmpinfo.bmWidth; 
	m_nHeight = bmpinfo.bmHeight; 
	SetWindowPos(NULL,0, 0, m_nWidth, m_nHeight, SWP_NOMOVE|SWP_NOOWNERZORDER); 
	return TRUE; 
} 
 
void CGISSymble::DrawBitmaps(CDC *pDC) 
{ 
	CDC memDC; 
	memDC.CreateCompatibleDC(pDC); 
	CBitmap* old  = memDC.SelectObject(&m_Bitmap); 
 
	pDC->BitBlt(0,0,m_nWidth, m_nHeight, &memDC, 0, 0, SRCCOPY); 
	memDC.SelectObject(old); 
} 
 
BOOL CGISSymble::Create(CPoint point, CWnd *pParentWnd,UINT mapid) 
{ 
	if (! CButton::Create(NULL, 0x5000000B,CRect( point.x, point.y, point.x, point.y ),pParentWnd,0)) 
		return false; 
	 
	return bIsCreated=LoadBitmap(mapid); 
}