Delphi. Remove a border of TabSheet of PageControl

久未见 提交于 2019-12-31 21:16:12

问题


Your help is needed.

Is it possible to remove a border of TabSheet (~4px)? I am using PageControl as a switch-panel instead of frames, windows etc. I want everything will be straight.

Big thanks for help!


回答1:


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.



回答2:


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.




回答3:


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;


来源:https://stackoverflow.com/questions/6274626/delphi-remove-a-border-of-tabsheet-of-pagecontrol

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!