写了个ATL插件,这个插件要自动调整位置和大小。。(在对话框中的使用)
怎样实现啊???SOS

解决方案 »

  1.   

    不用相应什么消息,
    先有加一个接口ISetPlaySize获得要设置的大小,
    然后在主接口中加一个方法:
    /***********************************************************************************
    设置大小
    ***********************************************************************************/STDMETHODIMP CJwForwardCtl::SetSize(ISetPlaySize *Playsize, long *pVal)
    {
    CVFSException::MapSEtoCE();
    try
    {
    m_setplaysize = Playsize;
       // m_setplaysize->AddRef();
    //从接口ISetPlaySize取出left的值,赋给此接口的left。
    m_setplaysize->get_left(&lleft);
    //从接口ISetPlaySize取出top的值,赋给此接口的top。
    m_setplaysize->get_top(&ltop);
    //从接口ISetPlaySize取出width的值,赋给此接口的width。
    m_setplaysize->get_width(&lwidth);
    //从接口ISetPlaySize取出height的值,赋给此接口的height。
    m_setplaysize->get_height(&lheight);
    //将控件移动到该位置
    ::MoveWindow(m_hWnd,lleft,ltop,lwidth,lheight,TRUE);
        //间接调用Release。
    Playsize = NULL;
    // m_setplaysize->Release();
    m_setplaysize = NULL;
    }
    catch(CVFSException ce)
    {
    TCHAR buf[256];
    UINT nError = 0;
    ce.GetErrorMessage(buf,nError);
    g_log.Add(" %s,file %s,line %d",buf,__FILE__,__LINE__);
    }
    return S_OK;
    }
      

  2.   

    LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
       CRect rect;
       GetClientRect(&rect);
       //m_Scroll为控件名称
       m_Scroll.MoveWindow(&rect, FALSE);

       return 0;
    }
      

  3.   


    ::MoveWindow(m_hWnd,lleft,ltop,lwidth,lheight,TRUE); 
    即可