autofit_header.shtml.htm
来自「mfc资料集合5」· HTM 代码 · 共 52 行
HTM
52 行
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Zafir Anjum">
<TITLE>Controls - Autofit Header Control</TITLE>
</HEAD>
<body background="../fancyhome/back.gif" tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000">
<table WIDTH="100%">
<tr WIDTH="100%">
<td><td>
</tr>
</table>
<CENTER><H3><FONT COLOR="#AOAO99">Autofit Header Control</FONT></H3></CENTER>
<HR>
This article was contributed by <A HREF="mailto:baldvin@trafficsoftware.com">Baldvin Hansson</A>.
<p>The Header Common Control has a lot of functionality but can still be improved quite a bit.
One thing I've always missed is to be able to automatically resize it's columns so that they
occupy the entire width of the control. The following class inherits from CHeaderCtrl and
adds exactly this feature to the Header Control. All you have to do is to insert the columns
you want and then call the SetAutofit method. From there on all columns are resized proportionally
to their existing size when the size of the control changes or when the user drags a column
header divider.<br>
<br>
There is still lot of room for improvements. If you find this class useful and make any modifications
to it I would appreciate if you'd send me a note with the changes so that we can continue to improve
this document. It's much better than posting an alternate version all together. I'll be glad to merge
any such improvements into the basic idea.
</p>
<p>For information on how to add this header control class to your listview for example, refer to
the article <a href="../listview/header_ctrl.shtml.htm" tppabs="http://www.codeguru.com/listview/header_ctrl.shtml">"The Header Control"</a> under the ListView category.</p>
<p>
<b>HeaderAutofit.h</b>
<PRE><TT><FONT COLOR="#990000">
#if !defined(AFX_HEADERAUTOFIT_H__B2BEAB04_6276_11D1_875B_00A0C9181E86__INCLUDED_)
#define AFX_HEADERAUTOFIT_H__B2BEAB04_6276_11D1_875B_00A0C9181E86__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// HeaderAutofit.h : header file
//
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?