[code]이런식으로 템플릿(?) 을 만들어 두면 배경색 수정하기가 용이하니깐. 갈수록 나에 짱구는 -_- 잔머리가...[/code]
// FormViewEx.cpp : implementation file
//
#include "stdafx.h"
#include "Main Unit Manager.h"
#include "FormViewEx.h"
// CFormViewEx
IMPLEMENT_DYNCREATE(CFormViewEx, CFormView)
CFormViewEx::CFormViewEx()
: CFormView(CFormViewEx::IDD)
{
}
CFormViewEx::CFormViewEx(UINT nResorceID)
: CFormView(nResorceID)
{
m_br.CreateSolidBrush(g_cfg.m_crFormViewColor);
}
CFormViewEx::~CFormViewEx()
{
m_br.DeleteObject();
}
void CFormViewEx::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CFormViewEx, CFormView)
ON_WM_CTLCOLOR()
ON_WM_SIZE()
END_MESSAGE_MAP()
// CFormViewEx diagnostics
#ifdef _DEBUG
void CFormViewEx::AssertValid() const
{
CFormView::AssertValid();
}
#ifndef _WIN32_WCE
void CFormViewEx::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif
#endif //_DEBUG
// CFormViewEx message handlers
HBRUSH CFormViewEx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
// 컨트롤 아이디 기준이 50000 이상은 폼에 해당하는 것 같아서
// 이런식으로 사용.
if (pWnd->GetDlgCtrlID() > 50000)
{
// 배경색 변경
return (HBRUSH)m_br;
}
return hbr;
}
void CFormViewEx::OnSize(UINT nType, int cx, int cy)
{
// 스크롤 바 없애기
}
[code]Header[/code]
#pragma once
// CFormViewEx form view
class CFormViewEx : public CFormView
{
DECLARE_DYNCREATE(CFormViewEx)
protected:
CFormViewEx(); // protected constructor used by dynamic creation
CFormViewEx(UINT nResorceID);
virtual ~CFormViewEx();
public:
enum { IDD = IDD_FORMVIEWEX };
#ifdef _DEBUG
virtual void AssertValid() const;
#ifndef _WIN32_WCE
virtual void Dump(CDumpContext& dc) const;
#endif
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
CBrush m_br;
DECLARE_MESSAGE_MAP()
public:
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnSize(UINT nType, int cx, int cy);
};
// FormViewEx.cpp : implementation file
//
#include "stdafx.h"
#include "Main Unit Manager.h"
#include "FormViewEx.h"
// CFormViewEx
IMPLEMENT_DYNCREATE(CFormViewEx, CFormView)
CFormViewEx::CFormViewEx()
: CFormView(CFormViewEx::IDD)
{
}
CFormViewEx::CFormViewEx(UINT nResorceID)
: CFormView(nResorceID)
{
m_br.CreateSolidBrush(g_cfg.m_crFormViewColor);
}
CFormViewEx::~CFormViewEx()
{
m_br.DeleteObject();
}
void CFormViewEx::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CFormViewEx, CFormView)
ON_WM_CTLCOLOR()
ON_WM_SIZE()
END_MESSAGE_MAP()
// CFormViewEx diagnostics
#ifdef _DEBUG
void CFormViewEx::AssertValid() const
{
CFormView::AssertValid();
}
#ifndef _WIN32_WCE
void CFormViewEx::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif
#endif //_DEBUG
// CFormViewEx message handlers
HBRUSH CFormViewEx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
// 컨트롤 아이디 기준이 50000 이상은 폼에 해당하는 것 같아서
// 이런식으로 사용.
if (pWnd->GetDlgCtrlID() > 50000)
{
// 배경색 변경
return (HBRUSH)m_br;
}
return hbr;
}
void CFormViewEx::OnSize(UINT nType, int cx, int cy)
{
// 스크롤 바 없애기
}
[code]Header[/code]
#pragma once
// CFormViewEx form view
class CFormViewEx : public CFormView
{
DECLARE_DYNCREATE(CFormViewEx)
protected:
CFormViewEx(); // protected constructor used by dynamic creation
CFormViewEx(UINT nResorceID);
virtual ~CFormViewEx();
public:
enum { IDD = IDD_FORMVIEWEX };
#ifdef _DEBUG
virtual void AssertValid() const;
#ifndef _WIN32_WCE
virtual void Dump(CDumpContext& dc) const;
#endif
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
CBrush m_br;
DECLARE_MESSAGE_MAP()
public:
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnSize(UINT nType, int cx, int cy);
};
'Windows > MFC' 카테고리의 다른 글
XP Theme 관련 (0) | 2013.10.02 |
---|---|
SetWindowPos 윈도우 크기 변경 (0) | 2013.10.02 |
CMenu 메뉴 삭제 (0) | 2013.10.02 |
CFormView 에서 Scrollbar 막기, 없애기 스크롤바 (0) | 2013.10.02 |
Windows API Tip (0) | 2013.10.02 |