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

📄 exampledialog.cpp

📁 创建可改变大小的对话框或框架的程序
💻 CPP
字号:
// ExampleDialog.cpp : implementation file
//

#include "stdafx.h"
#include "Sample.h"
#include "ExampleDialog.h"
#include "GeometryManager.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CExampleDialog dialog


CExampleDialog::CExampleDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CExampleDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CExampleDialog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CExampleDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CExampleDialog)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CExampleDialog, CDialog)
	//{{AFX_MSG_MAP(CExampleDialog)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CExampleDialog message handlers

BOOL CExampleDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// initialize the geometry manager
	//
	// the default behavior is fine
	//
	HGEOM hGeom = GmStartDefinition(0);
	ASSERT(hGeom);
	if (hGeom)
	{
		// add the top-level dialog group
		//
		// arrange its direct children vertically
		//
		HGMGROUP hTopDialog = GmAddTopDialog(hGeom, m_hWnd, GM_VERTICAL);
		if (hTopDialog)
		{
			// add the generic group for the static text and edit field
			//
			// arrange its direct children vertically
			// give it a weight of 1
			//
			HGMGROUP hGroup1 = GmAddGroup(hGeom, hTopDialog, GM_VERTICAL, 1);
			if (hGroup1)
			{
				// add the static text group
				//
				// left-align and vertically center it
				// give it a weight of 0
				//
				GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDC_SI_LABEL), GM_LEFT | GM_VCENTER, 0);
				
				// add the multiline edit field group
				//
				// allow it to grow (in both directions)
				// give it a weight of 1
				//
				GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDC_SI), GM_GROW, 1);
			}
			
			// add the generic group for the buttons
			//
			// right-align it
			// arrange its direct children horizontally
			// give it a weight of 0
			//
			hGroup1 = GmAddGroup(hGeom, hTopDialog, GM_RIGHT | GM_HORIZONTAL, 0);
			if (hGroup1)
			{
				// add the two buttons
				//
				// don't allow any growth
				// give them a weight of 0
				//
				GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDOK), 0, 0);
				GmAddWnd(hGeom, hGroup1, ::GetDlgItem(m_hWnd, IDCANCEL), 0, 0);
			}
		}
		
		// end the definition and start the manager
		//
		GmEndDefinition(hGeom);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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