📄 dlgsamp2.cpp
字号:
// dlgsamp2.cpp : implementation file
//
// This is a part of the Objective Grid C++ Library.
// Copyright (C) 1995 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 "dlgsamp2.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
/////////////////////////////////////////////////////////////////////////////
// CSample2Dialog
//
// CSample1Dialog is based on the IDD_DLGSAMP2 dialog template.
// I have dragged an user control into the dialog template and
// set the control class to "CGXTabWnd".
//
// CGXTabWnd is a registered window class. Registration is
// automatically done in CGridSampleApp::InitInstance which
// calls the method GXRegisterClass().
//
// The macro GetTabWnd() returns a pointer to the tab window.
// OnInitDialog creates several grid windows and attaches these
// windows to the tabwindow.
//
// CSample2GridWnd is a derived grid control. It shows you
// how to do custom cell validation.
//
// In DoDataExchange, I have added the line
// DDV_GXTabWnd(pDX, GetTabWnd());
// which enables control validation in the dialog.
#define GetTabWnd() ((CGXTabWnd*) GetDlgItem(IDC_TABWND2))
/////////////////////////////////////////////////////////////////////////////
// CSample2GridWnd grid control
// validation routine
BOOL CSample2GridWnd::OnValidateCell(ROWCOL nRow, ROWCOL nCol)
{
CString s;
// retrieve text from current cell
CGXControl* pControl = GetControl(nRow, nCol);
pControl->GetCurrentText(s);
if (atol(s) < 0 || atol(s) > 100)
{
char sz[255];
sprintf(sz, "Please enter a value between 0 and 100!");
SetWarningText(sz);
return FALSE;
}
return TRUE;
}
BEGIN_MESSAGE_MAP(CSample2GridWnd, CGXGridWnd)
//{{AFX_MSG_MAP(CSample2GridWnd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSample2Dialog dialog
CSample2Dialog::CSample2Dialog(CWnd* pParent /*=NULL*/)
: CDialog(CSample2Dialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CSample2Dialog)
m_nEdit = 0;
m_nVal2 = 0;
//}}AFX_DATA_INIT
}
void CSample2Dialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSample2Dialog)
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 CGXTabWnd controls
DDV_GXTabWnd(pDX, GetTabWnd());
}
BEGIN_MESSAGE_MAP(CSample2Dialog, CDialog)
//{{AFX_MSG_MAP(CSample2Dialog)
ON_WM_NCACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSample2Dialog message handlers
BOOL CSample2Dialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_grid1.Create(0, CRect(0,0,1,1), GetTabWnd(), GetTabWnd()->GetNextID());
m_grid2.Create(0, CRect(0,0,1,1), GetTabWnd(), GetTabWnd()->GetNextID());
m_grid3.Create(0, CRect(0,0,1,1), GetTabWnd(), GetTabWnd()->GetNextID());
GetTabWnd()->AttachWnd(&m_grid1, "Grid 1");
GetTabWnd()->AttachWnd(&m_grid2, "Grid 2");
GetTabWnd()->AttachWnd(&m_grid3, "Grid 3");
m_grid1.Initialize();
m_grid2.Initialize();
m_grid3.Initialize();
m_grid1.SetRowCount(256);
m_grid2.SetRowCount(256);
m_grid3.SetRowCount(256);
m_grid1.SetColCount(52);
m_grid2.SetColCount(52);
m_grid3.SetColCount(52);
GetTabWnd()->SetFocus();
return FALSE; // return TRUE unless you set the focus to a control
}
BOOL CSample2Dialog::OnNcActivate(BOOL bActive)
{
if (CGXGridCombo::GetComboBoxDropDown())
return TRUE;
return CDialog::OnNcActivate(bActive);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -