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

📄 link1button1.cpp

📁 一个通讯的主站程序 献给vc 串口通信的网友 看看吧
💻 CPP
字号:
// Link1Button1.cpp : implementation file
//

#include "stdafx.h"
#include "Modem3.h"
#include "Link1Button1.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLink1Button

CLink1Button::CLink1Button()
{	m_brush1.CreateSolidBrush(RGB(255,0,0));
    m_brush2.CreateSolidBrush(RGB(220, 220, 220));
}

CLink1Button::~CLink1Button()
{	if (fUnderline.GetSafeHandle()) fUnderline.DeleteObject();
}


BEGIN_MESSAGE_MAP(CLink1Button, CButton)
	//{{AFX_MSG_MAP(CLink1Button)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLink1Button message handlers
void CLink1Button::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{ 
	// 获取一个CDC指针
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	//定义按钮区域并初始化
	CRect rect(lpDrawItemStruct->rcItem);
    int iObk = pDC->SetBkMode(TRANSPARENT);
    //初始化按钮状态
	UINT state = lpDrawItemStruct->itemState;
    CFont * pOldFont = NULL;

	CString strText;
	GetWindowText(strText);
	 
     if (brush_flag==0)
		{
		    pDC->SetBkColor(RGB(225,255,255));
            pDC->FillRect(rect,&m_brush2);
			pDC->Draw3dRect(rect,::GetSysColor(COLOR_BTNHIGHLIGHT),::GetSysColor(COLOR_BTNSHADOW));
		    pDC->DrawText(strText, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		}
		else  if(brush_flag==1)
		{
			pDC->Draw3dRect(rect,RGB(0,0,0),RGB(0,0,0));		
			//字体颜色
			pDC->SetTextColor(RGB(0,0,0));
		
            pDC->FillRect(rect,&m_brush1);
			
            pDC->Draw3dRect(rect,::GetSysColor(COLOR_BTNHIGHLIGHT),::GetSysColor(COLOR_BTNSHADOW));
            pDC->DrawText(strText, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		}
		//加下画线(也可以用其他字体)
			if (fUnderline.GetSafeHandle() == NULL)
			{
				CFont * pFont = GetFont();
				ASSERT(pFont);
				LOGFONT lf;
				pFont->GetLogFont(&lf);
				lf.lfUnderline = TRUE;
				fUnderline.CreateFontIndirect(&lf);		
			}

			pOldFont = pDC->SelectObject(&fUnderline);
		}
	
		void CLink1Button::SetFlag(int b_flag)
		{
			brush_flag=b_flag;
		}

⌨️ 快捷键说明

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