Domanda

Ho visto il codice che gestisce il disegno di questa cosa ( DFCS_SCROLLSIZEGRIP ), ma sicuramente c'è uno stile di finestra che posso applicare per ottenerlo " gratuitamente " ;. Giusto?

È stato utile?

Soluzione

Al posto di una risposta migliore, posterò il codice che ho che disegna il grip delle dimensioni e gestisce il hit test. È inoltre necessario invalidare l'area appropriata durante OnSize per poterla ridipingere.

BOOL CMyDialog::OnEraseBkgnd(CDC* pDC)
{
    if (CDialog::OnEraseBkgnd(pDC))
    {
        // draw size grip
        CRect r;
        GetClientRect(&r);
        int size = GetSystemMetrics(SM_CXVSCROLL);
        r.left = r.right - size;
        r.top = r.bottom - size;
        pDC->DrawFrameControl(&r, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}

-

LRESULT CMyDialog::OnNcHitTest(CPoint point)
{
    // return HTBOTTOMRIGHT for sizegrip area
    CRect r;
    GetClientRect(&r);
    int size = GetSystemMetrics(SM_CXVSCROLL);
    r.left = r.right - size;
    r.top = r.bottom - size;
    ScreenToClient(&point);

    if (r.PtInRect(point))
    {
        return HTBOTTOMRIGHT;
    }
    else
        return CDialog::OnNcHitTest(point);
}

Fonte: http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.ui/2006-01/msg00103.html

Altri suggerimenti

Non credo che esista uno stile predefinito per ottenere questa funzionalità gratuitamente. Devi creare una nuova finestra figlio con il nome classe Barra di scorrimento e controllare lo stile SBS_SIZEGRIP

Oltre a OnEraseBkgnd e OnNcHitTest menzionati sopra, sarà necessario invalidare l'area di grip quando la finestra viene ridimensionata, altrimenti lascerà segni quando viene ingrandita:

void CMyDialog::OnSize(UINT nType, INT cx, INT cy)
{

    CRect  rc;
    int    iSize=GetSystemMetrics(SM_CXVSCROLL);

    GetClientRect(rc);
    InvalidateRect(CRect(rc.left-iSize, rc.bottom-iSize, rc.right, rc.bottom), FALSE);
    CDialog::OnSize(nType, cx, cy);
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top