我现在做了一个播放控件,在使用时需要动态改变控件的大小,如默认时为一个大小但是双击时要能将其放大四倍,请问各位大哥如何解决,谢谢,分不够可再开贴
Email:[email protected]

解决方案 »

  1.   

    要是装他的容器是窗口当然可以实现直接用::setposition
      

  2.   

    LRESULT CPolyCtl::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    { // a toggle value used to toggle control size.
    static int iToggleVal = 10; HRGN hRgn;
    WORD xPos = LOWORD(lParam);  // horizontal position of cursor
    WORD yPos = HIWORD(lParam);  // vertical position of cursor
    CalcPoints(m_rcPos);   // Create a region from our list of points
    hRgn = CreatePolygonRgn(&m_arrPoint[0], m_nSides, WINDING); // If the clicked point is in our polygon then fire the ClickIn
    //  event otherwise we fire the ClickOut event
    if (PtInRegion(hRgn, xPos, yPos))
    Fire_ClickIn(xPos, yPos);
    else
    Fire_ClickOut(xPos, yPos);   // Delete the region that we created
    DeleteObject(hRgn);
    // Toggle control size here.
    RECT newPos;
    newPos = m_rcPos;
    newPos.right -= iToggleVal;
    newPos.bottom -= iToggleVal;
    iToggleVal = -iToggleVal;

    HRESULT hRet;
    CComPtr<IOleInPlaceSite> spCtlSite;
    hRet = InternalGetSite(IID_IOleInPlaceSite, (void**)&spCtlSite);
    if (SUCCEEDED(hRet))
    {
    if (spCtlSite != NULL)
    {
    // (Try) to change control size, 
    // provided the container cooperates.
    hRet = spCtlSite->OnPosRectChange (&newPos);
    }
    } return 0;
    }
    As can be seen earlier, the Polygon control attempts to resize its window every time you click the left mouse button. Accordingly, on a left button click, the control does the following:Calculates a new rectangle.
    Calls IOleInPlaceSite::OnPosRectChange() with that new rectangle.
    Resizes itself (by calling SetWindowPos() in CComControlBase::IOleInPlaceObject_SetObjectRects()) only when the container in turn calls the control's implementation of IOleInPlaceObject::SetObjectRects. 
    The last bullet is crucial: Well behaved controls resize themselves only at the behest of the container. So, if the container doesn't cooperate, the control won't resize. ActiveX controls hosted in an Microsoft Active Template Library (ATL) 3.0 container are unable to resize themselves dynamically. The container could be a composite control or any window using ATL containment as described in the following Knowledge Base article: 
    192560 HOWTO: Adding ATL Control Containment Support to Any Window 
      

  3.   

    直接在控件里面设一个属性值,这个值对应函数SetInitialSize(int x,int y)里面的x和y就可以了,在使用的时候就可以直接调用了