<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="zafir anjum">
<title>mfc programmer's sourcebook : advanced ui</title>
<meta name="description" content="source code for implementing advanced ui features">
<meta name="keywords" content>
</head>
<body background="../di2001.jpg"
tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#ffffff">
<h3 align="center"><font color="#aoao99">advanced ui - mdi list in the status bar (and a
custom window list dialog)</font></h3>
<hr align="center">
<p>this article was contributed by <a href="mailto:warch@tin.it">iuri apollonio</a>. </p>
<p><a href="tabstatus.zip" tppabs="http://www.codeguru.com/advancedui/tabstatus.zip">download
demo</a> 141k <br>
<br>
<img src="tabstatus.gif" tppabs="http://www.codeguru.com/advancedui/tabstatus.gif"
width="400" height="287" alt="tabstatus.gif (6k)"><br>
<br>
</p>
<h4>1. what is this ?</h4>
<p>some time ago, carlos alberto silva asked me for a way to display in the window dialog
list different names from the ones in title bar. we end up with this thing: it's basically
a replacement for the standard window list dialog (the one from the window menu, i mean)
and a tab control inserted in the status bar acting like the start menu bar.<br>
the title of the mdi windows can be different from the one displayed in the title bar.<br>
</p>
<h4>2. how to implement this thing</h4>
<p>you'll need to add to your project those classes:<br>
<ul>
<li>cviewmanager</li>
<li><br>
</li>
<li>cwindowlistdlg</li>
<li><br>
</li>
<li>cwindowtabctrl</li>
<li><br>
</li>
</ul>
<p>the cwindowlistdlg is a dialog resource, so add it using the standard add components
way or manually copy its dialog template resource.<br>
now inlude in the view cpp file and in the mainframe cpp this header:<br>
<font color="#990000"></p>
<pre>
#include "viewmanager.h"
</font></pre>
<p>in the mainframe, get an handler for the wm_close message and write this:<br>
<font color="#990000"></p>
<pre>
void cmainframe::onclose()
{
theviewmanager.removeall();
theviewmanager.bclosing = true;
cmdiframewnd::onclose();
}
</font></pre>
<p>in the view contructor, add this line:<br>
<font color="#990000"></p>
<pre>
cmdiwindlistview::cmdiwindlistview()
{
theviewmanager.addview("", this);
}
</font></pre>
<p>and it the view destructor, this one:<br>
<font color="#990000"></p>
<pre>
cmdiwindlistview::~cmdiwindlistview()
{
theviewmanager.removeview(this);
}
</font></pre>
<p>last, in the view oninitialupdate we can define the view name:<br>
<font color="#990000"></p>
<pre>
void cmdiwindlistview::oninitialupdate()
{
cview::oninitialupdate();
cmdiwindlistdoc * pdoc = getdocument();
cstring cs = pdoc->gettitle();
cs += " -with custom text for window list";
theviewmanager.setviewname(cs, this);
}
</font></pre>
<p>with the setviewname function we give the name we want to be displayed in the status
bar and in the window dialog list. if the standard name is good, simply pass the
document.gettitle() text. you'll need to call this function every time the title of your
view changes (usually after a save).<br>
</p>
<h4>3. adding the status bar</h4>
<p>if we want the status bar like the desktop bar, we'll need to do this modify to the
mainframe.<br>
first add in the cmainframe::oncreate this line:<br>
<font color="#990000">thewindowtab.create(ws_child|ws_visible|tcs_buttons|tcs_fixedwidth|tcs_singleline|tcs_forcelabelleft,
crect(0,0,0,0), &m_wndstatusbar, 1000); </font>change the 1000 used as hardcode value
for the tab control as you like; it's not good practice to hard code the controls value.<br>
then, get an handler for the wm_size message and write this:<br>
<font color="#990000"></p>
<pre>
void cmainframe::onsize(uint ntype, int cx, int cy)
{
cmdiframewnd::onsize(ntype, cx, cy);
if (m_wndstatusbar.getsafehwnd() && thewindowtab.getsafehwnd())
{
crect rc;
m_wndstatusbar.getitemrect(0, rc);
thewindowtab.setwindowpos(0,rc.left,rc.top,rc.width(), rc.height(), swp_nozorder);
}
}
</font></pre>
<p>in this sample, i putted the tab control containing the windows in the status bar first
pane; if you want it to be as large as the status bar, try this:<br>
<font color="#990000"></p>
<pre>
if (m_wndstatusbar.getsafehwnd() && thewindowtab.getsafehwnd())
{
crect rc;
m_wndstatusbar.getwindowrect(rc);
m_wndstatusbar.screentoclient(rc);
thewindowtab.setwindowpos(0,0,0,rc.width(), rc.height(), swp_nozorder);
}
</font></pre>
<p>or, if you want to put the tab in another pane, simply change the index of the
statusbar.getitemrect.<br>
</p>
<h4>4. the custom window list dialog</h4>
<p>the custom window list dialog is invoked with the function:<br>
<font color="#990000"></p>
<pre>
theviewmanager.dowindowlist();
</font></pre>
<p>simply make a menu item named "my window list", handle it in mainframe and
call the function above.<br>
<br>
that's all. the code is mine, the concept is of <a href="mailto:csilva@unisys.com.br">carlos</a>.
enjoy! </p>
<p>last updated: 2 july 1998 </p>
<!--comments-->
</body>
</html>
状态条中加入子窗口的列表
需积分: 50 126 浏览量
2000-12-14
00:00:00
上传
评论 1
收藏 70B ZIP 举报
普通网友
- 粉丝: 882
- 资源: 2万+
最新资源
- 1040g0cg310ravpiu6ibg5pg00tsipsln3ju2d0g 2
- 基于Python的SAR图像去噪CNN-NLM设计源码
- redhat6升级到redhat7,过程redhat6.x-> redhat6.10->rehat7.9 主版本最高版本
- 基于Django的流程引擎设计源码
- 基于Node.js的Express框架与MySQL的后台管理系统设计源码
- 基于Java的Flink流批一体数据处理快速集成开发框架设计源码
- FirstFilterOrderCompare
- Screenshot_2024-03-28-19-17-25-020_com.ss.android.lark.jpg
- 基于Java的车辆违章信息查询系统设计源码
- wqeAFSDADWDAESD
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈