<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>
没有合适的资源?快使用搜索试试~ 我知道了~
状态条中加入子窗口的列表
共2个文件
gif:1个
htm:1个
需积分: 50 44 下载量 156 浏览量
2000-12-14
00:00:00
上传
评论 1
收藏 70B ZIP 举报
温馨提示
在多文档应用程序的状态条中加入子窗口的列表, 使程序的状态条有点像Windows 95的任务条.
资源推荐
资源详情
资源评论
收起资源包目录
tabstatus.zip (2个子文件)
tabstatus.gif 7KB
tabstatus.shtml.htm 5KB
共 2 条
- 1
资源评论
普通网友
- 粉丝: 882
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功