1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGroup
CGroup::CGroup()
{
}
CGroup::~CGroup()
{
}
//----------------------------------------------------------------------
bool CGroup::ShowGroup(int nCmdShow/*=SW_SHOW */)
{
if(!GetCtrlOnGroup()) return false;
CWnd *pDialog=GetParent();
for(int i=0;i<m_arIdCtrl.GetSize();i++) pDialog->GetDlgItem(m_arIdCtrl[i])->ShowWindow(nCmdShow);
return true;
}
//----------------------------------------------------------------------
bool CGroup::EnableGroup(BOOL bEnable/*=TRUE*/)
{
if(!GetCtrlOnGroup()) return false;
CWnd *pDialog=GetParent();
for(int i=0;i<m_arIdCtrl.GetSize();i++) pDialog->GetDlgItem(m_arIdCtrl[i])->EnableWindow(bEnable);
return true;
}
//----------------------------------------------------------------------
bool CGroup::GetCtrlOnGroup()
{
ASSERT(m_hWnd);
if(m_arIdCtrl.GetSize()) return true;
CWnd *pDialog=GetParent();
CRect rectGrp;
GetWindowRect(&rectGrp);
CWnd *pCtrl=pDialog->GetNextDlgTabItem(this);
CRect rectCtrl,rectUnion;
if(!pCtrl) return false;
do
{
pCtrl->GetWindowRect(&rectCtrl);
if(rectGrp.PtInRect(CPoint(rectCtrl.left,rectCtrl.top)) &&
rectGrp.PtInRect(CPoint(rectCtrl.right,rectCtrl.top)) &&
rectGrp.PtInRect(CPoint(rectCtrl.left,rectCtrl.bottom)) &&
rectGrp.PtInRect(CPoint(rectCtrl.right,rectCtrl.bottom)))
{
m_arIdCtrl.Add(pCtrl->GetDlgCtrlID());
m_arRectCtrl.Add(rectCtrl);
}
else break;
pCtrl=pDialog->GetNextDlgTabItem(pCtrl);
}
while(pCtrl );
return (m_arIdCtrl.GetSize()>0);
}
//---------------------------
bool CGroup::IsHide()
{
//
if(!GetCtrlOnGroup()) return false;
int nct=0;
CWnd *pDialog=GetParent();
for(int i=0;i<m_arIdCtrl.GetSize();i++)
nct+=!(pDialog->GetDlgItem(m_arIdCtrl[i])->IsWindowVisible());
return(nct==m_arIdCtrl.GetSize());
}
//---------------------------
bool CGroup::IsEnable()
{
//
if(!GetCtrlOnGroup()) return false;
int nct=0;
CWnd *pDialog=GetParent();
for(int i=0;i<m_arIdCtrl.GetSize();i++)
nct+=pDialog->GetDlgItem(m_arIdCtrl[i])->IsWindowEnabled();
return(nct==m_arIdCtrl.GetSize());
}
//---------------------------
BEGIN_MESSAGE_MAP(CGroup, CButton)
//{{AFX_MSG_MAP(CGroup)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGroup message handlers |
Partager