CProgressCtrlST 1.1






4.38/5 (9投票s)
2002年9月4日
3分钟阅读

106791

5820
一个位图进度条控件
SoftechSoftware 主页
SoftechSoftware 电子邮件
摘要
CProgressCtrlST
是从 MFC CProgressCtrl 类派生的类。使用此类,您的应用程序可以使用位图作为进度条,就像在许多现代安装程序和游戏中看到的那样!
CProgressCtrlST 功能
- 易于使用
- 标准 CProgressCtrl 方法
- 支持 256+ 颜色位图
- 支持负范围
- 支持垂直进度控制
- 包含完整的源代码!
- 在现有应用程序中实现成本为零
如何在您的应用程序中集成 CProgressCtrlST
在你的项目中包含以下文件
- ProgressCtrlST.h
- ProgressCtrlST.cpp
Tile.bmp
并将其称为 IDB_TILE。使用对话框编辑器创建一个名为,例如, IDC_TILED 的进度控件。然后为此进度控件创建一个成员变量
CProgressCtrlST m_progressTiled;现在将进度控件附加到 CProgressCtrlST。对于基于对话框的应用程序,在您的 OnInitDialog 中
// Call the base-class method CDialog::OnInitDialog(); // Create the IDC_TILED progress control m_progressTiled.SubclassDlgItem(IDC_TILED, this);或在您的 DoDataExchange 中
// Call the base method CDialog::DoDataExchange(pDX); // Create the IDC_TILED progress control DDX_Control(pDX, IDC_TILED, m_progressTiled);该控件将具有与基本 MFC 类 CProgressCtrl 中相同的默认范围和起始位置。可以使用基类的相同方法修改这些值,例如,
SetRange
或 SetPos
。目前不支持 OffsetPos
。默认情况下,控件将像普通进度条一样绘制自身。可以分配一个位图,以获取显示它的进度条,而不是正常的标准块!
将平铺此位图以绘制进度条的必要部分;不会以任何方式缩小或放大它。
将位图分配给进度条
// Assign a bitmap m_progressTiled.SetBitmap(IDB_TILE);您的进度控制现在是一个 CProgressCtrlST!
类方法
SetBitmap
设置用于绘制进度条的位图。
// Parameters: // [IN] nBitmap // Resource ID of the bitmap to use as background. // Pass NULL to remove any previous bitmap. // [IN] bRepaint // If TRUE the control will be repainted. // // Return value: // PROGRESSST_OK // Function executed successfully. // PROGRESSST_INVALIDRESOURCE // The resource specified cannot be found or loaded. // DWORD SetBitmap(int nBitmap, BOOL bRepaint = TRUE)SetBitmap
设置用于绘制进度条的位图。
// Parameters: // [IN] hBitmap // Handle to the bitmap to use as background. // Pass NULL to remove any previous bitmap. // [IN] bRepaint // If TRUE the control will be repainted. // // Return value: // PROGRESSST_OK // Function executed successfully. // PROGRESSST_INVALIDRESOURCE // The resource specified cannot be found or loaded. // DWORD SetBitmap(HBITMAP hBitmap, BOOL bRepaint = TRUE)SetRange
设置进度条控件范围的上限和下限,并重新绘制条以反映新范围。
// Parameters: // [IN] nLower // Specifies the lower limit of the range (default is zero). // [IN] nUpper // Specifies the upper limit of the range (default is 100). // void SetRange(int nLower, int nUpper)SetStep
指定进度条控件的步长增量。
步长增量是调用 StepIt 增加进度条当前位置的量。
// Parameters: // [IN] nStep // New step increment. // // Return value: // The previous step increment. // int SetStep(int nStep)SetPos
设置进度条控件的当前位置(由 nPos 指定)并重新绘制条以反映新位置。
进度条控件的位置不是屏幕上的物理位置,而是在 SetRange 中指示的上限和下限之间。
// Parameters: // [IN] nPos // New position of the progress bar control. // // Return value: // The previous position of the progress bar control. // int SetPos(int nPos)StepIt
将进度条控件的当前位置按步长增量前进,并重新绘制条以反映新位置。
步长增量由 SetStep 方法设置。
// Return value: // The previous position of the progress bar control. // int StepIt()OnDrawText
每次重新绘制进度条时都会调用此函数。
它是一个虚拟函数,允许派生类进行自定义绘图。
默认实现不执行任何操作。
// Parameters: // [IN] pDC // Pointer to the device context. // [IN] nPercentage // Current percentage of the progress bar. // [IN] rcCtrl // A CRect object that indicates the dimensions of the entire control. // [IN] rcProgress // A CRect object that indicates the dimensions of the currently displayed bar. // [IN] bVertical // TRUE if the progress is vertical, otherwise FALSE. // virtual void OnDrawText(CDC* pDC, int nPercentage, CRect rcCtrl, CRect rcProgress, BOOL bVertical)GetVersionI
以短数值形式返回类版本。
// Return value: // Class version. Divide by 10 to get actual version. // static short GetVersionI()GetVersionC
以字符串值的形式返回类版本。
// Return value: // Pointer to a null-terminated string containig the class version. // static LPCTSTR GetVersionC()
历史
- v1.1 (2002年8月27日)
类名更改为 CProgressCtrlST
添加了对垂直进度控制的支持 - v1.0 (1999年1月1日)
首次发布
免责声明
本软件和随附文件按“原样”分发,不附带任何明示或暗示的保证。对可能造成的损害甚至功能不承担任何责任。用户必须承担使用本软件的全部风险。