본문 바로가기

Windows/MFC

CRectEx

[code]// DATE        : February 21, 2007
// CODER    : aucd29 (aucd29@gmail.com)
// VERSION    : 1.0
//
//

// NOTE : February 21, 2007
// --------------------------------------------------------------
// * RECT 가지고 로그 찍기 귀찮아서 만든다 -_ -
// * Construct 에서 바로 처리할 수 있도록 변경
//
// --------------------------------------------------------------
// DESCRIPTION
// --------------------------------------------------------------
// 1. 먼저 헤더파일을 인클루드 해야겠지?
// 2. 변수 선언
// 3. 값을 가져와야겟지
// 4. 리턴된 CRect 값을 확인해볼 수 도 있다.
// 5. 혹은 전처럼 사용할 수 도 있다.
//    
// CRectEx rect;
// rect.GetClientRect(this);
// rect.Print(L" HOHO");
//
// GetClientRect(rect);
// rect.Print(L" HAHA");
//
// CRectEx rect2(this);
// rect2.Print(L" HEHE");
//


#include "StdAfx.h"
#include "RectEx.h"

CRectEx::CRectEx(void)
{
}

CRectEx::CRectEx(CWnd* obj)
{
    obj->GetClientRect(this);
}

CRectEx::~CRectEx(void)
{
}

CPoint CRectEx::GetWindowGap(CWnd* obj)
{
    CRect rect;

    obj->GetClientRect(this);
    obj->GetWindowRect(rect);

    Print(L" CLIENT");
    Print(rect, L" WINDOW");

    // 윈도우 전체 크기와 다이얼로그 크기를 비교해서 리턴
    // -3 을 한 이유는 좌우 하단에 보더값이 존재 하기 때문
    return CPoint(rect.Width() - Width() - 3, rect.Height() - Height() - 3);
}

void CRectEx::Print(CString szTitle)
{
    TRACE(L"RECT%s : %d %d %d %d %d %d\n", szTitle, left, top, right, bottom, Width(), Height());
}

void CRectEx::Print(CRect rect, CString szTitle)
{
    TRACE(L"RECT%s : %d %d %d %d %d %d\n", szTitle, rect.left, rect.top, rect.right, rect.bottom, rect.Width(), rect.Height());
}

CRect CRectEx::GetClientRect(CWnd* obj)
{
    obj->GetClientRect(this);
    return this;
}

CRect CRectEx::GetWindowRect(CWnd* obj)
{
    obj->GetWindowRect(this);
    return this;
}
[/code]


[code]
#pragma once
#include "atltypes.h"

class CRectEx :
    public CRect
{
public:
    CRectEx(void);
    CRectEx(CWnd* obj);
    ~CRectEx(void);
    CPoint GetWindowGap(CWnd* obj);
    void Print(CString szTitle = L"");
    void Print(CRect rect, CString szTitle = L"");
    CRect GetClientRect(CWnd* obj);
    CRect GetWindowRect(CWnd* obj);
};
[/code]

'Windows > MFC' 카테고리의 다른 글

다이얼로그에 색을 가져오자 Dialog color (GetSysColor)  (0) 2013.10.02
CButtonEx  (0) 2013.10.02
MFC TIP  (0) 2013.10.02
XML Parser  (0) 2013.10.02
MSXML 6.0  (0) 2013.10.02