
Signature
Marcus Kwok
Replace 'invalid' with 'net' to reply
> I have a Form that has a PictureBox in it that has a dock style set to
> "fill". I can set the PictureBox's PictureBoxSizeMode to StretchImage,
[quoted text clipped - 9 lines]
> I am writing in Managed C++ (.NET 1.1) but in the past I have not had
> much difficulty translating code from VB.NET or C# into Managed C++.
The example code at
<http://tinyurl.com/mc9wn>
=
<http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsContro
lClassResizeTopic.asp>
should point you in the right direction.

Signature
Larry Lard
Replies to group please
Marcus Kwok - 25 Apr 2006 17:24 GMT
>> I have a Form that has a PictureBox in it that has a dock style set to
>> "fill". I can set the PictureBox's PictureBoxSizeMode to StretchImage,
[quoted text clipped - 17 lines]
>
> should point you in the right direction.
Thanks for the link. Keeping the window square is easy and works.
However, I am having problems with my method:
I added a double to the class called aspect_ratio.
In the constructor, I calculate
aspect_ratio = static_cast<double>(image->Width) / static_cast<double>(image->Height);
Then in the Resize event handler:
System::Void PlotDisplayWindow_Resize(System::Object * sender, System::EventArgs * e)
{
Control* control = __try_cast<Control*>(sender);
// Looking at this, I think I need Height instead of Width, but the
// concept is what's important
control->Size = System::Drawing::Size(static_cast<int>(aspect_ratio * control->Size.Width), control->Size.Width);
}
When I do this and try to resize the form, I get a flickering of
rectangles of the appropriate aspect ratio as I drag the border of the
frame, but as soon as I let go of the border then the window snaps back
to its original size.

Signature
Marcus Kwok
Replace 'invalid' with 'net' to reply