void CGridReportCtrl::SetDataSource(long hwnd)
{
char lpClassName[255];
//获取类名
if (::GetClassName((HWND)hwnd, lpClassName, 255))
{
CString strClassName;
strClassName+=lpClassName;
if(strClassName == "MSFlexGridWndClass")
{
CMSFlexGrid * m_pMSFlexGrid = (CMSFlexGrid *)CMSFlexGrid::FromHandle((HWND)hwnd);
if(m_pMSFlexGrid !=NULL)
{
long row = m_pMSFlexGrid->GetRows();
if (row <= 0) return;
long col = m_pMSFlexGrid->GetCols();
if (col <= 0) return ;
CString str1;
str1.Format("%d,%d",row,col);
AfxMessageBox(str1);
CString strText; for(int i=0;i<row;i++)
for(int j=0;j<col;j++)
{
strText=m_pMSFlexGrid->GetTextMatrix(i,j);
}
} }
}
}
这段代码如果不在控件中,和MSFlexGrid在一个程序里,运行结果是对的,但是放在控件中,行列值都不对,表格里的内容也得不到不知道哪里有问题?
{
char lpClassName[255];
//获取类名
if (::GetClassName((HWND)hwnd, lpClassName, 255))
{
CString strClassName;
strClassName+=lpClassName;
if(strClassName == "MSFlexGridWndClass")
{
CMSFlexGrid * m_pMSFlexGrid = (CMSFlexGrid *)CMSFlexGrid::FromHandle((HWND)hwnd);
if(m_pMSFlexGrid !=NULL)
{
long row = m_pMSFlexGrid->GetRows();
if (row <= 0) return;
long col = m_pMSFlexGrid->GetCols();
if (col <= 0) return ;
CString str1;
str1.Format("%d,%d",row,col);
AfxMessageBox(str1);
CString strText; for(int i=0;i<row;i++)
for(int j=0;j<col;j++)
{
strText=m_pMSFlexGrid->GetTextMatrix(i,j);
}
} }
}
}
这段代码如果不在控件中,和MSFlexGrid在一个程序里,运行结果是对的,但是放在控件中,行列值都不对,表格里的内容也得不到不知道哪里有问题?
解决方案 »
- 控件Create出来以后,可以改变字体吗?
- 请教OPCV中的分水岭算法
- 为什么我的程序显示不出来(编译器没有报错)
- vc 环境下关于teechart和teelistbox
- CDatabase读取mysql中数据时出现乱码
- 菜鸟问题?
- ListView视图中的LIST的问题
- Visual Studio.net 2003 和Visual Studio 2005 和VC6.0这几个编译器的侧重点分别是什么?
- 说一下你对《 深入浅出MFC 》2e 的看法
- 请教高手:怎样才能使一个局部临时表的作用域扩大为一个数据库连接的范围内?
- OLEDB 为什么不能执行带go的语句
- 图像变化和显示的一个问题,高手来看看,出来马上结帐!谢!
CGridReport m_rp;
CString s;
m_grid.SetRows(20);
m_grid.SetCols(11);
for (int a=0;a<20;a++)
{
for (int b=0;b<11;b++)
{
s.Format("Row %d, Col %d",a,b);
m_grid.SetTextMatrix(a,b,s);
}
}
unsigned long color[]={0x00ff0000,0x0000ff00,0x000000ff,0x00cc00ff,0x0000ccff,0x00ffffcc,0x002000aa,0x00ffccff,0x0020aab0,0x00b53589}; m_grid.SetRow(1);
for (a=1;a<11;a++)
{
m_grid.SetCol(a);
m_grid.SetCellBackColor(color[a-1]);
m_grid.SetCellForeColor(color[10-a]);
}//-----------------------------------------------------------------------------
测试
m_rp.SetDataSource((long)m_grid.GetHWnd());