xiaotian2000 2002年09月09日
我用以下代码,实现了重画标题栏和窗体四边,有了很好的效果,但是在窗体在活动与非活动之间切换时,出现闪烁,请问怎么解决!
我用以下代码,实现了重画标题栏和窗体四边,有了很好的效果,但是在窗体在活动与非活动之间切换时,出现闪烁,请问怎么解决!

LRESULT CTitleBarDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT lrst=CDialog::DefWindowProc(message, wParam, lParam);

if (!::IsWindow(m_hWnd))
return lrst;

if (message==WM_MOVE||message==WM_PAINT||message == WM_NCACTIVATE||message == WM_NCPAINT ||message == WM_NOTIFY)
{
CDC* pWinDC = GetWindowDC();
if (pWinDC)
DrawTitleBar(pWinDC);
ReleaseDC(pWinDC);
}

return lrst;
}

//响应双击非客户区,就是最大化和恢复
void CTitleBarDlg::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
{
if (IsZoomed())
SendMessage(WM_SYSCOMMAND, SC_RESTORE, MAKELPARAM(point.x, point.y));
else
{
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, MAKELPARAM(point.x, point.y));
Invalidate();
}
}

void CTitleBarDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
//检测各按钮是否按到
if (m_rtIcon.PtInRect(point))
AfxMessageBox("美丽的窗口!");
else if (m_rtButtHelp.PtInRect(point))
SendMessage(WM_HELP);
else if (m_rtButtExit.PtInRect(point))
SendMessage(WM_CLOSE);
else if (m_rtButtMin.PtInRect(point))
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, MAKELPARAM(point.x, point.y));
else if (m_rtButtMax.PtInRect(point))
{
if (IsZoomed())
SendMessage(WM_SYSCOMMAND, SC_RESTORE, MAKELPARAM(point.x, point.y));
else
{
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, MAKELPARAM(point.x, point.y));
Invalidate();
}
}
else if (!IsZoomed())
{
Default();
}
}

void CTitleBarDlg::OnNcMouseMove(UINT nHitTest, CPoint point)
{
//
if (m_rtButtMin.PtInRect(point)||m_rtButtMax.PtInRect(point)||m_rtButtExit.PtInRect(point)||m_rtIcon.PtInRect(point))
{
HCURSOR m_hButtonCursor = AfxGetApp()->LoadCursor(IDC_HAND);
::SetCursor(m_hButtonCursor);
}

CDialog::OnNcMouseMove(nHitTest, point);
}

...全文
23 点赞 收藏 3
写回复
3 条回复

还没有回复,快来抢沙发~

发动态
发帖子
VC/MFC
创建于2007-09-28

7872

社区成员

42.1w+

社区内容

VC/MFC相关问题讨论
社区公告
暂无公告