Visit the Ultimate Toolbox main page for an overview and configuration guide to the Ultimate Toolbox library.
Contents
The Ultimate Toolbox contains several classes that enable the integration of graphic-based routines in your MFC based application.
COXDIB
is an MFC extension encapsulating DIB operations. It includes functionality for reading/writing BMP and JPG files, conversion, palette extraction, resizing, rotation (at 90°increments), dithering, and drawing. Many of the Ultimate Toolbox classes make use of this class for graphics file rendering.
As an example, consider the rendering of a large 24 bit per pixel bitmap in a small area on a 256 color display. The best approach is to resize, dither, then render the resulting dib:
...
m_DIB.Read("c:\some.bmp");
m_DIB.ResizeDIB(320, 200);
m_DIB.HalfToneDitherDIB();
...
m_PeriDIB.Paint(pDC, CRect(0, 0, 320, 200), CRect(0, 0, 320, 200));
...
COXGraphics
class was designed in order to provide advanced graphics routines for programmers. It is currently used internally in the COXRoundedButton
class to render the button.
void COXRoundedButton::DrawButtonBackground(CDC* pDC, CRect buttonRect,
UINT nState, CPalette* pPalette)
{
COLORREF BackColor=m_clrBk;
CSize szRadius=CalcSphereRadius();
COXGraphics graphics;
if (!(IsChecked() || (nState & ODS_SELECTED) == ODS_SELECTED))
{
graphics.DrawRoundedButton(pDC,buttonRect.left,buttonRect.top,
buttonRect.Width(),buttonRect.Height(),
szRadius.cx,szRadius.cy,pPalette,
m_clrButton,m_clrLight,m_fThetta,
m_fPhi,m_fLightIntensityCoef,
m_nPhong,m_fMirror,m_fDiffuse,
m_fAmbient,BackColor);
}
else
{
graphics.DrawRoundedButton(pDC,buttonRect.left,buttonRect.top,
buttonRect.Width(),buttonRect.Height(),
szRadius.cx,szRadius.cy+(szRadius.cx-szRadius.cy)/3,pPalette,
m_clrButton,m_clrLight,m_fThetta,
m_fPhi+180,m_fLightIntensityCoef,
m_nPhong,0,m_fDiffuse,
m_fAmbient,BackColor);
}
}
The COXImageViewer
class is a COXScrollWnd
based class which is designed to display DIB (bitmap) and (optionally) JPEG images.
The
samples\graphics\ImageViewer sample in action.
COXMetaFile
supports Windows 3.x, Aldus header and enhanced metafiles (*.wmf and *.emf).
A metafile as displayed in the
samples/graphics/metafile example.
void CMetaFileView::OnDraw(CDC* pDC)
{
CMetaFileDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect rectClient;
GetClientRect( &rectClient);
if (m_bMaintainRatio)
{
if (! pDoc->m_MetaFile.PlayFile (pDC, &rectClient) )
AfxMessageBox (_T("Error in COXMetaFile::PlayFile"));
}
else
{
if (! pDoc->m_MetaFile.PlayFile (pDC ) )
AfxMessageBox (_T("Error in COXMetaFile::PlayFile"));
}
return ;
}
COXSplashWnd
and COXSplashWndDIB
allow for quick and easy implementation of customizable splash windows.
The LoadBitmap method of COXSplashWndDib
can specify a border color (default is 0xFF000000) that will be made transparent, giving the appearance of a shaped window. Each outer pixel in this color will be made invisible.
COXSplashWnd
can be seen in action in the samples\graphics\Splash example.
Initial CodeProject release August 2007.
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.
Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.