I am resetting the size of a Form in a Control derived from Panel in the OnLayout handler after changing the control's size.
panel->ClientSize = size;
this->Parent->ClientSize =
System::Drawing::Size(
this->Parent->ClientSize.Width,
this->Parent->ClientSize.Height-difference);
Stepping through the code with the debugger shows that the change in location happens when the Form's ClientSize is changed. The Panel is NOT Anchored to the Form.
The problem I'm having is that this causes the controls location to change.
>>> FormPanel::layoutPanel - {X=604,Y=0}{Width=766, Height=250}
FormPanel::layoutPanel Height set - {X=604,Y=0}{Width开发者_高级运维=766, Height=217}
FormPanel - OnSizeChanged:{X=604,Y=0}{Width=766, Height=217}
FormPanel - OnLocationChanged:{X=604,Y=-17}{Width=766, Height=217}
FormPanel - OnMove:{X=604,Y=-17}{Width=766, Height=217}
Setting Form1->ClientSize = {Width=1370, Height=217}
<<< FormPanel::layoutPanel - {X=604,Y=-17}{Width=766, Height=217}
I get two events and the control has moved to Y = -17.
The questions I have are:
1) What is the difference between OnLocationChanged and OnMove?
2) Why has it moved?
3) Am I doing anything wrong here?
I would check to see how the control is anchored to it's parent.
精彩评论