Bevel Line control

Bevel Line control

This article was submitted .

This simple control is a subclassed STATIC Windows control, which paints a sunked or raised line. It's that very nice layout gadget you need to separate groups of controls, but is difficult to get right using the standard controls.

To use it, place a static control (label) on your dialog.
Add a member variable to your dialog implementation file...

CBevelLine m_ctlBevel
In the OnInitDialog() event handler, add the following line:
  LRESULT OnInitDialog(UINT /*uMsg*/, 
                       WPARAM /*wParam*/, 
                       LPARAM /*lParam*/, 
                       BOOL& /*bHandled*/)

The control draws a horizontal line if the width is larger than the height, otherwise a vertical line is drawn.
Use the m_bSunken variable to control whether to draw a sunked or raised line.


Someone noted that it is possible to create a similar control just by using the Picture control with a height of 1 pixel. Unfortunately the Picture control is subject to automatic resizing when a large font is used.

Source Code Dependencies

Microsoft Visual C++ 6.0
Microsoft WTL 3.0 Library

Download Files

DownloadSource Code (2 Kb)