FlexCell in SDI
来源:互联网 发布:风油精提神 知乎 编辑:程序博客网 时间:2024/05/19 23:24
FlexCell 是一款国产的网格、报表控件,其用法比较简单,特性也比较丰富。下面演示如何在一个单文档应用中使用 FlexCell。
1、新建工程
应用类型为 SDI(Single document),名称为 TF1。
2、添加 FlexCell 控件
选择菜单项“Project > Add to Project > Components and Controls”,弹出“Components and Controls Gallery”对话框。选择“Registered ActiveX Controls”文件夹。双击 FlexCell.Grid,弹出“Insert this components?”消息框。点【确定】按钮,弹出“Confirm Classes”对话框,点【OK】按钮。最后关闭“Components and Controls Gallery”对话框。
3、编程
3.1 包含头文件
打开 StdAfx.h,在 #endif // _AFX_NO_AFXCMN_SUPPORT 后添加:
#include "_grid.h"
#include "_cell.h"
3.2 在视图类中定义网格变量
打开 TF1View.h,在 // Attributes 后添加:
private:
C_Grid* m_pGrid;
3.3 构造与析构
CTF1View::CTF1View()
{
m_pGrid = NULL;
}
CTF1View::~CTF1View()
{
if (m_pGrid)
delete m_pGrid;
}
3.4 创建网格
如果视图类没有 OnInitialUpdate 函数,就需要覆盖这个虚函数。选择 Workspace 窗口中的 ClassView 页。右键单击 CTF1View,选择“Add Virtual Function”,弹出“New Virtual Override for class CTF1View”对话框。双击“New Virtual Functions”下的“OnInitialUpdate”,“OnInitialUpdate”会出现在右边的“Existing virtual function overrides”下。单击【Edit Existing】按钮,编辑代码。
void CTF1View::OnInitialUpdate()
{
CView::OnInitialUpdate();
if (m_pGrid == NULL)
{
// Create the Gridctrl object
m_pGrid = new C_Grid;
if (!m_pGrid) return;
// Create the Gridctrl window
CRect rect;
GetClientRect(rect);
if ( m_pGrid->Create(_T(""), WS_CHILD | WS_VISIBLE, rect, this, 120) )
{
// Register the FlexCell
m_pGrid->SetRegisterInformation(_T("***"), _T("***")); 注册码保密
m_pGrid->SetAutoRedraw(FALSE);
m_pGrid->SetRows(6);
m_pGrid->SetCols(8);
m_pGrid->SetDisplayFocusRect(FALSE);
//m_pGrid->SetExtendLastCol(TRUE);
// Column Headers
m_pGrid->Cell(0, 1).SetText(_T("Mon"));
m_pGrid->Cell(0, 2).SetText(_T("Tue"));
m_pGrid->Cell(0, 3).SetText(_T("Thu"));
m_pGrid->Cell(0, 4).SetText(_T("Wed"));
m_pGrid->Cell(0, 5).SetText(_T("Fri"));
m_pGrid->Cell(0, 6).SetText(_T("Sat"));
m_pGrid->Cell(0, 7).SetText(_T("Sun"));
// Populate items
for (int i = 0; i < 31; i++)
{
CString strCell;
strCell.Format(_T("%d"), i + 1);
m_pGrid->Cell(i / 7 + 1, i % 7 + 1).SetText(strCell);
}
m_pGrid->SetAutoRedraw(TRUE);
}
else
{
AfxMessageBox(_T("m_pGrid->Create() failed!"));
}
}
}
3.5 大小变化
如果视图类没有 OnSize 函数,就需要添加处理函数。在 ClassView 页中,右键单击 CTF1View,选择“Add Windows Message Handler”,弹出“New Windows Message and Event Handlers for class CTF1View”对话框。双击“New Windows messages/events”下的“WM_SIZE”,“WM_SIZE”会出现在右边的“Existing message/event handlers”下。单击【Edit Existing】按钮,编辑代码。
void CTF1View::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
if (m_pGrid->GetSafeHwnd())
{
CRect rect;
GetClientRect(rect);
m_pGrid->MoveWindow(rect);
m_pGrid->UpdateWindow();
m_pGrid->ShowWindow(SW_SHOW);
}
}
4、运行效果
1、新建工程
应用类型为 SDI(Single document),名称为 TF1。
2、添加 FlexCell 控件
选择菜单项“Project > Add to Project > Components and Controls”,弹出“Components and Controls Gallery”对话框。选择“Registered ActiveX Controls”文件夹。双击 FlexCell.Grid,弹出“Insert this components?”消息框。点【确定】按钮,弹出“Confirm Classes”对话框,点【OK】按钮。最后关闭“Components and Controls Gallery”对话框。
3、编程
3.1 包含头文件
打开 StdAfx.h,在 #endif // _AFX_NO_AFXCMN_SUPPORT 后添加:
#include "_grid.h"
#include "_cell.h"
3.2 在视图类中定义网格变量
打开 TF1View.h,在 // Attributes 后添加:
private:
C_Grid* m_pGrid;
3.3 构造与析构
CTF1View::CTF1View()
{
m_pGrid = NULL;
}
CTF1View::~CTF1View()
{
if (m_pGrid)
delete m_pGrid;
}
3.4 创建网格
如果视图类没有 OnInitialUpdate 函数,就需要覆盖这个虚函数。选择 Workspace 窗口中的 ClassView 页。右键单击 CTF1View,选择“Add Virtual Function”,弹出“New Virtual Override for class CTF1View”对话框。双击“New Virtual Functions”下的“OnInitialUpdate”,“OnInitialUpdate”会出现在右边的“Existing virtual function overrides”下。单击【Edit Existing】按钮,编辑代码。
void CTF1View::OnInitialUpdate()
{
CView::OnInitialUpdate();
if (m_pGrid == NULL)
{
// Create the Gridctrl object
m_pGrid = new C_Grid;
if (!m_pGrid) return;
// Create the Gridctrl window
CRect rect;
GetClientRect(rect);
if ( m_pGrid->Create(_T(""), WS_CHILD | WS_VISIBLE, rect, this, 120) )
{
// Register the FlexCell
m_pGrid->SetRegisterInformation(_T("***"), _T("***")); 注册码保密
m_pGrid->SetAutoRedraw(FALSE);
m_pGrid->SetRows(6);
m_pGrid->SetCols(8);
m_pGrid->SetDisplayFocusRect(FALSE);
//m_pGrid->SetExtendLastCol(TRUE);
// Column Headers
m_pGrid->Cell(0, 1).SetText(_T("Mon"));
m_pGrid->Cell(0, 2).SetText(_T("Tue"));
m_pGrid->Cell(0, 3).SetText(_T("Thu"));
m_pGrid->Cell(0, 4).SetText(_T("Wed"));
m_pGrid->Cell(0, 5).SetText(_T("Fri"));
m_pGrid->Cell(0, 6).SetText(_T("Sat"));
m_pGrid->Cell(0, 7).SetText(_T("Sun"));
// Populate items
for (int i = 0; i < 31; i++)
{
CString strCell;
strCell.Format(_T("%d"), i + 1);
m_pGrid->Cell(i / 7 + 1, i % 7 + 1).SetText(strCell);
}
m_pGrid->SetAutoRedraw(TRUE);
}
else
{
AfxMessageBox(_T("m_pGrid->Create() failed!"));
}
}
}
3.5 大小变化
如果视图类没有 OnSize 函数,就需要添加处理函数。在 ClassView 页中,右键单击 CTF1View,选择“Add Windows Message Handler”,弹出“New Windows Message and Event Handlers for class CTF1View”对话框。双击“New Windows messages/events”下的“WM_SIZE”,“WM_SIZE”会出现在右边的“Existing message/event handlers”下。单击【Edit Existing】按钮,编辑代码。
void CTF1View::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
if (m_pGrid->GetSafeHwnd())
{
CRect rect;
GetClientRect(rect);
m_pGrid->MoveWindow(rect);
m_pGrid->UpdateWindow();
m_pGrid->ShowWindow(SW_SHOW);
}
}
4、运行效果
“Ctrl + F5”运行程序,效果如图
0 0
- FlexCell in SDI
- SDI
- VS2010/MFC flexcell使用
- FlexCell用户自定义打印模板
- 有关flexCell属性的设置
- SDI全屏
- dephiMDI&SDI
- SDI接口
- SDI Frame
- SDI接口
- SDI编码器
- SDI延迟
- SDI-GS2971
- 关于FlexCell控件的SelectionMode属性(选择模式)的说明
- ADOQuery返回值用TGrid单元合并(FlexCell插件)
- ListView On SDI
- 在SDI中做多视转换
- SDI多视图切换
- html5新功能---拖放
- 卷积神经网络的学习资料
- 虚拟机屏幕太小 如何调整?
- POJ 1189 钉子和小球
- android开发之android性能优化的方法
- FlexCell in SDI
- SSO单点登录、跨域重定向、跨域设置Cookie、京东单点登录实例分析
- Hibernate主键生成方式详解( Key Generator)
- 广州传智播客老师现场授课.Net实战培训
- hdfs benchmark
- Linux系统--route命令详解
- JAVA单例类的线程安全最简洁有效的写法
- Linux编译sip库及第一个demo
- Oracle Read-only Tablespace(只读表空间)