본문 바로가기

Windows/MFC

Custom Control (커스텀 컨트롤) 사용하기

[code]위치를 잡아주는게 그냥 맨땅에서 하는 것보단 커스텀 컨트롤 하나 떡하니 올려놓고 하는게 아무래도
편하다 보니 ^.^ 근데 왜케 dll 참조해서 사용하는 것 밖에 데브엔 없는 건지...

참조 코드 : http://www.codeproject.com/miscctrl/jobwnd.asp
[/code]

// PositionReportDetail.cpp : implementation file
//

#include "stdafx.h"
#include "PosTest.h"
#include "PositionReportDetail.h"

#define ADVANCED_UI_CLASSNAME _T("PositionReportDetail")

// CPositionReportDetail

IMPLEMENT_DYNAMIC(CPositionReportDetail, CWnd)

CPositionReportDetail::CPositionReportDetail()
{
    RegisterWindowClass();
}

CPositionReportDetail::~CPositionReportDetail()
{
}


BEGIN_MESSAGE_MAP(CPositionReportDetail, CWnd)
END_MESSAGE_MAP()



// CPositionReportDetail message handlers

BOOL CPositionReportDetail::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
    return CWnd::Create(lpszClassName, ADVANCED_UI_CLASSNAME, dwStyle, rect, pParentWnd, nID, pContext);
}

bool CPositionReportDetail::RegisterWindowClass(void)
{
    WNDCLASS wndcls;
    HINSTANCE hInst = AfxGetInstanceHandle();

    if (!(::GetClassInfo(hInst, ADVANCED_UI_CLASSNAME, &wndcls)))
    {
        // 새로운 클래스를 정의 해 주도록 하고.
        wndcls.style            = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
        wndcls.lpfnWndProc     = ::DefWindowProc;
        wndcls.cbClsExtra     = wndcls.cbWndExtra = 0;
        wndcls.hInstance        = hInst;
        wndcls.hIcon            = NULL;
        wndcls.hCursor         = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
        wndcls.hbrBackground    = (HBRUSH)GetSysColorBrush(COLOR_3DFACE);
        wndcls.lpszMenuName     = NULL;
        wndcls.lpszClassName    = ADVANCED_UI_CLASSNAME;

        if (!AfxRegisterClass(&wndcls))
        {
            AfxThrowResourceException();
            return false;
        }
    }

    return true;
}

[code]header[/code]
#pragma once


// CPositionReportDetail

class CPositionReportDetail : public CWnd
{
    DECLARE_DYNAMIC(CPositionReportDetail)

public:
    CPositionReportDetail();
    virtual ~CPositionReportDetail();

protected:
    DECLARE_MESSAGE_MAP()
public:
    virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
    bool RegisterWindowClass(void);
};


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

Fullscreen (전체 화면 )  (0) 2013.10.02
CHeaderCtrl  (0) 2013.10.02
GetKeyState  (0) 2013.10.02
CDialogBar 상속해보기  (0) 2013.10.02
CButtonEx (Version 1.5)  (0) 2013.10.02