- classlib.zip
- classlibsamples.zip
- samplesexe.zip
- ADO.exe
- Browser.exe
- Colorpicker.exe
- CRC.exe
- DynamicDialog.exe
- FastFind.exe
- FileDirTree.exe
- Hash.exe
- InfoBar.exe
- LayoutEngine.exe
- MDI.exe
- MRU.exe
- MultiMon.exe
- PanelBar.exe
- XPControls.exe
- XPMenu.exe
- samples.zip
- Browser.exe
- Colorpicker.exe
- CRC.exe
- DynamicDialog.exe
- FastFind.exe
- FileDirTree.exe
- Hash.exe
- InfoBar.exe
- LayoutEngine.exe
- MDI.exe
- MRU.exe
- MultiMon.exe
- XPMenu.exe
- classes.zip
- Classes
- ALL.H
- application.cpp
- application.h
- ClassHierarchy.txt
- ClassLib.dsp
- ClassLib.dsw
- ClassLib.sln
- ClassLib.suo
- ClassLib.vcproj
- Collectors
- Coords
- Exceptions
- GDI
- History.txt
- IO
- Layout
- LIB6
- LIB7
- Menus
- Samples
- Colorpicker
- CRC
- DynamicDialog
- FastFind
- FileDirTree
- Hash
- InfoBar
- LayoutEngine
- MDI
- MRU
- MultiMon
- XPMenu
- Shell
- STANDARD.H
- Strings
- Threads
- TODO.TXT
- Tools
- Windows
|
//
// palette.cpp
//
// (C) Copyright 2000 Jan van den Baard.
// All Rights Reserved.
//
#include "palette.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// Constructor.
ClsPalette::ClsPalette()
{
}
// Destructor. Does nothing.
ClsPalette::~ClsPalette()
{
}
// Create palette.
BOOL ClsPalette::CreatePalette( const LOGPALETTE *pLogPalette )
{
// Attach the palette.
Attach( ::CreatePalette( pLogPalette ));
return ( BOOL )( m_hGdiObject ? TRUE : FALSE );
}
// Create half-tone palette.
BOOL ClsPalette::CreateHalftonePalette( HDC hDC )
{
// Attach the palette.
Attach( ::CreateHalftonePalette( hDC ));
return ( BOOL )( m_hGdiObject ? TRUE : FALSE );
}
// Animate palette.
void ClsPalette::AnimatePalette( UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY pPaletteColors )
{
_ASSERT_VALID( m_hGdiObject ); // Must be valid.
// Animate.
::AnimatePalette(( HPALETTE )m_hGdiObject, nStartIndex, nNumEntries, pPaletteColors );
}
// Get palette index.
UINT ClsPalette::GetNearestPaletteIndex( COLORREF crColor ) const
{
_ASSERT_VALID( m_hGdiObject ); // Must be valid.
// Get index.
return ::GetNearestPaletteIndex(( HPALETTE )m_hGdiObject, crColor );
}
// Resize the palette.
BOOL ClsPalette::ResizePalette( UINT nNumEntries )
{
_ASSERT_VALID( m_hGdiObject ); // Must be valid.
// Resize...
return ::ResizePalette(( HPALETTE )m_hGdiObject, nNumEntries );
}
// Realize the palette.
UINT ClsPalette::RealizePalette( HDC hDC )
{
_ASSERT_VALID( m_hGdiObject ); // Must be valid.
// Realize...
return ::RealizePalette( hDC );
}
// Retrieve palette entries.
UINT ClsPalette::GetPaletteEntries( UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY pPaletteColors ) const
{
_ASSERT_VALID( m_hGdiObject ); // Must be valid.
// Get the entries.
return ::GetPaletteEntries(( HPALETTE )m_hGdiObject, nStartIndex, nNumEntries, pPaletteColors );
}
// Set palette entries.
UINT ClsPalette::SetPaletteEntries( UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY pPaletteColors )
{
_ASSERT_VALID( m_hGdiObject ); // Must be valid.
// Set the entries.
return ::SetPaletteEntries(( HPALETTE )m_hGdiObject, nStartIndex, nNumEntries, pPaletteColors );
}
// Get the entry count of the palette.
WORD ClsPalette::GetEntryCount() const
{
_ASSERT_VALID( m_hGdiObject ); // Must be valid.
WORD wCount = 0;
// Get the object count.
GetObject( sizeof( WORD ), ( LPVOID )&wCount );
return wCount;
}
// Get a stock palette.
BOOL ClsPalette::GetStockPalette( int nObject )
{
// Get the stock palette.
HPALETTE hPalette = ( HPALETTE )GetStockObject( nObject );
// Make sure it is a palette.
if ( hPalette && ::GetObjectType( hPalette ) != OBJ_PAL )
return FALSE;
// Attach the object.
Attach( hPalette );
return TRUE;
}
// Return the object of the handle.
ClsPalette *ClsPalette::FromHandle( HPALETTE hPalette )
{
return ( ClsPalette * )ClsGdiObject::FromHandle( hPalette );
}
// Operator to return the palette handle.
ClsPalette::operator HPALETTE() const
{
// Return the handle.
return ( HPALETTE )m_hGdiObject;
}
|
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.
I have been programming for a hobby since 1985. I have started programming on the C= 64. After that I migrated to the C= Amiga which I traded in for a PC back in 1997 I believe. Back in 2000 I decided to lose a hobby and start developing software for a living.
Currently I am working mainly in developing software for building security and access control systems.