Click here to Skip to main content
15,897,891 members
Articles / Desktop Programming / MFC

SkinControls 1.1 - A journey in automating the skinning of Windows controls

Rate me:
Please Sign up or sign in to vote.
4.97/5 (80 votes)
11 Oct 200314 min read 361K   19.8K   274  
A self-contained, user-extensible, application-wide skinning architecture for Windows controls.
// delayredraw.cpp : implementation file
//

#include "stdafx.h"
#include "delayredraw.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDelayRedraw

BOOL CDelayRedraw::Start(HWND hWnd, int nDelay)
{
	CDelayRedraw* pRedraw = new CDelayRedraw(hWnd, nDelay);

	return pRedraw ? pRedraw->Create(NULL, NULL, WS_POPUP) : FALSE;
}

CDelayRedraw::CDelayRedraw(HWND hWnd, int nDelay) : m_hwndRef(hWnd), m_nDelay(nDelay)
{
	
}

CDelayRedraw::~CDelayRedraw()
{
}


BEGIN_MESSAGE_MAP(CDelayRedraw, CFrameWnd)
	//{{AFX_MSG_MAP(CDelayRedraw)
	ON_WM_CREATE()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CDelayRedraw message handlers

int CDelayRedraw::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (!::IsWindow(m_hwndRef) || m_nDelay <= 0)
		return -1;

	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	SetTimer(1, m_nDelay, NULL);
	
	return 0;
}

void CDelayRedraw::OnTimer(UINT nIDEvent) 
{
	CFrameWnd::OnTimer(nIDEvent);

	if (nIDEvent == 1)
	{
		KillTimer(1);

		::InvalidateRect(m_hwndRef, NULL, TRUE);
		::UpdateWindow(m_hwndRef);

		::SendMessage(m_hwndRef, WM_NCPAINT, 0, 0);

		DestroyWindow();
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer Maptek
Australia Australia
.dan.g. is a naturalised Australian and has been developing commercial windows software since 1998.

Comments and Discussions