⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gridmethods.cpp

📁 The PCI Local bus concept was developed to break the PC data I/O bottleneck and clearly opens the d
💻 CPP
字号:
//----------------------------------------------------------------------------
//
// Module Name:         GridMethods.cpp
// Module Description:  Wrapper methods for ActiveX GridControl - use these
//						for creating/modifying a grid using both Visual C++ 
//						and MFC 4.2.  The gridctrl.h file generated through 
//						ClassWizard for the ActiveX GridControl is required 
//						for this wrapper.
//
// Usage Notes/Restrictions:
//    Copyright 1999 Cimaron, All rights reserved
//
// Date		 Author           Comment
// ----      ------           ------
// 10-12-99  P. de Sa'	      Initial Revision
//
//----------------------------------------------------------------------------


#include "stdafx.h"
#include "GridMethods.h"

//-----------------------------------------------------------------
// CGridMethods
//
// This is the constructor for the CGridMethods class.
//-----------------------------------------------------------------
CGridMethods::CGridMethods(void)
{
	// your ad here
}

//-----------------------------------------------------------------
// ~CGridMethods
//
// This is the destructor for the CGridMethods class.
//-----------------------------------------------------------------
CGridMethods::~CGridMethods()
{
	// your ad here
}

//-----------------------------------------------------------------
// bInitializeGrid
//
// This method is a wrapper to initialize an ActiveX Grid Control.
// The calling method needs to have access to a CGridCtrl object
// (through ClassWizard->Member Variables or other means) and must
// pass a handle to that object to this method.  The calling
// method must pass the number of rows and columns required in the
// grid, as well as the number of fixed rows and columns.
//-----------------------------------------------------------------
bool CGridMethods::bInitializeGrid(CGridCtrl *grid, const short iRows, const short iCols, 
								   const short iFixedRows, const short iFixedCols)
{
	short i;

	grid->SetRows(iRows);
	grid->SetCols(iCols);
	grid->SetFixedRows(iFixedRows);
	grid->SetFixedCols(iFixedCols);

	// Adjust column sizes
	for(i = 0; i < iCols; i++)
	{
		grid->SetColWidth(i, 1000);
	}

	return(true);
}

//-----------------------------------------------------------------
// bSetGridValueString
//
// This method is a wrapper to write to an ActiveX Grid Control.
// The calling method needs to have access to a CGridCtrl object
// (through ClassWizard->Member Variables or other means) and must
// pass a handle to that object to this method.  The calling
// method must pass the row and column location where the data
// will be written as well as the data itself (in string format).
//-----------------------------------------------------------------
bool CGridMethods::bSetGridValueString(CGridCtrl *grid, const short sRowNumber, 
									   const short sColNumber, CString szData)
{
	short sNumRows;
	short sNumCols;

	sNumRows = grid->GetRows();
	sNumCols = grid->GetCols();

	// Add data items to the main portion of the grid - notice it looks the
	// same as entering data in the fixed portion of the grid
	
	// This method will return false if a negative row or column is
	// entered here.  This method will also return false if a row or
	// column is entered that is greater than the actual number of
	// respective rows or columns currently available under *grid.
	if((sRowNumber >= 0) && (sColNumber >= 0) &&
		(sRowNumber <= sNumRows) && (sColNumber <= sNumCols))
	{
		grid->SetRow(sRowNumber);
		grid->SetCol(sColNumber);
		grid->SetText(szData);
		return(true);
	}
	else
	{
		return(false);
	}
}

//-----------------------------------------------------------------
// bSetGridValueInteger
//
// This method is a wrapper to write to an ActiveX Grid Control.
// The calling method needs to have access to a CGridCtrl object
// (through ClassWizard->Member Variables or other means) and must
// pass a handle to that object to this method.  The calling
// method must pass the row and column location where the data
// will be written as well as the data itself (in integer format).
// The bool parameter bHexMode will allow the data to be displayed
// in plain integer format (i.e., the way it looks in the string)
// as well as in hexadecimal format (i.e., with a "0x" appended to
// the front of the data).
//-----------------------------------------------------------------
bool CGridMethods::bSetGridValueInteger(CGridCtrl *grid, const short sRowNumber, 
										const short sColNumber, const int iData, 
										const bool bHexMode)
{
	char szConvertedData[255];

	if(bHexMode)
	{
		// Hexadecimal mode
		itoa(iData, szConvertedData, 16);
	}
	else
	{
		// Integer mode
		itoa(iData, szConvertedData, 10);
	}

	return(bSetGridValueString(grid, sRowNumber, sColNumber, szConvertedData));
}	

//-----------------------------------------------------------------
// bSetColumnHeadingString
//
// This method is a wrapper for the bSetGridValueString method.
// This method will assume the row number is 0 as that is the
// row number where a column heading will normally be located.
//-----------------------------------------------------------------	
bool CGridMethods::bSetColumnHeadingString(CGridCtrl *grid, const short sColNumber, 
										   CString szHeading)
{
	return(bSetGridValueString(grid, 0, sColNumber, szHeading));
}

//-----------------------------------------------------------------
// bSetRowHeadingString
//
// This method is a wrapper for the bSetGridValueString method.
// This method will assume the column number is 0 as that is the
// column number where a row heading will normally be located.
//-----------------------------------------------------------------	
bool CGridMethods::bSetRowHeadingString(CGridCtrl *grid, const short sRowNumber, 
										CString szHeading)
{
	return(bSetGridValueString(grid, sRowNumber, 0, szHeading));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -