Wednesday, January 20, 2010

New Group Box

I decided that I'd rather see a more accurate version of the group box control I had in mind so I put together a new custom control.

The code needs some optimisation, for example the WM_PAINT handler is building some objects that could be created once during the control initialisation, but it's mostly there.

A quick sample of the various styles can be seen here:

gbdemo

Code wise, the control creation is simple and I've coded to allow for use in the dialog editor.

Sample code for creating the upper right box would be:

 

CRect _rGB2(CPoint(350, 20), CSize(250, 150));

CBCLGroupbox Groupbox2 = new CBCLGroupbox;

Groupbox2->setTextBoxOffset(15, 0)

.setTextBoxBorderPadding(5, 5)

.setGroupboxBkColour(RGB(236, 245, 216))

.setGroupboxBorderColour(RGB(0, 0, 0))

.setGroupboxTextBoxBkColour(RGB(186, 215, 97))

.setGroupboxTextColour(RGB(0, 0, 0))

.setDropShadow(7, ::GetSysColor(COLOR_3DDKSHADOW));

Groupbox2->Create("Shadow Colour Groupbox", _rGB2, this, 1);

Simple enough to be useful.

No comments: