CWinFormsView has arbitrary minimum size?

  • Thread starter Thread starter MLM450
  • Start date Start date
M

MLM450

I am using CWinFormsView to host my C# control. When I resize the view
window to a larger size the control seems to grow with it just fine.
But when I shrink the size of the view, I get scroll bars. I don't want
scrollbars, I want the control to shrink.

In the .NET control, I have tried adjusting the minimum size and the
auto size mode properties. In my view, I have tried setting the
controls size when the view is resized. None of this has helped.

Any suggestions?

Thanks,
Mike
 
In case anybody else out there is struggling with this issue too, I
have found the solution. Apparently it is a bug that is not discussed
in the Micorosoft documentation. The only reference I can find on it is
in their CWinFormsView sample app. In OnInitialUpdate, add the
following code after the call to the parent's OnInitialUpdate.

// *** Workaround bottom dock initial sizing issue
System::Windows::Forms::ScrollableControl ^scrlCtrl =
dynamic_cast<System::Windows::Forms::ScrollableControl^>(GetControl());
if (scrlCtrl != nullptr)
{
CRect rcView;
GetClientRect(&rcView);
System::Drawing::Size size(0,0);
scrlCtrl->AutoScrollMinSize = size;
}
// *** End workaround
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top