⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlgsamp4.cpp

📁 mfc internals 源码 mfc internals 源码
💻 CPP
字号:
// dlgsamp4.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 "dlgsamp4.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

/////////////////////////////////////////////////////////////////////////////
// CSample4Dialog
//
// As described in the overview of the programmers guide,
// you can use a grid as dialog control in a dialog template.
//
// CSample4Dialog is based on the IDD_DLGSAMP4 dialog template.
// I have dragged an user control into the dialog template and
// set the control class to "CSample4GridWnd".
//
// CSample4GridWnd is registered in CGridSampleApp::InitInstance
// which calls the method CSample4GridWnd::RegisterClass().
//
// The macro GetGridWnd() returns a pointer to the grid window.
// OnInitDialog calls the Initialize method of the grid.
//
// In DoDataExchange, I have added the line
// DDV_GXGridWnd(pDX, GetGridWnd());
// which enables control validation in the dialog.

/////////////////////////////////////////////////////////////////////////////
// CSample4GridWnd grid control

IMPLEMENT_REGISTER(CSample4GridWnd, CS_DBLCLKS, 0, 0, 0);

// validation routine

BOOL CSample4GridWnd::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(CSample4GridWnd, CGXGridWnd)
	//{{AFX_MSG_MAP(CSample4GridWnd)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSample4Dialog dialog

#define GetGridWnd() ((CSample4GridWnd*) GetDlgItem(IDC_GRIDWND4))

CSample4Dialog::CSample4Dialog(CWnd* pParent /*=NULL*/)
	: CDialog(CSample4Dialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSample4Dialog)
	m_nEdit = 0;
	m_nVal2 = 0;
	//}}AFX_DATA_INIT
}

void CSample4Dialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSample4Dialog)
	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(CSample4Dialog, CDialog)
	//{{AFX_MSG_MAP(CSample4Dialog)
	ON_WM_NCACTIVATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CSample4Dialog message handlers

BOOL CSample4Dialog::OnInitDialog()
{
	CDialog::OnInitDialog();

	GetGridWnd()->Initialize();

	GetGridWnd()->SetRowCount(256);
	GetGridWnd()->SetColCount(52);

	GetGridWnd()->SetFocus();

	return FALSE;  // return TRUE  unless you set the focus to a control
}

BOOL CSample4Dialog::OnNcActivate(BOOL bActive)
{
	if (CGXGridCombo::GetComboBoxDropDown())
		return TRUE;

	return CDialog::OnNcActivate(bActive);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -