In Windows 3.X, using WS_CAPTION got you a border and a title bar, but not a dialog frame. This meant that having a border and a dialog frame were mutually exclusive. Clearing WS_CAPTION would remove both the title and the border in a Windows 3 application. In these apps, you would remove the title bar by clearing only the WS_DLGFRAME portion in conjunction with utilizing the WS_POPUP style. Win32 offers a new set of extended windows styles. You can use extended window styles to create a window with a dialog frame, a border, and no title bar.
This combination produces a window with a border and a dialog frame whenever you specify bsDialog as the BorderStyle. We clear WS_CAPTION when we override CreateParams, but the form retains its border because of the assignment to the ExStyle. The assignment to ExStyle does not happen when you set BorderStyle to something other than bsDialog, which means you should stick with the bsDialog style when utilizing the code from this FAQ.
Note: If you need a resizable, captionless form, change CreateParams like this:
void __fastcall TForm1::CreateParams(TCreateParams &Params)
TForm::CreateParams(Params); // call base class first
Params.Style &= ~WS_DLGFRAME;
Params.Style |= WS_POPUP;
This code always works, without regard to the BorderStyle property of the form. However, it is less intuitive than clearing the WS_CAPTION bits.