龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > C/C++开发 >

C++实现仿Office风格的颜色选取框代码(5)

时间:2009-12-22 15:42来源:未知 作者:admin 点击:
分享到:
void CColorPicker::OnLButtonDown(long x, long y) { //POINT pt; RECT rc; //pt.x = x; pt.y = y; //ClientToScreen(m_hwnd, GetClientRect(m_hwnd, //if (!PtInRect( else { m_bMouseDown = true; ReDraw(m_HotRo

void CColorPicker::OnLButtonDown(long x, long y)

{

    //POINT pt;

    RECT rc;

    //pt.x = x; pt.y = y;

    //ClientToScreen(m_hwnd, &pt);

    GetClientRect(m_hwnd, &rc);

    //if (!PtInRect(&rc, pt))

    if (xrc.right || yrc.bottom)

        PostMessage(m_hwnd, WM_CLOSE, 0, 0);

    else

    {

        m_bMouseDown = true;

        ReDraw(m_HotRow, m_HotCol, true);

    }

}

void CColorPicker::OnLButtonUp(long x, long y)

{

    m_bMouseDown = false;

    ReDraw(m_HotRow, m_HotCol, true);

    if (y>=5*18+10 && m_HotRow==5)

    {

        ShowWindow(m_hwnd, SW_HIDE);

        CColorDialog * crDlg = new CColorDialog(m_Color, CC_FULLOPEN | CC_ANYCOLOR);

        int nResult = crDlg->DoModal();

        m_Color = crDlg->GetColor();

        PostMessage(m_hwnd, WM_CLOSE, 0, 0);

    }

    else if (m_HotRow<5 && m_HotCol<8)

    {

        m_Color = ColorMap[m_HotRow][m_HotCol];

        PostMessage(m_hwnd, WM_CLOSE, 0, 0);

    }

}

void CColorPicker::OnMouseMove(long x, long y)

{

    RECT  rc;

    GetClientRect(m_hwnd, &rc);

    InflateRect(&rc, -2, -2);

    if (xrc.right || yrc.bottom)

    {

        if (m_HotRow != 255)

        {

            ReDraw(m_HotRow, m_HotCol, false);

            m_HotRow = 255;

        }

    }

    else

    {

        if (y>=5*18+10)

        {

            if (m_HotRow != 5)

            {

                ReDraw(m_HotRow, m_HotCol, false);

                m_HotRow = 5;

                ReDraw(5, 0, true);

            }

        }

        else if (((byte)(y-2) / 18)!=m_HotRow || ((byte)(x-2) / 18)!=m_HotCol)

        {

            ReDraw(m_HotRow, m_HotCol, false);

            m_HotRow = (byte)(y-2) / 18;

            m_HotCol = (byte)(x-2) / 18;

            ReDraw(m_HotRow, m_HotCol, true);

        }

    }

}

精彩图集

赞助商链接