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

📄 roundwnd.cpp

📁 一个完整的数字硬盘录像机系统软件
💻 CPP
字号:
// RoundWnd.cpp : implementation file
//
 
#include "stdafx.h"
#include "GtMpeg.h"
#include "RoundWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CRoundWnd::CRoundWnd()
{
    WNDCLASS wndcls;
    HINSTANCE hInst = AfxGetResourceHandle();
    if (!(::GetClassInfo(hInst, "RoundCtrl", &wndcls)))
    {
        wndcls.style            = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
        wndcls.lpfnWndProc      = ::DefWindowProc;
        wndcls.cbClsExtra       = wndcls.cbWndExtra = 0;
        wndcls.hInstance        = hInst;
        wndcls.hIcon            = NULL;
        wndcls.hCursor          = NULL;
        wndcls.hbrBackground    = NULL;//(HBRUSH) (Brush.operator HBRUSH());//COLOR_3DFACE + 1
        wndcls.lpszMenuName     = NULL;
        wndcls.lpszClassName    = "RoundCtrl";
        if (!AfxRegisterClass(&wndcls)) 
            AfxThrowResourceException();
    }
	m_nStates=1;
	m_pToolTip = NULL;
}

CRoundWnd::~CRoundWnd()
{
	if (m_pToolTip)
	{
        delete (m_pToolTip);
        m_pToolTip = NULL;
    }
}
BEGIN_MESSAGE_MAP(CRoundWnd, CWnd)
	//{{AFX_MSG_MAP(CRoundWnd)
	ON_WM_CREATE()
	ON_WM_PAINT()
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
	ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT,0,0xFFFF,OnToolTipNotify)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
int CRoundWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	CreateTooltips();
	return 0;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CRoundWnd::OnPaint() 
{
	CPaintDC dc(this);
	CRect Rect;
	GetClientRect(Rect);
	Rect.DeflateRect(1,1); 
	CBitmap Bitmap;
	if(m_nStates==1)
		Bitmap.LoadBitmap(IDB_AUTO_2);
	else
	   Bitmap.LoadBitmap(IDB_AUTO_1);
    APutImage(&dc,Rect.left,Rect.top,&Bitmap,RGB(255,0,0));
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CRoundWnd::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if(m_nStates==1)
		m_nStates=-1;
	else
		m_nStates=1;
	Invalidate();
	NMHDR Msg;
	Msg.hwndFrom=m_hWnd;
	if(m_nStates==-1)
       Msg.code=_CTRL_TRUN_START;
	else
       Msg.code=_CTRL_TRUN_STOP;
    GetParent()->SendMessage(WM_NOTIFY,_CTRL_INFO,(LPARAM)&Msg);
	CWnd::OnLButtonDown(nFlags, point);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BOOL CRoundWnd::Create(CString sCaption,CRect rect, CWnd* pParentWnd, UINT nID) 
{
	m_sCaption=sCaption;
	return CWnd::Create("RoundCtrl",NULL,WS_CHILD|WS_VISIBLE, rect, pParentWnd, nID);
}
//////////////////////////////////////
//
/////////////////////////////////////
void CRoundWnd::CreateTooltips()
{
    if (m_pToolTip == NULL)
    {
        CRect rect;
        GetClientRect(rect);
        m_pToolTip = new CToolTipCtrl;
        if(!m_pToolTip)
        {
            MessageBox(_T("Unable to allocate memory for ToolTips!"));
        }
        else
        {
            if( !m_pToolTip->Create(this, TTS_ALWAYSTIP) )
            {   
                MessageBox(_T("Unable to Create ToolTips for Grid!"));
            }
            else
            {
                m_pToolTip->AddTool(this, LPSTR_TEXTCALLBACK, rect, 1);
                m_pToolTip->Activate(TRUE);
                m_pToolTip->SendMessage(TTM_SETDELAYTIME,TTDT_AUTOPOP,30000);
                EnableToolTips(TRUE);
            }
        }
    }
}
////////////////////////////////////////
//
///////////////////////////////////////
BOOL CRoundWnd::PreTranslateMessage(MSG* pMsg) 
{
    switch(pMsg->message)
    {
        case WM_LBUTTONDOWN:
        case WM_MOUSEMOVE:
        case WM_LBUTTONUP:
        case WM_MBUTTONDOWN:
        case WM_MBUTTONUP:
        case WM_RBUTTONDOWN:
        case WM_RBUTTONUP:
        if (m_pToolTip)
        {
            CPoint ptCurrentPos;
            ptCurrentPos.x = LOWORD(pMsg->lParam);
            ptCurrentPos.y = HIWORD(pMsg->lParam);
            if (m_rectSearch.PtInRect(ptCurrentPos) == FALSE)
            {
                m_pToolTip->Activate(FALSE);
            }
            m_pToolTip->Activate(TRUE);
            m_pToolTip->RelayEvent(pMsg);
        }
    }
	return CWnd::PreTranslateMessage(pMsg);
}
////////////////////////////////////////
//
///////////////////////////////////////
BOOL CRoundWnd::OnToolTipNotify(UINT id,NMHDR   *pNMH, LRESULT *pResult) 
{
    LPTOOLTIPTEXT lpttt; 
    lpttt = (LPTOOLTIPTEXT)pNMH; 
    lpttt->szText[0] = '\0';
    POINT  ptCurrentPos;
    GetCursorPos(&ptCurrentPos);
    ScreenToClient(&ptCurrentPos);
    m_rectSearch.SetRect(ptCurrentPos.x - 3,ptCurrentPos.y - 3,ptCurrentPos.x + 3,ptCurrentPos.y + 3);
    strcpy(lpttt->szText,m_sCaption); 
    return FALSE;
}

⌨️ 快捷键说明

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