YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

Get Ready to Unleash the Power of UCanCode .NET

 


UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"


Free VC++ MFC Grid Control with VC++ Source Code

 
 
The ALX Grid Control is intended for display and change of the data which may be submitted as the table. It is realized as library on basis of MFC classes which are statically connected to the application. The library includes classes: CALXGridView for support of technology document - view, and CALXGridCtrl for use in dialogue windows. And also classes - Grid control of cells. Since version 1.1 the library includes class CALXSplitterWnd for support of dynamic splitters.

The sample shows an opportunity of use of grid controls of cells, and also changes of the data in cells. Class CGridView is determined from parent class CALXGridView <gridview.htm>. In his constructor are added column (function AddCo ()) and define type grid control (function DefineColCtrl ()). Cells of one of column are defined as a cell containing the image (function DefineImage()).

CGridCtrl::CGridCtrl()
{
 CString strTmp;

 strTmp.LoadString(ID_COL_DEBIT);
 DefineColCtrl(AddCol(115, strTmp,
                      ACFF_RIGHT, AHFF_CENTER,
                      0, 0, ID_COL_DEBIT),
               GA_EDITCTRL, WS_CHILD | ES_RIGHT);

 strTmp.LoadString(ID_COL_CREDIT);
 DefineColCtrl(AddCol(115, strTmp,
                      ACFF_RIGHT, AHFF_CENTER,
                      0, 0, ID_COL_CREDIT),
               GA_EDITCTRL, WS_CHILD | ES_RIGHT);

 strTmp.LoadString(ID_COL_SALDO);
 DefineColCtrl(AddCol(120, strTmp,
                      ACFF_RIGHT, AHFF_CENTER,
                      0, 0, ID_COL_SALDO),
               GA_CELLCTRL);

 //...

 SetGridRowCount(m_RowInfo.GetSize()+1);
}

Also virtual function GetCellData() which returns the data of cells necessary for display is redefined.

CELL_DATA CGridCtrl::GetCellData(int nCol, int nRow)
{
 CELL_DATA CellData = CALXGrid::GetCellData(nCol,nRow);

 if(nRow == GetGridRowCount()-1)
 {
  switch(GetCellCtrlID(nCol,nRow))
  {
   case ID_COL_DEBIT:
   {
    COleCurrency SumDeb(0,0);
    for(int i = 0; m_RowInfo.GetSize() > i; i++)
    SumDeb += m_RowInfo[i].m_Dedet;
    CellData.m_strText = SumDeb.Format();
    break;
   }
   case ID_COL_CREDIT:
   {
    COleCurrency SumCrd(0,0);
    for(int i = 0; m_RowInfo.GetSize() > i; i++)
     SumCrd += m_RowInfo[i].m_Credit;
    CellData.m_strText = SumCrd.Format();
    break;
   }
   case ID_COL_SALDO:
   {
    COleCurrency SumSld(0,0);
    for(int i = 0; m_RowInfo.GetSize() > i; i++)
    SumSld += m_RowInfo[i].m_Dedet - m_RowInfo[i].m_Credit;
    CellData.m_strText = SumSld.Format();
    break;
   }
  }
  return CellData;
 }

 switch(GetCellCtrlID(nCol,nRow))
 {
  case ID_COL_DEBIT:
   CellData.m_strText = m_RowInfo[nRow].m_Dedet.Format();
  break;

  case ID_COL_CREDIT:
   CellData.m_strText = m_RowInfo[nRow].m_Credit.Format();
  break;

  case ID_COL_SALDO:
   CellData.m_strText = (m_RowInfo[nRow].m_Dedet
                      - m_RowInfo[nRow].m_Credit).Format();
  break;
 }

 return CellData;
}

The virtual function OnSaveCellData() - seved data.

BOOL CGridCtrl::OnSaveCellData(int nCol, int nRow)
{
 CALXCellCtrl* pCellCtrl = GetCellCtrl(nCol,nRow);
 if(pCellCtrl != NULL)
 {
  CELL_DATA Data = pCellCtrl->GetCellData();
  switch(GetCellCtrlID(nCol,nRow))
  {
   case ID_COL_DEBIT:
    m_RowInfo[nRow].m_Dedet.ParseCurrency(Data.m_strText);
    break;
   case ID_COL_CREDIT:
    m_RowInfo[nRow].m_Credit.ParseCurrency(Data.m_strText);
    break;
   }
   InvalidateCell(2,nRow);
   InvalidateRow(m_RowInfo.GetSize());
  }
 return TRUE;
}

Downloads

Download demo project (includes release build) - 104 Kb

 

 

Copyright ?1998-2024 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.net