简体   繁体   English

如何很好地处理cdialogex调整大小?

[英]How to nicely handle cdialogex resizing?

I do not want to use another classes for this purpose like easysize or sizecbar from codeproject.com. 我不想为此目的使用其他类,例如codeproject.com的easysize或sizecbar。 I am using MFC CDialogEx. 我正在使用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. 我从软件depends.exe取得了这个投手。 Any help will appreciate. 任何帮助将不胜感激。 Thanks in advance. 提前致谢。

You have to handle OnNCHitTest and OnSetCursor in order to change the cursor. 您必须处理OnNCHitTest和OnSetCursor才能更改光标。 Return HTNOWHERE from OnNCHitTest when the cursor is over a border and set the corresponding cursor in OnSetCurosr. 当光标在边框上时,从OnNCHitTest返回HTNOWHERE并在OnSetCurosr中设置相应的光标。 You can have a member variable set from OnNCHitTest to know the hit test value, like m_hittest. 您可以从OnNCHitTest设置一个成员变量来了解命中测试值,例如m_hittest。 In order to do the sizing you can use CRectTracker Class in OnMouseMove when you have the capture (left button down). 为了进行大小调整,您可以在捕获时使用OnMouseMove中的CRectTracker类(向下按下按钮)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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