简体   繁体   中英

How to nicely handle cdialogex resizing?

I do not want to use another classes for this purpose like easysize or sizecbar from codeproject.com. I am using MFC CDialogEx. I try this:

LRESULT ChildDialog::OnNcHitTest(CPoint point)
{
    // TODO: Add your message handler code here and/or call default
    //UINT nHitTest = CWnd::OnNcHitTest(uParam, lParam);
    //return (nHitTest == HTLEFT) ? HTNONE : nHitTest;

    return CDialogEx::OnNcHitTest(point);
}

void ChildDialog::OnSizing(UINT fwSide, LPRECT pRect)
{
    //
    //TRACE("%d\n", fwSide);

    if (fwSide == WMSZ_RIGHT)
    {

        SetClassLong(m_hWnd,
            GCL_HCURSOR,
            (LONG)LoadCursor(NULL, IDC_ARROW));

        //ASSERT(FALSE);
        //AfxMessageBox(_T("right"));
    }
    // TODO: Add your message handler code here

    CDialogEx::OnSizing(fwSide, pRect);


}

When i click on right of the dialog message show right.

As you can see in the pitcher i try to do like this. Change cursor, draw black dot lines. resize dialog only one side upper and want to disable all corner and left, right and down. And also when i resize dialog from upper side also want to move upper control.

在此处输入图片说明

I do not want someone do all this for me. Just advice how i can achieve this. I take this pitcher from software depends.exe. Any help will appreciate. Thanks in advance.

You have to handle OnNCHitTest and OnSetCursor in order to change the cursor. Return HTNOWHERE from OnNCHitTest when the cursor is over a border and set the corresponding cursor in OnSetCurosr. You can have a member variable set from OnNCHitTest to know the hit test value, like m_hittest. In order to do the sizing you can use CRectTracker Class in OnMouseMove when you have the capture (left button down).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM