在其变成浮动状态的过程中,我想改变它的大小,尝试了几个方法都不行
onseze()  onsizing() 用SetWindowPos() 
哪怕 onpaint()

解决方案 »

  1.   

    void CYourBar::OnSize(UINT nType, int cx, int cy)
    {
        CControlBar::OnSize(nType, cx, cy);    CRect rc;
        GetClientRect(rc);    m_wnd1.SetWindowPos(NULL,
                rc.left + 1, rc.top + 1,
                rc.Width() - 2, rc.Height () - 2 - 22,
                SWP_NOACTIVATE | SWP_NOZORDER );    m_wnd2.SetWindowPos(NULL,
                rc.left + 1, rc.bottom - 1 - 20,
    rc.Width() - 2 , 20,
                SWP_NOACTIVATE | SWP_NOZORDER );
    }
      

  2.   

    谢谢楼上 不过好像偏题了
     我要改变的是trlbar 本身的尺寸, 比如本来它是停靠的 我把它拖到浮动,这时候让它尺寸自动改变到我要的尺寸
      

  3.   

    ControlBar是从 Cwnd中派生的, SetWindowPos应该可用的要不试试 MoveWindow(CRect);
      

  4.   

    我的意思是:
    就是在什么地方用MoveWindow() 或者SetWindowPos()函数?
    很奇怪,onsize() 好像不管我窗口尺寸怎么变化,它都不执行!
      

  5.   

    我没有办法了 就在OnMouseLeave()函数里想实现改变窗口大小(反正),结果还是不成,代码如下
    修改后rect.bottom是我要求的数字,但窗口大小就是没有变化!
    请高手赐教
    LRESULT CMyBar::OnMouseLeave(WPARAM wParam, LPARAM lParam)
    {
    //鼠标离开了控件条主窗体
    if (m_bMouseOver)
    {
    m_bMouseOver = FALSE;
    Invalidate(FALSE);
    } CRect rect ;

    GetClientRect(&rect);//按照鼠标状态填充整个客户区 
    acutPrintf("\n  rect.bottom==%d",  rect.bottom);
    if (rect.bottom<m_ButtonH*m_buttonCount) 
    {
    rect.bottom=m_ButtonH*m_buttonCount;
    MoveWindow(&rect);
    }
        acutPrintf("  rect.bottom==%d",  rect.bottom);
         //OnPaint();
    return 0;
    }