📄 wndtips.cpp
字号:
// WndTips.cpp : 实现文件
//
#include "stdafx.h"
#include "PCIEBoardTest.h"
#include "WndTips.h"
#include ".\wndtips.h"
// CWndTips
IMPLEMENT_DYNAMIC(CWndTips, CWnd)
CWndTips::CWndTips()
{
}
CWndTips::~CWndTips()
{
}
BEGIN_MESSAGE_MAP(CWndTips, CWnd)
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
// CWndTips 消息处理程序
void CWndTips::ClearTips()
{
m_lstTips.RemoveAll();
}
void CWndTips::AddTips(const char *p_szTips)
{
if (p_szTips)
{
CString strTips = p_szTips;
m_lstTips.AddTail(strTips);
}
}
void CWndTips::ShowTips(int x, int y)
{
if (m_lstTips.GetCount() > 0)
{
//
CDC *pDC = GetDC();
CSize sizeTips;
CSize sizeTemp;
CString strTips;
POSITION pos = m_lstTips.GetHeadPosition();
sizeTips.cx = 0;
sizeTips.cy = 0;
while(pos)
{
strTips = m_lstTips.GetNext(pos);
sizeTemp = pDC->GetOutputTextExtent(strTips);
sizeTips.cy += sizeTemp.cy;
sizeTips.cx = sizeTips.cx > sizeTemp.cx ? sizeTips.cx : sizeTemp.cx;
}
CRect rectParent;
GetParent()->GetClientRect(rectParent);
if(x + sizeTips.cx + 2 > rectParent.Width())
x -= (sizeTips.cx + 2);
else
x += 16;
if(y + sizeTips.cy + 2 > rectParent.Height())
y -= (sizeTips.cy + 2);
else
y += 1;
MoveWindow(x, y, sizeTips.cx + 2, sizeTips.cy + 2);
ShowWindow(SW_SHOW);
}
else
{
ShowWindow(SW_HIDE);
}
}
BOOL CWndTips::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CRect rectClient;
GetClientRect(rectClient);
CBrush brshTips;
brshTips.CreateSolidBrush(RGB(255, 255, 128));
CBrush * pOldBrsh = pDC->SelectObject(&brshTips);
pDC->Rectangle(rectClient);
pDC->SetBkColor(RGB(255, 255, 128));
rectClient.left += 1;
rectClient.top += 1;
rectClient.right -= 1;
rectClient.bottom -= 1;
POINT posDisp;
CSize sizeTemp;
CString strTips;
POSITION pos = m_lstTips.GetHeadPosition();
posDisp.x = 1;
posDisp.y = 1;
while(pos)
{
strTips = m_lstTips.GetNext(pos);
pDC->TextOut(posDisp.x, posDisp.y, strTips);
sizeTemp = pDC->GetOutputTextExtent(strTips);
posDisp.y += sizeTemp.cy;
}
pDC->SelectObject(pOldBrsh);
return CWnd::OnEraseBkgnd(pDC);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -