procedure TMainForm.FormCreate(Sender: TObject);
var
  Setting: LongInt;
begin
  if BorderStyle= bsNone then Exit;
  Setting:= GetWindowLong(Handle, gwl_style);
  if (Setting and ws_Caption)= ws_Caption then
    begin
      case BorderStyle of
        bsSingle,
        bsSizeable: SetWindowLong(Handle, gwl_Style, Setting and (Not(ws_Caption))or ws_border);
        bsDialog: SetWindowLong(Handle, gwl_Style, Setting and (Not(ws_Caption))or ds_modalframe or ws_dlgframe);
      end;
    end;
   Height:= Height- getSystemMetrics(sm_cyCaption);
   Refresh;
end;