Setting a Forms ClientSize changes the Location of the control
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?
我会检查控件是如何锚定到它的父项。
链接地址: http://www.djcxy.com/p/58370.html上一篇: 在重新控制时移动表单的内容