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
;
}
}
}
}
查看全文
相关阅读:
Web应用程序使用Hibernate
Hibernate使用注释
Hibernate入门程序
Hibernate体系结构
Spring MVC文件上传教程
Spring MVC配置静态资源和资源包教程
Spring MVC4使用Servlet3 MultiPartConfigElement文件上传实例
Spring4 MVC文件下载实例
Spring4 MVC+Hibernate4 Many-to-many连接表+MySQL+Maven实例
Spring4 MVC+Hibernate4+MySQL+Maven使用注解集成实例
原文地址:https://www.cnblogs.com/RChen/p/161379.html
最新文章
[Algorithm] 234. Palindrome Linked List / Reverse linked list
[XState] Invoke Child XState Machines from a Parent Machine
[XState] Invoke Callbacks to Send and Receive Events from a Parent XState Machine
[XState] Invoking a Promise for Asynchronous State Transitions in XState
[XState] Delay XState Events and Transitions
我把大三给了谁
工作那些事(十一)谈谈码农与农民工区别和发展之路
ios游戏开发 Sprite Kit教程:初学者 1
oc 内存管理
CUDA常见问题之无法在c文件中调用cu文件中定义的函数
热门文章
UVA10361
《深入理解计算机系统》--异常控制流
TQ210裸机编程(4)——按键(中断法)
Android流量监控 思路,想法
Hibernate继承映射
Hibernate快速入门
Hibernate二级缓存
Hibernate使用Log4j日志记录(使用properties文件)
Hibernate使用Log4j日志记录(使用xml文件)
Hibernate生成器类
Copyright © 2011-2022 走看看