Below I put the contents of the CGRID and reposted the use of CGRID, the original file of this article comes from the flex_grid_src.zip file on www.vchelp.net. For the use of CGRID, it has been modified, because you don't know the original author, look at the amount.
Where cgrid.h and cgrid.cpp are encapsulation of cflexgrid, CDLGUSERMANGER is using CGRID
/****************************
// Grid.h: interface for the cgrid class.////
#if! defined (AFX_GRID_H__91679B43_6C53_11D3_BEF7_00C04F755C52__included _) # define afX_GRID_H__91679B43_6C53_11D3_BEF7_00C04F755C52__included_
#if _MSC_VER> 1000 # prgma overce # endif //_MSC_VER> 1000
#include "msflexgrid.h"
class CGrid: public CMSFlexGrid {public: CGrid (); virtual ~ CGrid (); public: BOOL GoRight (); BOOL GoLeft (); BOOL GoDown (); BOOL GoUp (); OnKeyPressGrid (short FAR * KeyAscii); OnClickGrid ( ); Void oneNtercell (); private: cstring m_griddata; bool beditmode; bool togrid;};
#ENDIF /! Defined (AFX_GRID_H__91679B43_6C53_11D3_Bef7_00c04f755c52__included_)
/ ***************CGRID.cpp*********************/Include "stdafx.h" #include "grid.h"
#ifdef _debug # undef this_filestatic char this_file [] = __ file __; # Define new debug_new # Endif
//// construction / destruction //
CGRID :: CGRID () {}
CGRID :: ~ cgrid () {
}
Bool cgrid :: Goup () {Transfervalue (TRUE); IF (GetRow ()> 1) {int currentrow = getrow (); currentrow -; transferse (false); if (! GetrowiSvisible); if (! Getrowisvisible ) Settoprow;
} Return True;
}
Bool cgrid :: godown () (); if (GetRow () Return True; } Bool CGRID :: Goleft () {TransferValue (TRUE); IF (getcol ()> 1) {int currentcol = getcol (); currentcol -; setcol (currentcol); if (! Getcolisible); if (! GetColisible (Currentcol) ) Setleftcol;} return true; Bool cgrid :: Goright () {Transfervalue (TRUE); IF (getcol () Bool CGRID :: TransferValue (Bool Togrid) {CString Stext; IF (TOGRID) {file: // Transfer value to grid from edit box setxt (m_griddata);} else {m_griddata = getText (); setbackcolorsel (RGB (0,255,255));} return true;} Bool CGRID :: onkeypressgrid (short far * keyascii) { Switch ((int) * keyascii) { case VK_BACK: file: // Backspace - delete the last character m_GridData.Delete (m_GridData.GetLength () -1,1); break; default: m_GridData = m_GridData (TCHAR *) KeyAscii; break;} TransferValue (TRUE); } CGRID :: OnClickGrid () { TransferValue (false); Void CGRID :: Onetercell () {TransferValue (false); / ********************************************************************************************************************************** ************** CDLGUSERMANAGER.CPP ******************** / // DLGUSERMANAGER.CPP: IMPLEMENTATION FILE #include "stdafx.h" #include "dlgusermanager.h" #ifdef _debug # define new debug_new # undef this_filestatic char this_file [] = __file __; # ENDIF /// CDLGUSERMANAGER DIALOG CDLGUSERMANAGER :: CDLGUSERMANAGER (CDLGUSERMANAGER (CWND * PParent / * = null * /): cdialog (cdlguserManager :: IDd, pparent) {file: // {{AFX_DATA_INIT (CDLGUSERMANAGER) FILE: //}} AFX_DATA_INIT } void CDlgUserManager :: DoDataExchange (CDataExchange * pDX) {CDialog :: DoDataExchange (pDX); file: // {{AFX_DATA_MAP (CDlgUserManager) DDX_Control (pDX, IDC_USER_MANAGER_GRID, m_grid); file: //}} AFX_DATA_MAP} BEGIN_MESSAGE_MAP (CDlgUserManager, CDIALOG) File: // {{AFX_MSG_MAP (CDLGUSERMANAGER) ON_WM_DESTROY () ON_WM_CREATE () File: //}} AFX_MSG_MAPEND_MESSAGE_MAP () /// CDLGUSERMANAGER MESSAGE HANDLERS Bool CDLGUSERMANAGER :: OnNitdialog () {cdialog :: oninitdialog (); CWND * hWnd = getdlgitem (idc_user_manager_grid); hgrid = hwnd-> getsafehwnd (); Return True; // Return True UnsS you set the focus to a control // Exception: OCX Property Pages SHOULD RETURN FALSE} BEGIN_EVENTSINK_MAP (CDlgUserManager, CDialog) file: // {{AFX_EVENTSINK_MAP (CDlgUserManager) ON_EVENT (CDlgUserManager, IDC_USER_MANAGER_GRID, -600 / * Click * /, OnClickUserManagerGrid, VTS_NONE) ON_EVENT (CDlgUserManager, IDC_USER_MANAGER_GRID, -601 / * DblClick * /, OnDblClickUserManagerGrid, VTS_NONE) ON_EVENT (CDlgUserManager, IDC_USER_MANAGER_GRID, -602 / * KeyDown * /, OnKeyDownUserManagerGrid, VTS_PI2 VTS_I2) ON_EVENT (CDlgUserManager, IDC_USER_MANAGER_GRID, 74 / * Compare * /, OnCompareUserManagerGrid, VTS_I4 VTS_I4 VTS_PI2) ON_EVENT (CDlgUserManager, IDC_USER_MANAGER_GRID, -603 / * KeyPress * /, OnKeyPressUserManagerGrid, VTS_PI2) ON_EVENT (CDlgUserManager, IDC_USER_MANAGER_GRID, -605 / * MouseDown * /, OnMouseDownUserManagerGrid, VTS_I2 VTS_I2 VTS_I4 VTS_I4) file: //}} AFX_EVENTSINK_MAPEND_EVENTSINK_MAP () Void CDLGUSERMANAGER :: OnClickUserManagerGrid () {// Todo: add your control notification handler code her_grid.onclickGrid ();} void CDlgUserManager :: OnDblClickUserManagerGrid () {// TODO: Add your control notification handler code here m_grid.OnClickGrid ();} void CDlgUserManager :: OnKeyPressUserManagerGrid (short FAR * KeyAscii) {// TODO: Add your control notification handler code here m_grid .Onkeypressgrid (keyascii); BOOL CDlgUserManager :: PreTranslateMessage (MSG * pMsg) {// TODO: Add your specialized code here and / or call the base class if (pMsg-> message == WM_KEYDOWN && (pMsg-> hwnd == hGrid)) {switch ( PMSG-> wparam) { Case vk_up: m_grid.goup (); return true; case vk_down: m_grid.godown (); return true; case vk_left: m_grid.goleft (); return true; case vk_right: m_grid.goright (); return true;}} Return CDIALOG :: PretranslateMessage (PMSG); Void CDLGUSERMANAGER :: Onok () {Try {file: // delete all records of users _variant_t vrecsaffected (0L); _BSTR_T BSTRDELETE ("Delete from 3PW"); ((CSLTG2001App *) AFXGetApp ()) -> m_sltgdbconn -> Execute (BSTRDELETE, & VRECSAFFECTED, AdoptionunSpecified); _BSTR_T BSTRINSERT; CSTRING STRUSER, STRPASSWD; for (int i = 1; I