用VC++6.0为对话框添加最小化按钮(4)
2015-06-17 01:45
导读:ReleaseDC(pMemDC); ReleaseDC(pDC); delete pMemDC; delete pBitmap1; delete pBitmap2; } ⑷ 对应鼠标左键的WM_NCLBUTTONDOWN消息处理函数 void CMinButtonDlg::OnNcLButtonDown(UINT nHitTest, CPo
ReleaseDC(pMemDC);
ReleaseDC(pDC);
delete pMemDC;
delete pBitmap1;
delete pBitmap2;
}
⑷ 对应鼠标左键的WM_NCLBUTTONDOWN消息处理函数
void CMinButtonDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
CDialog::OnNcLButtonDown(nHitTest, point);
//检测是否在最小化按钮区域内按下按钮
if (m_rtButtMin.PtInRect(point))
{
m_BMPPressed=FALSE;//绘制按钮按下时的状态
DrawButton(); //绘制最小化按钮
m_BMPPressed=TRUE;//绘制按钮的正常状态
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, MAKELPARAM(point.x, point.y));//发送最小化消息
}
}
⑸ //在最小化按钮区域实现提示文本
BOOL CToolTips::AddToolTip( UINT nID, LPRECT lpRect, LPCTSTR lpszText )
{
TOOLINFO Tips;
memset(&Tips, 0, sizeof(TOOLINFO));
Tips.cbSize = sizeof(TOOLINFO);
Tips.hwnd = GetOwner()->GetSafeHwnd();
Tips.uFlags = TTF_SUBCLASS;
Tips.uId = nID;
memcpy(&Tips.rect, lpRect, sizeof(RECT));
Tips.lpszText = (LPSTR)lpszText
return (BOOL)SendMessage(TTM_ADDTOOL, 0, (LPARAM)&Tips);
}
⑹ 在对话框初始化函数OnInitDialog()中添下列代码:
(转载自http://zw.NSEaC.com科教作文网) m_ToolTip.Create(this,TTS_ALWAYSTIP);//创建工具提示控件,TTS_ALWAYSTIP表示,//不论控件所属窗体是否活动,提示条始终有效
GetMinButRect();
ScreenToClient(&m_ButtMinTips);//屏幕坐标转换为窗体坐标