有一个标签label1.capion:=1;
定义hh为全局变量
然后添加form的onresize事件,如下:
hh:=hh+strtoint(label1.Caption);
label1.caption:=inttostr(hh);
运行程序
label1便显示成了2
然后每改变窗口大小一次,label1中的数值便为8 然后再拖动一次,又变成了64 ,512,4096,16384……
呵呵,onresize的工作原理到底是什么哦,搞不懂了
还有,怎么才能做到程序运行的时候,label1显示原来的 1 ,在拖动之后,变成2。
请问如何做到呢,谢谢。
另外,请问onCanResize和onresize有什么区别?谢谢!
程序運行結果是正確的,
1 + 1 = 2
2 + 2 = 4
4 + 4 = 8
........
onCanResize
Occurs when an attempt is made to resize the control.
property OnCanResize: TCanResizeEvent;
Use OnCanResize to adjust the way a control is resized. If necessary, change the new width and height of the control in the OnCanResize event handler. The OnCanResize event handler also allows applications to indicate that the entire resize should be aborted.
If there is no OnCanResize event handler, or if the OnCanResize event handler indicates that the resize attempt can proceed, the OnCanResize event is followed immediately by an OnConstrainedResize event.
OnResize
Occurs immediately after the control is resized.
property OnResize: TNotifyEvent;
Use OnResize to make any final adjustments after a control is resized.
To modify the way a control responds when an attempt is made to resize it, use the OnCanResize or OnConstrainedResize events instead.
onresize
顾名思义就是大小改变时将执行的事件。