Blue Marquee selection

Blue Marquee selection

This article was submitted .

While tinkering with my GMail Drive tool, I noticed a remarkable feature in the Windows Explorer file list on Windows XP. When you drag a bounding selection box (marquee) to select multiple items in the list control, it paints a blue "transparent" selection box.

The marquee is semi-transparent so items are still displayed under it. It is much nicer than the striped rubber band rectangle that is normally used, because you can capture the items easier with the visual feedback. The Windows ListView control, which is at the base of the file list, doesn't seem to expose this feature natively (see note). It's also an interesting feature, because other of the flashy effects in Windows XP are made the same way as far as I can figure. This includes another Windows Explorer shiny effect: the translucent drag'n'drop images (with radial transparency) and probably the menu shadows as well.

These effects could simply take advantage of a trick I learned a long time ago, the WS_EX_TRANSPARENT Windows style that allows the windows to appear transparent - not covering the pixels of the window below it. The style wasn't properly documented on MSDN for many years but its name is a giveaway.

The translucency effect is based on the layered window capability from Windows 2000 (WS_EX_LAYERED style). A layered window asks your graphics card to paint the window with an alpha-channel. Alpha-channel is transparency. At its simplest form, you just tell the window to become 50% transparent. At its most complex setup, you can define a different transparency pr. pixel - allowing your window to slowly fade out at its edges.

The trick is to create a new window that hovers on top of our control (the ListView control for the Explorer). We show the window only when the selection box is about to be displayed, place it exactly over the list control and then we paint the selection box onto it. The selection box is drawn as a solid rectangle. By setting the mentioned Windows styles, we make the window behave as transparent and with the alpha-blending effect on the window underneath, it appears semi-transparent.

How to use it

In a dialog with a ListView control you add it as an additional control. The control needs to absorb messages in the parent since it must catch the LVN_MARQUEEBEGIN notification event.

So add a member variable to your dialog implementation file...

  CListViewMarquee m_ListMarquee;
In the OnInitDialog() event handler, add the following lines:
LRESULT OnInitDialog(UINT /*uMsg*/, 
                     WPARAM /*wParam*/, 
                     LPARAM /*lParam*/, 
                     BOOL& /*bHandled*/)

Add the following reflection macros to your main message map:

  CHAIN_MSG_MAP_ALT_MEMBER( m_ListMarquee, 1 )


I have since then been made aware that the ListView control does actually support the blue marquee natively - with the use of the LVS_EX_DOUBLEBUFFER extended style. Since it seems to be related to double buffering, one might also suspect that it is really implemented using the Win32 AlphaBlend function and not with a transparent popup window at all.

Source Code Dependencies

Windows XP
Microsoft Visual C++ 6.0
Microsoft WTL 7.5 Library

Download Files

DownloadSource Code (49 Kb)

To the top