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

📄 ngdialog.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// Override to let the parent know when a page becomes active
BOOL CNGPropertyPage::OnSetActive(void)
{
	CNGPropertySheet* pParent = DYNAMIC_DOWNCAST(CNGPropertySheet, GetParent());
	if (pParent != NULL)
	{
		pParent->OnSetActive(this);
	}
	return CNGPropertyPage_BASE::OnSetActive();
}


// Override to:
//	1.	Let the parent know when a page becomes inactive
//	2.	Prevent reentrant calls to UpdateData() via OnCommand()
BOOL CNGPropertyPage::OnKillActive(void)
{
	ASSERT_VALID(this);

	m_bLockCtrlUpdates = true;

	CNGPropertySheet* pParent = DYNAMIC_DOWNCAST(CNGPropertySheet, GetParent());
	if (pParent != NULL)
	{
		pParent->OnKillActive(this);
	}
	BOOL bResult = CNGPropertyPage_BASE::OnKillActive();
	m_bLockCtrlUpdates = false;

	return bResult;
}


/////////////////////////////////////////////////////////////////////////////
// CNGPropertyPage operations

BOOL CNGPropertyPage::SetServer(CObject* pServer)
{
	m_pServer = pServer;
	ASSERT_VALID(m_pServer);

	return (m_pServer != NULL);
}


BOOL CNGPropertyPage::SetDocument(CDocument* pDocument)
{
	m_pDoc = pDocument;
	ASSERT_VALID(m_pDoc);

	return (m_pDoc != NULL);
}


void CNGPropertyPage::SetModified(BOOL bChanged /*= TRUE*/)
{
	m_bModified = bChanged;
	CNGPropertyPage_BASE::SetModified(bChanged);
}


BOOL CNGPropertyPage::EnableDlgControl(UINT uID, BOOL bEnable)
{
	CWnd* pWnd = GetDlgItem(uID);
    if (NULL != pWnd)
	{
		pWnd->EnableWindow(bEnable);

		return TRUE;
	}
	ASSERT(FALSE);
	return FALSE;
}


BOOL CNGPropertyPage::ShowDlgControl(UINT uID, BOOL bShow)
{
	CWnd* pWnd = GetDlgItem(uID);
    if (NULL != pWnd)
	{
		pWnd->ShowWindow(bShow);
		return TRUE;
	}
	ASSERT(FALSE);
	return FALSE;
}
	

BOOL CNGPropertyPage::SetReadOnly(UINT uID, BOOL bReadOnly /*= TRUE*/)
{
	CEdit* pCtrl = static_cast<CEdit*>( GetDlgItem(uID) );
    if (NULL != pCtrl)
	{
		pCtrl->SetReadOnly(bReadOnly);
		return TRUE;
	}
	ASSERT(FALSE);
	return FALSE;
}


BOOL CNGPropertyPage::UpdateData(BOOL bSaveAndValidate /*= TRUE*/)
{
	if (IsWindow(m_hWnd))
	{
		return CNGPropertyPage_BASE::UpdateData(bSaveAndValidate);
	}
	return FALSE;
}



/////////////////////////////////////////////////////////////////////////////
// CNGPropertyPage message handlers




/////////////////////////////////////////////////////////////////////////////
// CNGPropertySheet

IMPLEMENT_DYNAMIC(CNGPropertySheet, CNGPropertySheet_BASE)

CNGPropertySheet::CNGPropertySheet(UINT uIDCaption, CWnd* pParentWnd, UINT iSelectPage)
	:CNGPropertySheet_BASE(uIDCaption, pParentWnd, iSelectPage)
{
	m_rectInitialPosition.SetRectEmpty();
	m_rectPosition.SetRectEmpty();

	EnableStackedTabs(FALSE);
}


CNGPropertySheet::CNGPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
	:CNGPropertySheet_BASE(pszCaption, pParentWnd, iSelectPage)
{
	m_rectInitialPosition.SetRectEmpty();
	m_rectPosition.SetRectEmpty();

	EnableStackedTabs(FALSE);
}


CNGPropertySheet::~CNGPropertySheet(void)
{
}


BEGIN_MESSAGE_MAP(CNGPropertySheet, CNGPropertySheet_BASE)
	//{{AFX_MSG_MAP(CNGPropertySheet)
	ON_WM_MOVE()
	ON_WM_HELPINFO()
	ON_WM_CONTEXTMENU()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CNGPropertySheet overrides

BOOL CNGPropertySheet::OnInitDialog(void)
{
	// Add a'?' button to the title bar for context help support
	ModifyStyleEx(0, WS_EX_CONTEXTHELP);

	BOOL bResult = CNGPropertySheet_BASE::OnInitDialog();
	
	SetInitialPosition();
	
	return bResult;
}


void CNGPropertySheet::OnSetActive(CPropertyPage* pPage)
{
	ASSERT_VALID(this);

	UNREFERENCED_PARAMETER(pPage);
}



void CNGPropertySheet::OnKillActive(CPropertyPage* pPage)
{
	ASSERT_VALID(this);

	UNREFERENCED_PARAMETER(pPage);
}

BOOL CNGPropertySheet::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	BOOL bResult = FALSE;

	// Crack message parameters
	// This bit was nicked from CPropertySheet::OnCommand()
	UINT uID		= LOWORD(wParam);
	HWND hWnd		= (HWND)lParam;
	//int nCode		= HIWORD(wParam);

	//UINT uCtrlID	= uID;						// We'll need this later

	// If the command notification was a control value change
	// which could be linked up via DDX update the DDX member
	// vars and send a WM_COMMAND notification on the affected
	// control (this allows a generic ON_COMMAND handler to be
	// used, irrespective of the type of the control)

	if (hWnd != NULL)
	{
		// Catch ENTER keypresses on a control
		// and convert to a CN_COMMAND call for that control
		// This allows the control focused when ENTER was pressed to receive
		// the change notification...
		if (uID == IDOK)
		{
			// Walk up from the focused window until we find a valid control
			HWND hWndFocusCtrl = ::GetFocus();
			while ( (hWndFocusCtrl != NULL) && (::GetParent(hWndFocusCtrl) != m_hWnd) )
			{
				hWndFocusCtrl =::GetParent(hWndFocusCtrl);
			}
			
			// If the focused control is the one we orignially received the 
			// notification from it must be the OK button itself, so
			// let it through unchanged
			if ( (hWndFocusCtrl == NULL) || (hWndFocusCtrl == hWnd) )
			{
				return CNGPropertySheet_BASE::OnCommand(wParam, lParam);
			}

			// Fire a CN_COMMAND notification on the focused control
			hWnd = hWndFocusCtrl;

			wParam = MAKEWPARAM(uID, CN_COMMAND);
			lParam = (LPARAM)hWnd;
			::SendMessage(hWnd, WM_COMMAND, wParam, lParam);

			// Move the focus to the next control
			::PostMessage(m_hWnd, WM_NEXTDLGCTL, 0, 0L);

			bResult = TRUE;			// Prevent sheet from closing
		}
		else
		{
			bResult = CNGPropertySheet_BASE::OnCommand(wParam, lParam);
		}
	}
	return bResult;
}




/////////////////////////////////////////////////////////////////////////////
// CNGPropertySheet operations

BOOL CNGPropertySheet::EnableDlgControl(UINT uID, BOOL bEnable)
{
	CWnd* pWnd = GetDlgItem(uID);
    if (NULL != pWnd)
	{
		pWnd->EnableWindow(bEnable);

		return TRUE;
	}
	ASSERT(FALSE);
	return FALSE;
}


BOOL CNGPropertySheet::ShowDlgControl(UINT uID, BOOL bShow)
{
	CWnd* pWnd = GetDlgItem(uID);
    if (NULL != pWnd)
	{
		pWnd->ShowWindow(bShow);
		return TRUE;
	}
	ASSERT(FALSE);
	return FALSE;
}
	

BOOL CNGPropertySheet::UpdateData(BOOL bSaveAndValidate /*= TRUE*/)
{
	if (IsWindow(m_hWnd))
	{
		return CNGPropertySheet_BASE::UpdateData(bSaveAndValidate);
	}
	return FALSE;
}


/////////////////////////////////////////////////////////////////////////////
// CNGPropertySheet message handlers

void CNGPropertySheet::OnMove(int x, int y) 
{
	CNGPropertySheet_BASE::OnMove(x, y);
	
	GetWindowRect(&m_rectPosition);
}


/////////////////////////////////////////////////////////////////////////////
// CNGPropertySheet Help Support

// Context help generated by pressing F1 or using the "?" button on the title
// bar of the property sheet.
BOOL CNGPropertySheet::OnHelpInfo(HELPINFO* pHelpInfo) 
{
	if (pHelpInfo->iContextType == HELPINFO_WINDOW)
	{
		// Launch WinHelp or HtmlHelp
		// The HELP_WM_HELP flag brings up pop-up help and expects an array 
		// of DWORD pairs of the control ID and the context help ID
		UINT uCtrlID = pHelpInfo->iCtrlId;
		if ( (uCtrlID != 0) && (uCtrlID != IDC_STATIC) )
		{
			CTRLID_HELPID_PAIR dwHelpIds(	uCtrlID,
											uCtrlID + HID_BASE_CONTROL);

			::WinHelp(	(HWND)pHelpInfo->hItemHandle,
						AfxGetApp()->m_pszHelpFilePath,	
						HELP_WM_HELP,
						(DWORD)&dwHelpIds);
		}
	}
	return TRUE;
}


//	Context help generated by right clicking the control and selecting the
//	"Whats this ?" menu.
void CNGPropertySheet::OnContextMenu(CWnd* pWnd, CPoint point) 
{
 	// The title bar has a system provided context menu which is displayed for
	// a right mouse button up
	if (HTCLIENT == OnNcHitTest(point))
	{
		//TRACE("OnContextMenu - HTCIENT\n");
		CWnd* pChildWnd;
		if (pWnd == this) //if the control on the Sheet is disabled
		{
			// get the hWnd of the disabled child window
			ScreenToClient(&point);
			pChildWnd = ChildWindowFromPoint(point, CWP_ALL);
		}
		else
		{
			// for OK, Cancel and Apply (if enabled) buttons
			pChildWnd = pWnd;
		}

		// Launch WinHelp or HtmlHelp
		// The HELP_CONTEXTMENU flag brings up the "Whats this ?" menu and selecting
		// the menu in turn brings up the pop-up help. It expects an array 
		// of DWORD pairs of the control ID and the context help ID
		
		UINT uCtrlID = pChildWnd->GetDlgCtrlID();
		if ( (uCtrlID != 0) && (uCtrlID != IDC_STATIC) )
		{
			CTRLID_HELPID_PAIR dwHelpIds(	uCtrlID,
											uCtrlID + HID_BASE_CONTROL);

			::WinHelp(	(HWND)pWnd->m_hWnd,
						AfxGetApp()->m_pszHelpFilePath,
						HELP_CONTEXTMENU,
						(DWORD)&dwHelpIds);
		}
	}
}


/////////////////////////////////////////////////////////////////////////////
// Implementation

void CNGPropertySheet::SetInitialPosition(void)
{
	// If we've got a position from last time use it to position
	// our window this time
	if (!m_rectInitialPosition.IsRectEmpty())
	{
		// As the property sheet is not scaleable at the moment we need
		// to make sure we change the size of m_rectPosition to match
		// the size of the window as it is now (remember that adding or
		// deleting pages between invokations may change the size)
		m_rectInitialPosition.BottomRight() =
							CPoint(	m_rectInitialPosition.left + m_rectPosition.Width(),
									m_rectInitialPosition.top + m_rectPosition.Height() );


		MoveWindow(m_rectInitialPosition);
	}
}


⌨️ 快捷键说明

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