最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net C#中父窗口及其子窗口标题调用方法
时间:2011-03-22 编辑:简简单单 来源:一聚教程网
如果用纯 c 代码编写,那么必须自己负责用 defframeproc 和 defmdichildproc 创建窗口;在 mfc 中则使用 cmdiframewnd/cmdichildwnd;.net 框架平台里则设置 form.ismdicontainer 和 form.mdiparent,不管用哪种方式,其核心都是 user kernel,尤其是 defframeproc,当 mdi 子窗口最大化时,它会联接父子窗口的标题文本来产生主窗口标题串。理解了这一点,下面我来示范如何改写mdi。这个例子的原始版本来自 msdn 库中用c#写的 scribble mdi(用 “scribble sample”搜索一下即可找到)。基本思路是首先在 scribble 例子的 mainwindow 中改写 wm_gettext 消息处理例程,必须添加两个数据成员:normaltext 和 maximizedtext,用它们来保存常态和最大化状态的标题 :
private string normaltext = "scribble2";
private string maximizedtext = "window is now maximized";
public string normaltext
{
get { return normaltext; }
set { normaltext = value; }
}
{
private string normaltext = "scribble2";
private string maximizedtext = "window is now maximized";
// handle wm_gettext: return maximized or
// normal text, depending on
// state of active mdi child window.
protected override void wndproc(ref message m)
{
const int wm_gettext = 0x000d;
if (m.msg==wm_gettext) {
form active = this.activemdichild;
string s = active!=null &&
active.windowstate==formwindowstate.maximized ? maximizedtext :
normaltext;
char[] c = s.tochararray();
intptr buf = m.lparam;
int len = c.length;
marshal.copy(c, 0, buf, math.min((int)m.wparam, len));
m.result = (intptr)len;
return;
}
base.wndproc(ref m);
}
...... // rest of mainwindow unchanged from scribble sample
}
-
上一个: .net生成静态页面原理与代码
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10