home *** CD-ROM | disk | FTP | other *** search
- // dlgsamp3.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 "dlgsamp3.h"
-
- #ifndef _GXALL_H_
- #include "gxwnd.h"
- #include "gxctrl.h"
- #endif
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- #define new DEBUG_NEW
-
- /////////////////////////////////////////////////////////////////////////////
- // CSample3Dialog
- //
- // CSample3Dialog is based on the IDD_DLGSAMP3 dialog template.
- // The grid window is created though a call to the Create() member function.
- //
- // In DoDataExchange, I have added the line
- // DDV_GXGridWnd(pDX, &m_wndGrid);
- // which enables control validation in the dialog.
-
- /////////////////////////////////////////////////////////////////////////////
- // CSample3Dialog dialog
-
- CSample3Dialog::CSample3Dialog(CWnd* pParent /*=NULL*/)
- : CDialog(CSample3Dialog::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSample3Dialog)
- m_nEdit = 0;
- m_nVal2 = 0;
- //}}AFX_DATA_INIT
- }
-
- void CSample3Dialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSample3Dialog)
- 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(CSample3Dialog, CDialog)
- //{{AFX_MSG_MAP(CSample3Dialog)
- ON_WM_NCACTIVATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSample3Dialog message handlers
-
- BOOL CSample3Dialog::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- CWnd* pGridFrame = GetDlgItem(IDC_GRIDWND3);
-
- if (pGridFrame)
- {
- // Retrive the size of the frame and convert the co-ordinated to
- // use the Dialog co-ordinates (from screen co-ordinates).
- CRect rect;
- pGridFrame->GetWindowRect( &rect );
- ScreenToClient(&rect);
-
- DWORD dwFlags =
- WS_TABSTOP | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE;
-
- #if _MFC_VER >= 0x0400
- // draw grid with sunken borders
- dwFlags |= WS_EX_CLIENTEDGE;
- #endif
-
- m_wndGrid.Create(
- dwFlags,
- rect,
- this,
- 21000);
-
- m_wndGrid.Initialize();
-
- m_wndGrid.SetRowCount(256);
- m_wndGrid.SetColCount(52);
-
- // minimumn, maximum value
- m_wndGrid.SetStyleRange(CGXRange().SetTable(), CGXStyle()
- .SetUserAttribute(GX_IDS_UA_VALID_MIN, _T("0"))
- .SetUserAttribute(GX_IDS_UA_VALID_MAX, _T("100"))
- .SetUserAttribute(GX_IDS_UA_VALID_MSG, _T("Please enter a value between 0 and 100!"))
- );
-
- m_wndGrid.SetCurrentCell(1,1);
-
- m_wndGrid.SetFocus();
-
- return FALSE;
- }
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
-
- BOOL CSample3Dialog::OnNcActivate(BOOL bActive)
- {
- if (CGXGridCombo::GetComboBoxDropDown())
- return TRUE;
-
- return CDialog::OnNcActivate(bActive);
- }
-