|
///////////////////////////////////////////////////////////////
//
// GDIUtils.cpp
//
// Created: 09/07/2005
// Copyright (c) 2005 Ralph Hare (ralph.hare@ysgyfarnog.co.uk)
// All rights reserved.
//
// The code and information is provided "as-is" without
// warranty of any kind, either expressed or implied.
//
///////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "GDIUtils.h"
#include "OSUtils.h"
namespace
{
//
// Wrapper around the SetLayeredWindowAttributes API. Rather than statically
// linking to it, we dynamically link so that MouseGestures.dll will load
// on NT4 and the like, but the mouse trails will be disabled
//
class LayerHelper
{
public:
LayerHelper() :
m_hMod( ::LoadLibrary( _T( "User32.dll" ) ) ),
m_pfn( NULL )
{
m_pfn = reinterpret_cast< SLWA_PROC * >( ::GetProcAddress( m_hMod, "SetLayeredWindowAttributes" ) );
}
~LayerHelper()
{
::FreeLibrary( m_hMod );
}
BOOL __stdcall SetLayeredWindowAttribute( HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags )
{
if( m_pfn )
{
return ( *m_pfn )( hWnd, crKey, bAlpha, dwFlags );
}
return FALSE;
}
private:
typedef BOOL ( __stdcall SLWA_PROC )( HWND, COLORREF, BYTE, DWORD );
private:
HMODULE m_hMod;
SLWA_PROC *m_pfn;
};
}
namespace GDIUtils
{
BOOL __stdcall SetLayeredWindowAttribute( HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags )
{
if( OSUtils::IsNT4() )
{
return TRUE;
}
static LayerHelper lh;
return lh.SetLayeredWindowAttribute( hWnd, crKey, bAlpha, dwFlags );
}
}
|
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.
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
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.