Link to home
Start Free TrialLog in
Avatar of SaravananMP
SaravananMP

asked on

ATL Composite control - Resizing at run time

Hi
I'm developing an ATL composite control which has two components (a button and a list box). The list box won't be visible initially; when the button is clicked the list box should appear. The initial area of the composite control just accomodates the button. Only when the button is clicked the composite control area should be increased to accomodate the list box. I tried changing the values of m_sizeExtent and m_sizeNormal; it didn't work. Is there a way to solve this issue? Your suggestions will be valuable.
Thanks.

Regards
Saravanan.
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Is the pCtrl->SetWindowPos(NULL, 0, 0, cx, cy, SWP_NOZORDER | SWP_NOMOVE) of any use - cx  and cy are the new width/height you want and pCtrl is a pointer to the control.
Avatar of SaravananMP
SaravananMP

ASKER

Hi
The issue here is the control has to resize itself. SetWindowPos didn't work. The control area is decided by the variables m_sizeExtent and m_sizeNatural. Can by some means these variables be changed after the construction of the control to change the control area?
ASKER CERTIFIED SOLUTION
Avatar of migel
migel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Could change the control size. While testing, I had a button control right below my composite control in the host window. As expected the button got hidden when the list box in my composite control dropped down. When I tried selecting an item in the list box through mouse click, the button (which is hiding) below my control is clicked and the button is visible there after. Sorry to bother you. Can this be solved?
Thanks.
hm...
It is another question isn`t it? :-)
It`s so strange may be it is a bug of the ActiveX host you use.
Do you check it under VB?
Thanks.
I will check it.
Hi
The call to spCtlSite->OnPosRectChange (&newPos); returned E_NOTIMPL when I tried using this control in an ATL container. I was testing this in MFC and it worked fine. Our requirement is to host this control in an ATL composite control. Any pointers to solve this issue?

Thanks & Regards
Saravanan.
Hi!
It is known ATL hosting bug:
In this case you can manually resize your control by:

          hRet = spCtlSite->OnPosRectChange (&newPos);
          if(FAILED(hRet))
{
          //Change the control's extents
          SIZE size;
          size.cx=m_rcPos.right;
          size.cy=m_rcPos.botom;
         
          HWND hwndContainer=GetContainerWindow(m_spClientSite);
          HDC hdc=::GetDC(hwndContainer);
          DPtoHIMETRIC(hdc, &size);
          ::ReleaseDC(hwndContainer,hdc);
          SetExtent(DVASPECT_CONTENT,&size);
}
}
Hi
Thanks for your response.
The code didn't compile when I tried this method. The error is
'GetContainerWindow' : undeclared identifier. Is there are a method equivalent to GetContainerWindow?

Thanks & regards
Saravanan.
Hi
DPtoHIMETRIC too is undeclared. I guess, DPtoHIMETRIC is a member of CDC class and I won't be able to use CDC in my ATL control class.
oops sorry - this was an old project snippet.
here is right code
  SIZEL szlMetric;
           size.cx=m_rcPos.right;
          size.cy=m_rcPos.botom;
 
   AtlPixelToHiMetric(&szlPixels, &szlMetric);
   // IOleObjectImpl
   SetExtent(DVASPECT_CONTENT, &szlMetric);

Hi
I tried this; It didn't work. When I searched for a work around, I found this article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q242994
Thanks.

Regards
Saravanan.