开发者

Delphi. Remove a border of TabSheet of PageControl

Is it possible to r开发者_StackOverflow中文版emove a border of TabSheet (~4px)? I am using PageControl as a switch-panel instead of frames, windows etc. I want everything will be straight.


unit Unit1;

interface

uses
  ...,
  CommCtrl;

type
  TPageControl = class(ComCtrls.TPageControl)
  private
    procedure TCMAdjustRect(var Msg: TMessage); message TCM_ADJUSTRECT;
  end;

  TForm1 = class(TForm)
    ...
  end;

...

procedure TPageControl.TCMAdjustRect(var Msg: TMessage);
begin
  inherited;
  if Msg.WParam = 0 then
    InflateRect(PRect(Msg.LParam)^, 4, 4)
  else
    InflateRect(PRect(Msg.LParam)^, -4, -4);
end;

...

end.


If you don't mind using third-party tools then the easiest solution would probably be to use TjvPageControl from JVCL. It has ClientBorderWidth property which you are looking for.


An alternative is to use a TTabSet with a TPageControl: In the onCreate event of the form, place this code to hide the tab.

procedure TMainForm.FormCreate(Sender: TObject);
var
    I : Integer;
begin
   for I := 0 to Pred(PageControl1.PageCount) do
       PageControl1.Pages[I].TabVisible := False;
   PageControl1.Style := tsFlatButtons;
   PageControl1.ActivePageIndex := 0;

   TabSet1.Style := tsModernPopout;
   TabSet1.SelectedColor := clMoneyGreen;
   TabSet1.UnselectedColor := clGradientActiveCaption;
   TabSet1.SelectedColor := clGradientActiveCaption;
end;


procedure TMainForm.TabSet1Change(Sender: TObject; NewTab: Integer;
  var AllowChange: Boolean);
begin
   PageControl1.ActivePageIndex := NewTab;
end;


nowadays, that is the answer. No need any code hacks
Probably you use themes, if not, you should use that technology:

  • Project Options > Application> Appearance

  • Check on one of them as Default Style)

    than :

  • Tools > Bitmap Style Designer > Open Style
  • Navigate your vsf style file
    (probably right here "C:\Users\Public\Documents\Embarcadero\Studio[VERSION]\Styles

  • Now In Bitmap Style Designer.. navigate to:
    Objects > Tabs > Frame > Bitmap

  • Click [...] three dot button of Bitmap In Inspector
  • Zoom to 800%
  • Pan/Scroll and Focus on to bitmap rectangle range.
  • Right Mouse Click to change Upper-Left, Left Mouse Click to change Lower-Right region.
    (so select inner rectangle to eliminate border bitmap now you have borderless page controls)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜