www.pudn.com > CraftFTP_gb.rar > DialogEx.cpp


// DialogEx.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "globals.h" 
#include "DialogEx.h" 
#include "CraftFTP.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CDialogEx dialog 
 
BOOL CALLBACK CGroupFrame::EnumChildWnds(HWND hWnd, CGroupFrame * pObj) 
{ 
	CRect R; 
	GetWindowRect(hWnd, &R); 
	pObj->m_pDialog->ScreenToClient(&R); 
 
	if (hWnd != pObj->m_pFrame->m_hWnd) 
	{ 
		if (IsRectContainedInRect(R, pObj->m_rFrm)) 
			pObj->m_adwWndHandles.Add((DWORD)hWnd); 
	} 
 
	return TRUE; 
} 
 
void CGroupFrame::SetFrame(CWnd * pParentWnd, UINT nFrmCtl, UINT nBtnCtrl) 
{ 
	m_pDialog = pParentWnd; 
 
	// Calculate the size of the rect that should contain the controls 
	m_pFrame  = m_pDialog->GetDlgItem(nFrmCtl); 
	m_pButton = m_pDialog->GetDlgItem(nBtnCtrl); 
	if (!m_pFrame) 
	{ 
		AfxMessageBox("Unable to find frame control"); 
		return; 
	} 
	m_pFrame->GetWindowRect(&m_rFrm); 
	m_pDialog->ScreenToClient(&m_rFrm); 
 
	// Make sure the array is empty 
	m_adwWndHandles.RemoveAll(); 
 
	EnumChildWindows(m_pDialog->m_hWnd, (WNDENUMPROC)EnumChildWnds, (LONG)(CGroupFrame *)this); 
} 
 
void CGroupFrame::Enable(BOOL bEnable) 
{ 
	for (int i=0 ; iEnableWindow(TRUE); 
		m_pButton->SetForegroundWindow(); 
	} 
} 
 
BOOL WINAPI CGroupFrame::IsRectContainedInRect(CRect &rcChild, CRect &rcMother) 
{	  
 
	if (rcMother.PtInRect(CPoint(rcChild.left,  rcChild.top)) && 
		rcMother.PtInRect(CPoint(rcChild.left,  rcChild.bottom)) && 
		rcMother.PtInRect(CPoint(rcChild.right, rcChild.top)) && 
		rcMother.PtInRect(CPoint(rcChild.right, rcChild.bottom))) 
		return TRUE; 
 
	return FALSE; 
} 
 
CDialogEx::CDialogEx(UINT nIDTemplate, CWnd* pParentWnd) 
	: CDialog(nIDTemplate, pParentWnd) 
{ 
} 
 
CDialogEx::CDialogEx(LPCTSTR lpszTemplateName, CWnd* pParentWnd) 
	: CDialog(lpszTemplateName, pParentWnd) 
{ 
} 
 
CDialogEx::CDialogEx() : CDialog() 
{ 
	//{{AFX_DATA_INIT(CDialogEx) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void CDialogEx::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CDialogEx) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CDialogEx, CDialog) 
	//{{AFX_MSG_MAP(CDialogEx) 
	ON_WM_NCRBUTTONDOWN() 
	//}}AFX_MSG_MAP 
	ON_MESSAGE(WM_HELP, OnHelp) 
	ON_MESSAGE(WM_CONTEXTMENU, OnHelpContextMenu) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CDialogEx message handlers 
 
LONG CDialogEx::OnHelp(UINT, LONG lParam) 
{ 
	CCraftFTPApp * theApp = (CCraftFTPApp*)AfxGetApp(); 
	ASSERT_VALID(theApp); 
 
	::WinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, theApp->m_szWinHelpFile, 
		HELP_WM_HELP, (DWORD)(LPVOID)GetHelpIDs()); 
 
	/* 
	::HtmlHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, AfxGetApp()->m_pszHelpFilePath, 
		HH_TP_HELP_WM_HELP, (DWORD)(LPVOID)GetHelpIDs()); 
	*/ 
	return 0; 
} 
 
LONG CDialogEx::OnHelpContextMenu(UINT wParam, LONG) 
{ 
	CCraftFTPApp * theApp = (CCraftFTPApp*)AfxGetApp(); 
	ASSERT_VALID(theApp); 
 
	::WinHelp((HWND)wParam, theApp->m_szWinHelpFile, 
		HELP_CONTEXTMENU, (DWORD)(LPVOID)GetHelpIDs()); 
 
	/* 
	::HtmlHelp((HWND)wParam, AfxGetApp()->m_pszHelpFilePath, 
		HH_TP_HELP_CONTEXTMENU, (DWORD)(LPVOID)GetHelpIDs()); 
	*/ 
	return 0; 
} 
 
BOOL CDialogEx::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	ModifyStyleEx(0, WS_EX_CONTEXTHELP); 
	 
	SetFont(&globalData.fontRegular); 
 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CDialogEx::OnNcRButtonDown(UINT nHitTest, CPoint point)  
{ 
	// TODO: Add your message handler code here and/or call default 
	if( nHitTest != HTCAPTION ) 
		CDialog::OnNcRButtonDown(nHitTest, point); 
}