描述:
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在一个程序里,运行结果是对的,但是放在控件中,行列值都不对,表格里的内容也得不到
不知道哪里有问题?