SDC C-Project CF Review 프로그램
LYW
2021-07-19 2bd50ead7f0b92fb9ed5b477b63dea8fbcf8217e
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
#include "StdAfx.h"
#include "akWndArrange.h"
 
 
CakWndArrange::CakWndArrange(void)
{
    m_pWndParent = NULL;
    m_rectOriginal.SetRect(0,0,0,0);
}
 
 
CakWndArrange::~CakWndArrange(void)
{
    clear();
}
 
void CakWndArrange::clear()
{
    m_vecWndChild.clear();
}
 
void CakWndArrange::setParentWnd( CWnd* pWnd )
{
    m_pWndParent = pWnd;
    pWnd->GetClientRect(m_rectOriginal);
}
 
void CakWndArrange::addChildWnd( CWnd* pWnd, int nStyle )
{
    
    _WndData data;
    data.nStyle = nStyle;
    data.hWnd = pWnd->GetSafeHwnd();
 
    pWnd->GetWindowRect(&data.rectOrginal);
    m_pWndParent->ScreenToClient(&data.rectOrginal);
 
    m_vecWndChild.push_back(data);
}
 
void CakWndArrange::setChildStyle( CWnd* pWnd, int nStyle )
{
    HWND hWnd = pWnd->GetSafeHwnd();
    for(int i=0; i<m_vecWndChild.size(); i++)
    {
        if(m_vecWndChild[i].hWnd == hWnd)
        {
            m_vecWndChild[i].nStyle = nStyle;
        }
    }
}
 
void CakWndArrange::process( int nWidth, int nHeight )
{
    if(nWidth*nHeight <= 0) return;
    int nSize = m_vecWndChild.size();
 
    _WndData WndChild;
    CRect rectParentOrg = m_rectOriginal;
    CRect rectNew;
    for(int i=0; i<nSize; i++)
    {
        WndChild = m_vecWndChild[i];
        
        rectNew = WndChild.rectOrginal;
        if(WA_RIGHTTOP & WndChild.nStyle)
        {
            rectNew.left = nWidth - ((rectParentOrg.right)-WndChild.rectOrginal.left);
            rectNew.right = rectNew.left + WndChild.rectOrginal.Width();
        }
        else if(WA_LEFTBOTTOM & WndChild.nStyle)
        {
            rectNew.top = nHeight - ((rectParentOrg.bottom)-WndChild.rectOrginal.top);
            rectNew.bottom = rectNew.top + WndChild.rectOrginal.Height();
        }
        else if(WA_RIGHTBOTTOM & WndChild.nStyle)
        {
            rectNew.left = nWidth - ((rectParentOrg.right)-WndChild.rectOrginal.left);
            rectNew.right = rectNew.left + WndChild.rectOrginal.Width();
        }
        else if(WA_LEFTTOP & WndChild.nStyle)
        {
 
        }
 
        if(WA_RESIZE_WIDTH & WndChild.nStyle)
        {
            rectNew.right += (nWidth-rectParentOrg.Width());
        }
        if(WA_RESIZE_HEIGHT & WndChild.nStyle)
        {
            rectNew.bottom += (nHeight-rectParentOrg.Height());
        }
        
        MoveWindow(WndChild.hWnd, rectNew.left, rectNew.top, rectNew.Width(), rectNew.Height(), TRUE);
    }
 
}