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

📄 check.cpp

📁 Windows NT 4.0 had WIPCfg32.exe, and Windows 95/98/ME had WinIPCfg.exe. For some reason, this utilit
💻 CPP
字号:
// Check.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "Check.h"

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

#define countof(a)	(sizeof(a)/sizeof(a[0]))

/////////////////////////////////////////////////////////////////////////////
// CCheck

CCheck::CCheck()
{
	HINSTANCE hInst = AfxGetInstanceHandle();
	UINT uiClassStyle = CS_DBLCLKS;
	//HCURSOR hCursor = ::LoadCursor (NULL, IDC_ARROW);
	HBRUSH hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);

	m_strClassName.Format (_T("WinIPCfg:Check") );
		//(UINT)hInst, uiClassStyle, (UINT)hCursor, (UINT)hbrBackground);

	//---------------------------------
	// See if the class already exists:
	//---------------------------------
	WNDCLASS wndcls;
	if (::GetClassInfo (hInst, m_strClassName, &wndcls))
	{
		//-----------------------------------------------
		// Already registered, assert everything is good:
		//-----------------------------------------------
		ASSERT (wndcls.style == uiClassStyle);
	}
	else
	{
		//-------------------------------------------
		// Otherwise we need to register a new class:
		//-------------------------------------------
		wndcls.style = uiClassStyle;
		wndcls.lpfnWndProc = ::DefWindowProc;
		wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
		wndcls.hInstance = hInst;
		wndcls.hIcon = NULL;
		wndcls.hCursor = NULL;
		wndcls.hbrBackground = hbrBackground;
		wndcls.lpszMenuName = NULL;
		wndcls.lpszClassName = m_strClassName;
		
		if (!AfxRegisterClass (&wndcls))
		{
			AfxThrowResourceException();
			return;
		}
	}

	 // Set vars

	m_bChecked = false;
}

CCheck::~CCheck()
{
}


BEGIN_MESSAGE_MAP(CCheck, CWnd)
	//{{AFX_MSG_MAP(CCheck)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CCheck message handlers

BOOL CCheck::Create(const RECT& rect, CWnd* pParentWnd, UINT nID) 
{
	DWORD dwStyle = WS_VISIBLE|WS_CHILD;
	
	if( !CWnd::Create(m_strClassName, NULL, dwStyle, rect, pParentWnd, nID, NULL) )
		return FALSE;

	return TRUE;
}

BOOL CCheck::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	if( !CWnd::Create(m_strClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext) )
		return FALSE;

	return TRUE;
}

void CCheck::SetCheck(bool bCheck)
{
	if( bCheck != m_bChecked )
	{
		m_bChecked = bCheck;
		InvalidateRect(NULL, FALSE);
	}
}

void CCheck::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	CRect rectWindow, rectFill;
	GetClientRect(rectWindow);

	COLORREF crDlg = GetSysColor(COLOR_3DFACE);
	COLORREF crFore = GetSysColor(COLOR_WINDOWTEXT);

	CBrush brushDlg(crDlg);

	CBitmap	bmp;

	bmp.CreateCompatibleBitmap(&dc, rectWindow.Width(), rectWindow.Height());

   // Create an in-memory device context compatible with the
    // display device context that is used to paint.
    CDC dcMemory;
    dcMemory.CreateCompatibleDC(&dc);

    // Select the bitmap into the in-memory device context.
    CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);

	rectFill = rectWindow;

	dcMemory.Draw3dRect(rectFill, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
	rectFill.DeflateRect(1, 1, 1, 1);
	//dcMemory.Draw3dRect(rectFill, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
	//rectFill.DeflateRect(1, 1, 1, 1);

	dcMemory.FillRect(rectFill, &brushDlg);

	if( m_bChecked )
	{
		int nTopLeft = (rectFill.Height()/3)*2;
		int nBottom = (rectFill.Width()/5)*2;
		int nTop = rectFill.Width();

		for(int i = 0; i < 4; ++i)
		{
			dcMemory.MoveTo(rectFill.left, rectFill.top+nTopLeft);
			dcMemory.LineTo(rectFill.left+nBottom, rectFill.bottom);
			dcMemory.LineTo(rectFill.left+nTop, rectFill.top);
			--nBottom;
			--nTop;
		}
	}

    // Copy the bits from the in-memory device context to the on-
    // screen device context to do the painting. Use the computed center 
    // point for the target offset.
    dc.BitBlt(rectWindow.left, rectWindow.top, rectWindow.Width(), rectWindow.Height(), &dcMemory, 0, 0, SRCCOPY);

    dcMemory.SelectObject(pOldBitmap);

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

⌨️ 快捷键说明

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