November 1998

Trouble on the border

by Kent Reisdorph

Both the PageControl component and the Notebook component we discuss in the accompanying article have problem borders. In fact, the notebook has no border at all. You can easily fix this, however, by placing the notebook on a panel and setting the border style of the panel as desired. (It's unlikely that you'll want to go to this effort, since you typically won't want a border on your paging control.)

The PageControl component has the opposite problem: You're forced to accept the default raised-edge border because the component has no BorderStyle property. (This is really a limitation of the underlying Win32 tab control, rather than the VCL PageControl component.) Fortunately, you can get around this border problem--but only by brute force.

To hide the raised border, first set the page control's Align property to alNone. Next, set the form's AutoScroll property to false. Then, create the following event handler for the OnResize event:


void __fastcall 
TForm1::FormResize(TObject *Sender)
{
  PageControl1->SetBounds(-3, -3, 
    ClientWidth + 5, ClientHeight + 5);
}

Manually position the page control so the painted border is hidden outside the form's displayable area. This approach has one drawback: The contents of the form may flicker as you resize the form (depending on your Windows settings). As an alternative to using the OnResize event, you can disallow sizing of the form. In this case, you'll want to position the page control in the form's OnCreate event handler. If you go this route, change the form's BorderStyle property to bsSingle and place the previous code snippet in the form's OnCreate event handler.