如何在窗口上移动客户区的起始坐标? [英] How to shift the start coordinates of the client area on the window?

查看:110
本文介绍了如何在窗口上移动客户区的起始坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经评审过了下面的文章用DWM绘制自定义框架区域。 


使用DWM自定义窗口框架


删除标准帧后,帧中不存在非客户区。

 void CMainFrame :: OnNcCalcSize(BOOL bCalcValidRects,NCCALCSIZE_PARAMS * lpncsp)
{
int nTHight = 30; / *标题栏高度* /
RECT * rc;
RECT aRect;
RECT bRect;
RECT bcRect;
if(bCalcValidRects == TRUE)
{
CopyRect(& aRect,& lpncsp-> rgrc [1]);
CopyRect(& bRect,& lpncsp-> rgrc [0]);
bcRect.left = bRect.left;
bcRect.top = bRect.top - nTHight;
bcRect.right = bRect.right;
bcRect.bottom = bRect.bottom;
CopyRect(& lpncsp-> rgrc [0],& bcRect);
CopyRect(& lpncsp-> rgrc [1],& bRect);
CopyRect(& lpncsp-> rgrc [2],& aRect);
}
其他
{
rc =(RECT *)lpncsp;
rc-> left = rc-> left;
rc-> top = rc-> top - nTHight;
rc-> right = rc-> right;
rc-> bottom = rc-> bottom;
}

CFrameWnd :: OnNcCalcSize(bCalcValidRects,lpncsp);
}

因为整个窗口都是客户端区域,所以我必须调整框架的UI控件位置,但我不知道如何处理这个
问题。例如,在删除非客户端部分之前,应将红色矩形(所有UI组件)移动到客户区的原始坐标下。





解决方案

< blockquote>您应该只返回此消息的正确值,而不是调用基类CFrameWnd :: OnNcCalcSize。 我不确定该值应该是什么,但很可能是这里列出的一些WVR_值的组合:


https://msdn.microsoft.com/en-us/library/windows/desktop/ms632634%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396


Scot



I have refereed below article to draw a custom frame area with DWM. 

Custom Window Frame Using DWM

After removing the standard frame, non client area is not exist in the frame.

void CMainFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
    int nTHight = 30; /*The title bar height*/
    RECT * rc;
    RECT aRect;
    RECT bRect;
    RECT bcRect;
    if(bCalcValidRects == TRUE)
    {
        CopyRect(&aRect,&lpncsp->rgrc[1]); 
        CopyRect(&bRect,&lpncsp->rgrc[0]);
        bcRect.left = bRect.left;
        bcRect.top = bRect.top - nTHight;
        bcRect.right = bRect.right;
        bcRect.bottom = bRect.bottom;
        CopyRect(&lpncsp->rgrc[0],&bcRect);
        CopyRect(&lpncsp->rgrc[1],&bRect);
        CopyRect(&lpncsp->rgrc[2],&aRect);
    }
    else
    {
        rc = (RECT *)lpncsp;
        rc->left = rc->left;
        rc->top = rc->top - nTHight;
        rc->right = rc->right;
        rc->bottom = rc->bottom;
    }

    CFrameWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
}

Because the entire window is client region, I have to adjust the UI control placement for the frame, but I don't know how to handle this problem. For example, below red rectangle (all UI component) should be shifted into the original coordinate of the client area before removing the non client part.


解决方案

Rather than calling the base class CFrameWnd::OnNcCalcSize, you should just return the proper value for this message.  I'm not precisely sure what the value should be, but most likely a combination of some of the WVR_ values listed here:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms632634%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

Scot


这篇关于如何在窗口上移动客户区的起始坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆