viksoe.dk

atlgdix.h

Written by Bjarke Viksoe.
This article was submitted .


This set of classes adds a few nice GDI wrappers to WTL.

COffscreenDraw

Primary to the set is the offscreen memory DC and message map class, which replaces your ordinary OnPaint() and DoPaint() with an offscreen memory device. It's for that flicker-free look you've been looking for.

To use it, derive from COffscreenDraw<Base> and add the following to your message map...

  BEGIN_MSG_MAP(Base)
    CHAIN_MSG_MAP(COffscreenDraw<Base>)
    ...
  END_MSG_MAP()
Remember to replace Base with the name of the most derived class.
Then implement the DoPaint method (if you handled the WM_PAINT or WM_ERASEBKGND messages yourself then remove these).
  void DoPaint(CDCHandle dc)
  {
    // code code code  
  }
You must erase your background before you draw anything else in DoPaint.

CMemDC

The CMemDC class is the actual offscreen memory DC used by the COffscreenDraw message map class.
If you want to do specific offscreen custom drawing, use this instead.

CIcon and CIconHandle

The HICON all wrapped up.
This class is now part of the WTL framework itself.

CCursor and CCursorHandle

The HCURSOR handle in a class.
This class is now part of the WTL framework itself.

CAccelerator and CAcceleratorHandle

The HACCEL and its friends.
This class is now part of the WTL framework itself.

CLogFont

The LOGFONT font structure with plenty of helper functions.
This class is now part of the WTL framework itself.

CSaveDC

Wraps the ::SaveDC() and ::RestoreDC() Win32 API calls. Use it when you're in doubt if you're releasing all your GDI objects properly.

CHandle

The new ATL Server library defines a CHandle class. Here is a similar class for older versions.

CMouseHover

This helper class adds the ability to get WM_MOUSEENTER and WM_MOUSELEAVE messages when the cursor hovers over a window.
To use it, let the window derive from the class and chain it in the message map (place the chain at the top). Note that WM_MOUSEENTER is a private message.

Source Code Dependencies

Microsoft WTL 3.0 Library

Download Files

DownloadSource Code (6 Kb)

To the top