• 大小: 2.92M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-04-18
  • 语言: C/C++
  • 标签: MFC  控件  

资源简介

MFC 各种控件重绘Tree、Button等

资源截图

代码片段和文件信息

// ButtonEx.cpp : 实现文件
//

#include “stdafx.h“
#include “MySelfPaintControl.h“
#include “ButtonEx.h“


// CButtonEx

IMPLEMENT_DYNAMIC(CButtonEx CButton)

CButtonEx::CButtonEx()
{
m_bIsPressed = false;
m_bIsFocused = false;
m_bIsDisabled = false;
m_hIcon = NULL;
m_fontItem.CreateFont(
18                        // nHeight
0                         // nWidth
0                         // nEscapement
0                         // nOrientation
FW_BOLD                   // nWeight
FALSE                     // bItalic
FALSE                     // bUnderline
0                         // cStrikeOut
ANSI_CHARSET    // nCharSet
OUT_DEFAULT_PRECIS        // nOutPrecision
CLIP_DEFAULT_PRECIS       // nClipPrecision
PROOF_QUALITY             // nQuality
DEFAULT_PITCH | FF_SWISS  // nPitchAndFamily
_T(“宋体“));              // lpszFacename
}

CButtonEx::~CButtonEx()
{
}

BEGIN_MESSAGE_MAP(CButtonEx CButton)
ON_WM_CTLCOLOR()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()

void CButtonEx::DrawDottedLineRect(CDC* pDC CRect rcDraw)
{
pDC->SetBkMode(TRANSPARENT);
CPen pen(PS_DOT 1 RGB(50 50 50));
CPen *pOldPen = pDC->Selectobject(&pen);
pDC->MoveTo(rcDraw.TopLeft());
pDC->LineTo(rcDraw.right rcDraw.top);
pDC->LineTo(rcDraw.BottomRight());
pDC->LineTo(rcDraw.left rcDraw.bottom);
pDC->LineTo(rcDraw.TopLeft());
pDC->Selectobject(pOldPen);
pOldPen = NULL;
}

void CButtonEx::DrawIcon(CDC *pDC HICON hIcon CRect rect BOOL bIsDisabled/* = FALSE*/)
{
if (!hIcon)
return;
int nSize = 24;
BOOL bRetValue;
ICONINFO iInfo;
::ZeroMemory(&iInfo sizeof(ICONINFO));
bRetValue = ::GetIconInfo(hIcon &iInfo);
if (bRetValue)
{
nSize = iInfo.xHotspot * 2;
}
CRect rc = rect;
rc.left += 8;
int nHoffset = rc.Height() - nSize;
CRect rcIcon;
if (nHoffset > 0)
{
rcIcon.left = rc.left;
rcIcon.top = rc.top + nHoffset / 2;
rcIcon.right = rc.left + nSize + 2;
rcIcon.bottom = rc.bottom - nHoffset / 2;
}
else
{
rcIcon.left = rc.left;
rcIcon.top = rc.top;
rcIcon.right = rc.left + nSize + 2;
rcIcon.bottom = rc.bottom;
}
pDC->DrawState(rcIcon.TopLeft() rcIcon.Size() hIcon bIsDisabled? DSS_DISABLED:DSS_NORMAL (CBrush*)NULL);
}

void CButtonEx::SetIcon(int nIcon)
{
if (m_hIcon)
::DestroyIcon(m_hIcon);
m_hIcon = (HICON)::LoadImage(AfxGetInstanceHandle() MAKEINTRESOURCE(nIcon) IMAGE_ICON 16 16 0);
Invalidate();
}

// CButtonEx 消息处理程序
HBRUSH CButtonEx::OnCtlColor(CDC* pDC CWnd* pWnd UINT nCtlColor)
{
HBRUSH hbr = CButton::OnCtlColor(pDC pWnd nCtlColor);

// TODO:  在此更改 DC 的任何特性
return (HBRUSH)::GetStockobject(NULL_BRUSH);
// TODO:  如果默认的不是所需画笔,则返回另一个画笔
return hbr;
}

BOOL CButtonEx::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
return TRUE;
return CButton::OnEraseBkgnd(pDC);
}

void CButtonEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO:  添加您的代码以绘

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     462336  2020-08-27 10:30  MySelfPaintControl\Exe\Win32\Debug\MySelfPaintControl.exe

     文件    2872804  2020-08-27 10:30  MySelfPaintControl\Exe\Win32\Debug\MySelfPaintControl.ilk

     文件    5222400  2020-08-27 10:32  MySelfPaintControl\Exe\Win32\Debug\MySelfPaintControl.pdb

     文件     711168  2020-09-27 09:28  MySelfPaintControl\Exe\x64\Debug\MySelfPaintControl.exe

     文件    4548132  2020-09-27 09:28  MySelfPaintControl\Exe\x64\Debug\MySelfPaintControl.ilk

     文件    5697536  2020-09-27 09:28  MySelfPaintControl\Exe\x64\Debug\MySelfPaintControl.pdb

     文件       6042  2020-08-29 11:27  MySelfPaintControl\MySelfPaintControl\ButtonEx.cpp

     文件        810  2020-08-28 15:02  MySelfPaintControl\MySelfPaintControl\ButtonEx.h

     文件       7865  2020-09-27 09:27  MySelfPaintControl\MySelfPaintControl\CheckBox.cpp

     文件       1767  2020-08-26 14:39  MySelfPaintControl\MySelfPaintControl\CheckBox.h

     文件       1097  2020-09-14 16:25  MySelfPaintControl\MySelfPaintControl\DlgPage1.cpp

     文件        518  2020-09-14 16:26  MySelfPaintControl\MySelfPaintControl\DlgPage1.h

     文件       1097  2020-09-14 16:25  MySelfPaintControl\MySelfPaintControl\DlgPage2.cpp

     文件        518  2020-09-14 16:26  MySelfPaintControl\MySelfPaintControl\DlgPage2.h

     文件       1097  2020-09-14 16:25  MySelfPaintControl\MySelfPaintControl\DlgPage3.cpp

     文件        518  2020-09-14 16:26  MySelfPaintControl\MySelfPaintControl\DlgPage3.h

     文件      31411  2020-08-22 08:56  MySelfPaintControl\MySelfPaintControl\GDIPlusEx.cpp

     文件      14732  2020-08-22 09:00  MySelfPaintControl\MySelfPaintControl\GDIPlusEx.h

     文件       7603  2020-08-28 09:22  MySelfPaintControl\MySelfPaintControl\MenuEx.cpp

     文件       2503  2020-08-28 09:16  MySelfPaintControl\MySelfPaintControl\MenuEx.h

     文件       4076  2020-09-15 10:53  MySelfPaintControl\MySelfPaintControl\MFCPropertyGridCtrlEx.cpp

     文件        642  2020-09-15 10:48  MySelfPaintControl\MySelfPaintControl\MFCPropertyGridCtrlEx.h

     文件       2768  2020-09-14 15:44  MySelfPaintControl\MySelfPaintControl\MFCTabCtrlEx.cpp

     文件        566  2020-09-14 15:43  MySelfPaintControl\MySelfPaintControl\MFCTabCtrlEx.h

     文件      18431  2020-08-25 10:33  MySelfPaintControl\MySelfPaintControl\MyComboBox.cpp

     文件       3811  2020-09-07 16:46  MySelfPaintControl\MySelfPaintControl\MyComboBox.h

     文件      11675  2020-08-27 14:22  MySelfPaintControl\MySelfPaintControl\MyMenu.cpp

     文件       2759  2020-08-27 14:22  MySelfPaintControl\MySelfPaintControl\MyMenu.h

     文件     152304  2020-09-27 08:53  MySelfPaintControl\MySelfPaintControl\MySelfPaintControl.aps

     文件       2627  2020-08-21 08:35  MySelfPaintControl\MySelfPaintControl\MySelfPaintControl.cpp

............此处省略55个文件信息

评论

共有 条评论