您的位置:首页 > 其它

在MFC中获取控件相对位置和使按钮变灰

2016-08-17 14:08 525 查看
一.获取控件相对位置。

    CRect frameRect;

    GetDlgItem(frameId)->GetWindowRect(&frameRect);//获取控件相对于屏幕的位置。

    ScreenToClient(frameRect);//转化为对话框上的相对位置。

    const int height = frameRect.bottom - frameRect.top;//控件的高

    const int width = frameRect.right - frameRect.left;//控件的宽

    const int RadioBtnXpos = frameRect.left + BUTTON_HEIGHT;//要新建的控件的横坐标

    const int RadioBtnYpos = frameRect.top + BUTTON_HEIGHT;//要新建的控件的纵坐标

二.使对话框中的按钮变灰。

    CButton btn;

    btn.EnableWindow(FALSE);



    CWnd *pWnd;

    pWnd = GetDlgItem(IDC_BUTTON1);

    pWnd->EnableWindow(FALSE);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mfc 对话框 控件