How to define the client area of a window (Views: 100)
Is it possible to define (set the size and position) of a window's client area (without resizing the window itself)? What I want to do is increase the non-client area to get more space to paint my own custom borders around a window. I want this to be reflected to the client area so that my border is protected from anything that goes on in the client area (painting, scrolling etc.).
You have to handle the WM_NCCALCSIZE message on your form. See win32.hlp for details. The following example handler for a TListBox descendent excludes some space for a header bar from the listboxes client area:
procedure THeaderListbox.wmnccalcsize(var msg: TWMNCCALCSIZE);
if msg.CalcValidRects then
with msg.CalcSize_Params^.rgrc do
top := top + Itemheight + 4;
I hope you know how to define a message handler in the class declaration.
<< Back to main page