Author: Jonas Bilinkevicius
How to give a listbox a rounded border
Answer:
To round a ListBox use CreateRoundRectRgn to shape it. Reduce the client size to
reposition back in place. Experiment with the rounding value. The greater the round
value the smoother it is.
Add a TListBox to a form
1 procedure TForm1.RoundListbox(var TheList: TListbox);
2 const3 schange = 5;
4 rnd = 20;
5 var6 thergn: HRGN;
7 mclient: TRect;
8 begin9 mclient := TheList.ClientRect; {get size}10 thergn := CreateRoundRectRgn(mclient.Left, mclient.top, mclient.right,
11 mclient.bottom, rnd, rnd);
12 TheList.BorderStyle := bsNone;
13 InflateRect(mclient, -schange, -schange); {shrink}14 TheList.Perform(EM_SETRECTNP, 0, lparam(@mclient)); {change}15 SetWindowRgn(TheList.Handle, thergn, true);
16 end;