对话框onsize问题
对话框上有两个listcontrol的控件 我希望随着对话框的大小的改变 这两个控件也随着发生变化,但是我写了 不行
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
if( nType==SIZE_MINIMIZED )
{
return;
}
static RECT LastWindowRect2 = {0, 0, 0, 0};
static RECT LastWindowRect1 = {0, 0, 0, 0};
if (dlgcount_flag==1)
{
CWnd *hWin;
int ux = cx - LastWindowRect1.right;
int uy = cy - LastWindowRect1.bottom;
if((hWin = GetDlgItem(IDC_LIST_CPU1)) != NULL)
{
RECT rect;
hWin->GetWindowRect(&rect);
ScreenToClient(&rect);
rect.right +=(ux) ;
rect.bottom += (uy);
hWin->MoveWindow(&rect);
}
if((hWin = GetDlgItem(IDC_LIST_CPU2)) != NULL)
{
RECT rect;
hWin->GetWindowRect(&rect);
ScreenToClient(&rect);
rect.left+=(ux);
rect.right +=(2*ux) ;
rect.bottom += (uy);
hWin->MoveWindow(&rect);
}
LastWindowRect1.right = cx;
LastWindowRect1.bottom = cy;
}
if (dlgcount_flag==2)
{
CWnd *hWin;
int ux = cx - LastWindowRect2.right;
int uy = cy - LastWindowRect2.bottom;
if((hWin = GetDlgItem(IDC_LIST_CPU1)) != NULL)
{
RECT rect;
hWin->GetWindowRect(&rect);
ScreenToClient(&rect);
rect.right +=(ux) ;
rect.bottom += (uy);
hWin->MoveWindow(&rect);
}
if((hWin = GetDlgItem(IDC_LIST_CPU2)) != NULL)
{
RECT rect;
hWin->GetWindowRect(&rect);
ScreenToClient(&rect);
rect.left+=(ux);
rect.right +=(2*ux) ;
rect.bottom += (uy);
hWin->MoveWindow(&rect);
}
LastWindowRect2.right = cx;
LastWindowRect2.bottom = cy;
}
我单步调试的时候,开始rect 的大小都能追踪到,但是改来该去 单步调试连 rect说未定义 找了半天不知道那里有错,请教各位给看一下 谢谢