2011-08-23 105 views
1

我有一個TabControl放在窗體上。這是一個VB.net窗口應用程序。無邊界TabControl

我想設置TabControl的邊界完全看不見類似formBorderstyle =無

我無法找到一個TabControl的任何設置,除去可見的邊框。 請推薦!

回答

1

這應該工作,並假定有2個選項卡控件。如果你有更多的話,相應調整。

Imports System.Runtime.InteropServices 
Imports System.Windows.Forms 

Public Class Form1 

Public Sub New() 

' This call is required by the Windows Form Designer. 
InitializeComponent() 

' Add any initialization after the InitializeComponent() call. 
Me.NativeTabControl1 = New NativeTabControl 
Me.NativeTabControl2 = New NativeTabControl 
Me.NativeTabControl1.AssignHandle(Me.TabControl1.Handle) 
Me.NativeTabControl2.AssignHandle(Me.TabControl2.Handle) 
End Sub 

Private NativeTabControl1, NativeTabControl2 As NativeTabControl 

Private Class NativeTabControl 
Inherits NativeWindow 

Protected Overrides Sub WndProc(ByRef m As Message) 
If (m.Msg = TCM_ADJUSTRECT) Then 
Dim rc As RECT = DirectCast(m.GetLParam(GetType(RECT)), RECT) 
'Adjust these values to suit, dependant upon Appearance 
rc.Left -= 3 
rc.Right += 3 
rc.Top -= 3 
rc.Bottom += 3 
Marshal.StructureToPtr(rc, m.LParam, True) 
End If 
MyBase.WndProc(m) 
End Sub 

Private Const TCM_FIRST As Int32 = &H1300 
Private Const TCM_ADJUSTRECT As Int32 = (TCM_FIRST + 40) 
Private Structure RECT 
Public Left, Top, Right, Bottom As Int32 
End Structure 

End Class 

End Class 
+0

給出錯誤!我應該在哪裏添加Native tabControl類。我認爲它不能像你展示的那樣嵌套。 – Anna

+0

這是關於在所有的邊緣上勾住TabControl並使其邊框落在負軸索引中! – Anna

+0

是的。這是完成我所知道的任務的唯一方法,因爲本機控制不允許你這樣做。錯誤出現在設計器標記中,我並不是靠Visual Studio進行調試的機器,但解決方案的核心是Win32代碼。 –