15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


How to autosize a MFC OLE control to parent's size?

Gareth Isaac -- humbert@tcp.co.uk
Sunday, February 02, 1997

Environment: VC++4.2 flat, Windows NT 4.0

I am trying to re-size a MFC OLE control to it's parents window. The
control is a tree control and it has a OLE property that is
'AutoFitToParent'. I am trying to embed the control in a HTML frame window.

Currently I do the following (which is a hack but I'm stuck at the moment)
in the notification of the change. I'm sure the problem lies in the
getparent, getparent section. This code works for 'TestContainer' but not
for Explorer v3.0.

Is there a correct way to determine the size of your parent area?


Many thanks,

Gareth...
==== Broken Code Segment Follows!! ======

void CRegTreeCtrl::OnAutoSizeToParentChanged() 
{
  CRect ParentCoordinates;
  CWnd  *Parent;

  /***********************************************************************/
  /* If we are in a run-time environment and are configured to resize to */
  /* our parent then perform the rezise functionality.                   */
  /***********************************************************************/
  if ((m_autoSizeToParent) && (AmbientUserMode()))
  {
    /*********************************************************************/
    /* Get the dimensions of the owning parent area.                     */
    /*********************************************************************/
    Parent = GetParent()->GetParent();
    Parent->GetClientRect(ParentCoordinates);

    /*********************************************************************/
    /* Now set our size to match the parent area.                        */
    /*********************************************************************/
    SetRectInContainer(ParentCoordinates);
  }
	SetModifiedFlag();

  return;
}




Mike Blaszczak -- mikeblas@nwlink.com
Wednesday, February 05, 1997

At 15:00 2/2/97 -0000, Gareth Isaac wrote:
>Environment: VC++4.2 flat, Windows NT 4.0

MFC 4.2-flat isn't compatible with shiping versions of some operating
system components.  You should upgrade to MFC 4.2b as soon as possible,
as it _does_ work with the golden versions of those components.

>I am trying to re-size a MFC OLE control to it's parents window. The
>control is a tree control and it has a OLE property that is
>'AutoFitToParent'. I am trying to embed the control in a HTML frame window.

>Currently I do the following (which is a hack but I'm stuck at the moment)
>in the notification of the change. I'm sure the problem lies in the
>getparent, getparent section. This code works for 'TestContainer' but not
>for Explorer v3.0.

I think it'll break for lots of other containers, like VB and Office 97,
as well.

>Is there a correct way to determine the size of your parent area?

No, there isn't.  An OLE Control is an OLE Server.  It's intended to do
exactly
what the server tells it to do.  Your control should accept the size that the
server gives it.  What if you started creating pushbuttons on your dialog box
and they insisted on taking the entire size of your dialog rather than taking
up the space you told them to?

If the parent wants the control to take up a certain area, it will ask the
control nicely to do so.  The control shouldn't make any assumptions about how
big it should be.  If you're using the control in IE and it isn't as big as
you
want it to be, there's a problem with your HTML, not with your control.


.B ekiM
http://www.nwlink.com/~mikeblas/      <-- trip report central!
  Crotch Rocket   / Full-Body Rocket
95 Honda VFR-750F / 94 Mazda RX-7
         I am bored of this talk. It is time now for the dancing!
  These words are my own - I do not speak on behalf of Microsoft.





| Вернуться в корень Архива |