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
;
}
}
}
}
查看全文
相关阅读:
在Ubuntu11.10中安装OpenCV2.3.1的详细步骤
基于二元语法模型的中文分词
相似图片搜索的原理
基于GPU的KMeans聚类算法
Windows下Eclipse和PyDev搭建完美Python开发环境
Ubuntu 11.10+win7双系统启动项管理及配置方法
主题爬虫
vue定义全局过滤器
element elimage 放多张图片,显示大图
element UI的form 禁止浏览器自动填充用户名或密码
原文地址:https://www.cnblogs.com/RChen/p/161379.html
最新文章
MD5算法的C++实现
linux下SystemC安装以及VS2010下SystemC的使用
素数寻找
GDI+部分知识点总结
5 Great Graduation Speech Quotes
Winform全球化
Win8 MSDN 简中/繁中/英文正式版下载(微软官方原版)
可视区域变换
visual studio开发环境颜色字体设置
C#交错数组
热门文章
vs2010 sp1 Help Library Manager安装说明
[网购指北]
C# 资源文件 图片引用
【C语言基础】从1开始加到100
【C基础】编译后在Windows运行解决一闪而过
HTTP协议那些事儿(Web开发补充知识点)
Bloom_filter算法(zz)
作为程序员的出路
已知二叉树的中序和前序序列(或后序)求解树
GPU通用计算调研报告
Copyright © 2011-2022 走看看