readme.wzd

来自「MFC扩展编程实例」· WZD 代码 · 共 79 行

WZD
79
字号
/////////////////////////////////////////////////////////////////////
// Example files...
/////////////////////////////////////////////////////////////////////

WzdWnd.cpp -- a window class which destroys itself when its window is destroyed.
WzdWnd.h

/////////////////////////////////////////////////////////////////////
// Modify any class.
/////////////////////////////////////////////////////////////////////

// 1) create a child window with the "BUTTON" window class
	m_wndChildButton.CreateEx(0,	// extended window style
		_T("BUTTON"),				// window class name
		"Button",					// window caption
		WS_CHILD|WS_VISIBLE,		// window style
		10,10,100,75,					// position and dimensions
		m_hWnd,						// parent window handle
		(HMENU)IDC_WZD_BUTTON		// window id
		);

// 2) create same button using member function of CButton class
	CRect rect(200,200,300,275);
	m_wndButton.Create(
		"Button",					//window caption
		WS_CHILD|WS_VISIBLE,		//window style
		rect,						// position and dimensions
		this,						// parent window class
		IDC_WZD_BUTTON				// window id
		);


// 3) create an overlapped window with an MFC window class
	LPCTSTR lpszClass = AfxRegisterWndClass(0, ::LoadCursor(NULL, IDC_ARROW),
		(HBRUSH)(COLOR_BACKGROUND+1), NULL);

	HMENU hMenu=::LoadMenu(NULL,MAKEINTRESOURCE(IDR_WZD_MENU));

	CWzdWnd *pWnd=new CWzdWnd;
	pWnd->CreateEx(WS_EX_CLIENTEDGE,// extended window style
		lpszClass,					// window class name
		"Overlapped",				// window caption
		WS_CAPTION|WS_SYSMENU|WS_OVERLAPPED|WS_VISIBLE|WS_DLGFRAME, 
									// window style
		120,120,200,100,			// position and dimensions
		NULL,						// owner window handle--NULL is Desktop
		hMenu						// for popup and overlapped windows: window menu handle
		);


// 4) create window with Windows API, then wrap with an MFC class
	HWND hWnd=::CreateWindowEx(
		WS_EX_CLIENTEDGE,			// extended window style
		lpszClass,					// windows class name
		"Overlapped 2",				// window caption
		WS_CAPTION|WS_SYSMENU|WS_OVERLAPPED|WS_VISIBLE|WS_DLGFRAME, 
									// window style
		220,220,200,100,			// position and dimensions
		NULL,						// owner window handle--NULL is Desktop
		hMenu,						// for popup and overlapped windows: window menu handle
		AfxGetInstanceHandle(),		// handle to application instance
		NULL				        // pointer to window-creation data
		);
 
	m_wndWrapper.Attach(hWnd);

	/// access window using CWnd class member functions


// 5) detach from an existing window and destroy class
	m_wndWrapper.Detach();


/////////////////////////////////////////////////////////////////////
// From: Visual C++ MFC Programming by Example by John E. Swanke
// Copyright (C) 1999 jeswanke. All rights reserved.
/////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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