zoukankan
html css js c++ java
挖一下 SuspendLayout, ResumeLayout 的原理
最近看到一些 winform 控件的写法里面,在设定 DockStyle 或者增减子控件的时候,往往先调用 SuspendLayout 方法,操作完毕之后调用一下 ResumeLayout. 不太明白其中的道理。所以用 Reflector 来看一下。
代码在 System.Windows.Forms.Control 中。
做一个简单的记录如下:
public
void
SuspendLayout()
{
this
.layoutSuspendCount
=
(
byte
) (
this
.layoutSuspendCount
+
1
);
}
public
void
ResumeLayout()
{
this
.ResumeLayout(
true
);
}
public
void
ResumeLayout(
bool
performLayout)
{
if
(
this
.layoutSuspendCount
>
0
)
{
this
.layoutSuspendCount
=
(
byte
) (
this
.layoutSuspendCount
-
1
);
if
(((
this
.layoutSuspendCount
==
0
)
&&
((
this
.state
&
0x200
)
!=
0
))
&&
performLayout)
{
this
.PerformLayout();
}
}
if
(
!
performLayout)
{
Control.ControlCollection collection1
=
(Control.ControlCollection)
this
.Properties.GetObject(Control.PropControlsCollection);
if
(collection1
!=
null
)
{
for
(
int
num1
=
0
; num1
<
collection1.Count; num1
++
)
{
Control.LayoutManager.UpdateAnchorInfo(collection1[num1]);
}
}
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public
void
PerformLayout()
{
this
.PerformLayout(
null
,
null
);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public
void
PerformLayout(Control affectedControl,
string
affectedProperty)
{
if
(
!
this
.GetAnyDisposingInHierarchy())
{
if
(
this
.layoutSuspendCount
>
0
)
{
this
.state
|=
0x200
;
}
else
{
this
.layoutSuspendCount
=
1
;
try
{
this
.OnLayout(
new
LayoutEventArgs(affectedControl, affectedProperty));
}
finally
{
this
.state
&=
-
513
;
this
.layoutSuspendCount
=
0
;
}
}
}
}
查看全文
相关阅读:
放大镜功能
background兼容IE9以下版本
JSON解析
vue.js 组件-全局组件和局部组件
i++ ++i的原子性
【转】程序员面试笔试宝典
【转】函数调用栈 格式化操作
【转】TCP三次握手过程
一些面试题
【转】HP(惠普)大中华区总裁孙振耀退休感言
原文地址:https://www.cnblogs.com/RChen/p/161379.html
最新文章
Ill-conditioned covariance create
21副GIF动图让你了解各种数学概念
[zz]计算 协方差矩阵
EM算法 The EM Algorithm
Kubernetes集群安全配置案例
etcd 命令行
etcd集群部署与遇到的坑
flume监控
flume 配置说明
hive on spark
热门文章
Golang开发环境搭建-Vim篇
KMP算法
docker1.9 network跨主机安装
shipyard安装
父组件调用子组件
vue 样式渲染,添加删除元素
vue 组件注册
vue环境搭建
图片懒加载 jquery.lazyload
图片拖曳
Copyright © 2011-2022 走看看