📄 checkfrm.cpp
字号:
#include "stdafx.h"
#include "Checkfrm.h"
// EnumChildWnds Callback
// 查找框架内控件
BOOL CALLBACK EnumChildWnds(HWND hwnd, CCheckFrame *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;
}
//设置一框架为检查框架
//pParentWnd::框架父窗口
//nFrmCtl::框架ID
void CCheckFrame::Set(CWnd *pParentWnd, UINT nFrmCtl)
{
m_pDialog = pParentWnd;
// Calculate the size of the rect that should contain the controls
m_pFrame = m_pDialog->GetDlgItem(nFrmCtl);
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();
// The (control) windows contained within the boundaries of the frame control
// are enumerated and their associated window-handles collected in an array.
EnumChildWindows(m_pDialog->m_hWnd, (WNDENUMPROC)EnumChildWnds, (LONG)(CCheckFrame *)this);
}
//允许或禁止框架中所有控件
void CCheckFrame::Enable(BOOL bEnable){ for (int i=0 ; i<m_adwWndHandles.GetSize() ; i++)
EnableWindow((HWND)m_adwWndHandles[i], bEnable);}//判断 rcChild 是否完全在 RcMother 内
BOOL 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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -