|
5、双击可以将主窗口激活并显示。由于WM_HITTEST消息的影响,我们双击鼠标的时候产生的是WM_NCLBUTTONDBLCLK消息,而不是WM_LBUTTONDBLCLK消息。 void CFloatWnd::OnNcLButtonDblClk(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CWnd *pParent = GetParent(); ASSERT(pParent); //显示窗口 if(!pParent->IsWindowVisible()) pParent->ShowWindow(SW_SHOW); //置窗口到最前面 pParent->SetForegroundWindow(); CDialog::OnNcLButtonDblClk(nFlags, point); } 关于调节透明度的Slider使用,也写了一些代码,一并贴出来,供大家参考。 void CMainDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: Add your message handler code here and/or call default //得到Slider的位置 int iCurPos = m_Slider.GetPos(); //得到最大值、最小值,及页大小 int nMax = m_Slider.GetRangeMax(); int nMin = m_Slider.GetRangeMin(); int nPageSize = m_Slider.GetPageSize(); switch(nSBCode) { case SB_LINELEFT: if(iCurPos > nMin) iCurPos --; break; case SB_LINERIGHT: if(iCurPos < nMax) iCurPos ++; break; case SB_PAGELEFT: if(iCurPos > nMin) iCurPos = max(nMin,iCurPos - nPageSize); break; case SB_PAGERIGHT: if(iCurPos < nMax) iCurPos = min(nMax,iCurPos + nPageSize); break; case SB_THUMBTRACK: iCurPos = nPos; break; case SB_THUMBPOSITION: iCurPos = nPos; break; } //设置Slider位置 m_Slider.SetPos(iCurPos); //更新透明度 pFloatWnd->OnUpdateTransparent(iCurPos); CDialog::OnHScroll(nSBCode, nPos, pScrollBar); } 至于该窗口的右键菜单,窗口的显示与隐藏,程序的退出等简单代码我就不多介绍了。
三、该程序在Windows xp sp2和Visual C++6.0下编译调试成功。
共2页: 上一页 [1] 2 下一页
|