home *** CD-ROM | disk | FTP | other *** search
- // dlgsamp1.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 "dlgsamp1.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
-
- /////////////////////////////////////////////////////////////////////////////
- // CSample1Dialog
- //
- // As described in the overview of the programmers guide,
- // you can use a grid as dialog control in a dialog template.
- //
- // CSample1Dialog is based on the IDD_DLGSAMP1 dialog template.
- // I have dragged an user control into the dialog template and
- // set the control class to "CGXGridWnd".
- //
- // CGXGridWnd is a registered window class. Registration is
- // automatically done in CGridSampleApp::InitInstance which
- // calls the method GXRegisterClass().
- //
- // The macro GetGridWnd() returns a pointer to the grid window.
- // OnInitDialog calls the Initialize method of the grid.
- //
- // OnInitDialog also shows you how to apply styles for the whole
- // table and some simple cell validation.
- //
- // In DoDataExchange, I have added the line
- // DDV_GXGridWnd(pDX, GetGridWnd());
- // which enables control validation in the dialog.
-
- #define GetGridWnd() ((CGXGridWnd*) GetDlgItem(IDC_GRID1))
-
- /////////////////////////////////////////////////////////////////////////////
- // CSample1Dialog dialog
-
- CSample1Dialog::CSample1Dialog(CWnd* pParent /*=NULL*/)
- : CDialog(CSample1Dialog::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSample1Dialog)
- m_nEdit = 0;
- m_nVal2 = 0;
- //}}AFX_DATA_INIT
- }
-
- void CSample1Dialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSample1Dialog)
- 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, GetGridWnd());
- }
-
- BEGIN_MESSAGE_MAP(CSample1Dialog, CDialog)
- //{{AFX_MSG_MAP(CSample1Dialog)
- ON_WM_NCACTIVATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CSample1Dialog message handlers
-
- BOOL CSample1Dialog::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- GetGridWnd()->Initialize();
-
- GetGridWnd()->SetScrollBarMode(SB_BOTH, gxnAutomatic | gxnEnhanced);
-
- GetGridWnd()->SetRowCount(256);
- GetGridWnd()->SetColCount(52);
-
- // minimumn, maximum value
- GetGridWnd()->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!"))
- );
-
- GetGridWnd()->SetStyleRange(CGXRange().SetCols(1), CGXStyle()
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Column 1")));
-
- GetGridWnd()->SetStyleRange(CGXRange().SetCols(2), CGXStyle()
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Column 2")));
-
- GetGridWnd()->SetStyleRange(CGXRange().SetCols(3), CGXStyle()
- .SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, _T("Column 3")));
-
- #if _MFC_VER >= 0x0400 && !defined(_AFX_NO_OLE_SUPPORT)
- // Enable grid to be used as data source
- GetGridWnd()->EnableOleDataSource();
-
- // Register the grid as drop target
- VERIFY(m_objDndDropTarget.Register(GetGridWnd()));
-
- #endif
-
- #if _MFC_VER >= 0x0400
- GetGridWnd()->EnableGridToolTips();
-
- CGXStylesMap* stylesmap = GetGridWnd()->GetParam()->GetStylesMap();
- stylesmap->AddUserAttribute(GX_IDS_UA_TOOLTIPTEXT,
- CGXStyle().SetWrapText(TRUE).SetAutoSize(TRUE));
- #endif
-
- GetGridWnd()->SetCurrentCell(1,1);
-
- GetGridWnd()->SetFocus();
-
- return FALSE; // return TRUE unless you set the focus to a control
- }
-
- BOOL CSample1Dialog::OnNcActivate(BOOL bActive)
- {
- if (CGXGridCombo::GetComboBoxDropDown())
- return TRUE;
-
- return CDialog::OnNcActivate(bActive);
- }
-