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

📄 mybookbutton.cpp

📁 此程序是基于BC4的蓝牙CE应用程序
💻 CPP
字号:
// MyBookButton.cpp : implementation file
//

#include "stdafx.h"
#include "btwnd.h"
#include "MyBookButton.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyBookButton

CMyBookButton::CMyBookButton()
{
}

CMyBookButton::~CMyBookButton()
{
}


BEGIN_MESSAGE_MAP(CMyBookButton, CButton)
	//{{AFX_MSG_MAP(CMyBookButton)
	ON_WM_PAINT()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_CREATE()
	ON_WM_MOUSEMOVE()
	ON_WM_ACTIVATE()
	ON_WM_KILLFOCUS()
	ON_WM_CANCELMODE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyBookButton message handlers
void CMyBookButton:: CreateButton(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID,
		CString dialnumber)
{
 Create( _T(""),dwStyle, rect,  pParentWnd,  nID );
 number_nID=nID;
 number_string=dialnumber;
  
}




void CMyBookButton::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

    	CRect rect;
	this->GetClientRect(&rect);
	//CClientDC dc(this);
    //CString str=_T("hello");

	CFont font;
	font.CreateFontIndirect(&lf1);
	dc.SelectObject(&font);
    dc.SetTextColor(RGB(255,250,250));
    dc.SetBkMode(TRANSPARENT);

   	CDC mem1CDC;
	CBitmap bitmap1;
	bitmap1.LoadBitmap(IDB_SUBBOOK_SEL_KONG_01);
    mem1CDC.CreateCompatibleDC(NULL);
    mem1CDC.SelectObject(&bitmap1) ;      
    dc.BitBlt(rect.TopLeft().x,rect.TopLeft().y,rect.BottomRight().x,rect.BottomRight().y,
		      &mem1CDC,0,0,SRCCOPY);
    dc.DrawText(number_string,&rect,DT_CENTER);

	

    // Do not call CButton::OnPaint() for painting messages
}

void CMyBookButton::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	button_up_flg=0;
		CRect rect;
		  CString str=_T("hello");
//if(flg_MouseMoveToRect==1)
//{
	this->GetClientRect(&rect);
	CClientDC dc(this);
   	CDC mem1CDC;
	CBitmap bitmap1;
	bitmap1.LoadBitmap(IDB_SUBBOOK_SEL_KONG_02);
    mem1CDC.CreateCompatibleDC(NULL);
    mem1CDC.SelectObject(&bitmap1) ;      
    dc.BitBlt(rect.TopLeft().x,rect.TopLeft().y,rect.BottomRight().x,rect.BottomRight().y,
		      &mem1CDC,0,0,SRCCOPY);
    
		CFont font;
	font.CreateFontIndirect(&lf1);
	dc.SelectObject(&font);
    dc.SetTextColor(RGB(255,250,250));
    dc.SetBkMode(TRANSPARENT);

	 dc.DrawText(number_string,&rect,DT_CENTER);
//}  
 CButton::OnLButtonDown(nFlags, point);
}

void CMyBookButton::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	button_up_flg=1;
	CRect rect;
//	if(flg_MouseMoveToRect==1)
//	{
	this->GetClientRect(&rect);
	CClientDC dc(this);
    CString str=_T("hello");

	CFont font;
	font.CreateFontIndirect(&lf1);
	dc.SelectObject(&font);
    dc.SetTextColor(RGB(255,250,250));
    dc.SetBkMode(TRANSPARENT);

   	CDC mem1CDC;
	CBitmap bitmap1;
	bitmap1.LoadBitmap(IDB_SUBBOOK_SEL_KONG_01);
    mem1CDC.CreateCompatibleDC(NULL);
    mem1CDC.SelectObject(&bitmap1) ;      
    dc.BitBlt(rect.TopLeft().x,rect.TopLeft().y,rect.BottomRight().x,rect.BottomRight().y,
		      &mem1CDC,0,0,SRCCOPY);
    dc.DrawText(number_string,&rect,DT_CENTER);
//	}
	CButton::OnLButtonUp(nFlags, point);
}



int CMyBookButton::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CButton::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	ZeroMemory(&lf1,sizeof(lf1));
	lf1.lfHeight=35;
	lf1.lfWeight=FW_BOLD;
	lf1.lfItalic=TRUE;
	::lstrcpy(lf1.lfFaceName,_T("Times New Roman"));
	
	return 1;	
}




void CMyBookButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	// TODO: Add your code to draw the specified item
	
}

void CMyBookButton::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CString str;
	CWnd *pCurrentWnd;
	int Currentdlg;
    
/*   this->ClientToScreen(&point);
	pCurrentWnd=WindowFromPoint(point);
    Currentdlg=	pCurrentWnd->GetDlgCtrlID();
	if(Currentdlg==number_nID)
    {
	  flg_MouseMoveToRect=1;
	  this->OnLButtonDown(nFlags, point);
	}
	else
	{
	  flg_MouseMoveToRect=0;
	    this->OnLButtonUp(nFlags, point);
	}
	*/
	CButton::OnMouseMove(nFlags, point);
}

void CMyBookButton::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
{
	CButton::OnActivate(nState, pWndOther, bMinimized);
	if (nState == WA_INACTIVE){Invalidate();}
	// TODO: Add your message handler code here
	
}

void CMyBookButton::OnKillFocus(CWnd* pNewWnd) 
{
	CButton::OnKillFocus(pNewWnd);
	
	// TODO: Add your message handler code here
	
}

void CMyBookButton::OnCancelMode() 
{
	CButton::OnCancelMode();
	
	// TODO: Add your message handler code here
	
}

⌨️ 快捷键说明

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