home *** CD-ROM | disk | FTP | other *** search
- // dlgsamp5.cpp : implementation file
- //
-
- // This is a part of the Objective Grid C++ Library.
- // Copyright (C) 1995,1996 ClassWorks, Stefan Hoenig.
- // All rights reserved.
- //
- // This source code is only intended as a supplement to
- // the Objective Grid Classes Reference and related
- // electronic documentation provided with the library.
- // See these sources for detailed information regarding
- // the Objective Grid product.
- //
-
- #include "stdafx.h"
- #include "gridapp.h"
- #include "dlgsamp5.h"
-
- #ifndef _GXWND_H_
- #include "gxwnd.h"
- #endif
-
- #ifndef _GXCTRL_H_
- #include "gxctrl.h"
- #endif
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- #define new DEBUG_NEW
-
- /////////////////////////////////////////////////////////////////////////////
- // CSample5Dialog
- //
- // CSample5Dialog is based on the IDD_DLGSAMP5 dialog template.
- // I have dragged an user control into the dialog template and
- // set the control class to "GXWnd".
- //
- // In OnInitDialog I call the SubclassDlgItem member funtion
- // which subclasses the CWnd control:
- // m_wndGrid.SubclassDlgItem(IDC_GRIDWND5, this);
- //
- // After calling SubclassDlgItem, the user control is attached
- // to the m_wndGrid member variable. m_wndGrid is an instance
- // of the CSample5GridWnd class. OnInitDialog calls the
- // Initialize method to initialize the grid.
- //
- // In DoDataExchange, I have added the line
- // DDV_GXGridWnd(pDX, &m_wndGrid);
- // which enables control validation in the dialog.
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSample5GridWnd grid control
-
- // validation routine
-
- BOOL CSample5GridWnd::OnValidateCell(ROWCOL nRow, ROWCOL nCol)
- {
- CString s;
-
- // retrieve text from current cell
- CGXControl* pControl = GetControl(nRow, nCol);
- pControl->GetCurrentText(s);
-
- if (_ttol(s) < 0 || _ttol(s) > 100)
- {
- SetWarningText(_T("Please enter a value between 0 and 100!"));
- return FALSE;
- }
-
- return TRUE;
- }
-
- BEGIN_MESSAGE_MAP(CSample5GridWnd, CGXGridWnd)
- //{{AFX_MSG_MAP(CSample5GridWnd)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CSample5Dialog dialog
-
- CSample5Dialog::CSample5Dialog(CWnd* pParent /*=NULL*/)
- : CDialog(CSample5Dialog::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSample5Dialog)
- m_nEdit = 0;
- m_nVal2 = 0;
- //}}AFX_DATA_INIT
-
-
- }
-
- void CSample5Dialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSample5Dialog)
- DDX_Text(pDX, IDC_EDIT1, m_nEdit);
- DDV_MinMaxInt(pDX, m_nEdit, 0, 100);
- DDX_Text(pDX, IDC_EDIT2, m_nVal2);
- DDV_MinMaxInt(pDX, m_nVal2, 0, 100);
- //}}AFX_DATA_MAP
-
- // validation routine for CGXGridWnd controls
- DDV_GXGridWnd(pDX, &m_wndGrid);
- }
-
- BEGIN_MESSAGE_MAP(CSample5Dialog, CDialog)
- //{{AFX_MSG_MAP(CSample5Dialog)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSample5Dialog message handlers
-
- BOOL CSample5Dialog::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- m_wndGrid.SubclassDlgItem(IDC_GRIDWND5, this);
-
- m_wndGrid.Initialize();
-
- m_wndGrid.SetRowCount(256);
- m_wndGrid.SetColCount(52);
-
- m_wndGrid.SetCurrentCell(1,1);
-
- m_wndGrid.SetFocus();
-
- return FALSE; // return TRUE unless you set the focus to a control
- }
-