這是我可以修改該填充的唯一方法。
Imports System.Runtime.InteropServices
Public Class NativeTabControl
Inherits NativeWindow
Private Const TCM_FIRST As Int32 = &H1300
Private Const TCM_ADJUSTRECT As UInt32 = (TCM_FIRST + 40)
Private baseCtrl As TabControl
Public Sub New(ByVal ctrl As TabControl)
Me.baseCtrl = ctrl
AddHandler ctrl.HandleDestroyed, AddressOf OnHandleDestroyed
Me.AssignHandle(ctrl.Handle)
End Sub
Private Sub OnHandleDestroyed(ByVal sender As Object, ByVal e As EventArgs)
' Window was destroyed, release hook.
RemoveHandler baseCtrl.HandleDestroyed, AddressOf OnHandleDestroyed
Me.ReleaseHandle()
End Sub
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 += 1
rc.Top -= 1
rc.Bottom += 1
Marshal.StructureToPtr(rc, m.LParam, True)
End If
MyBase.WndProc(m)
End Sub
Private Structure RECT
Public Left, Top, Right, Bottom As Int32
End Structure
End Class
的可能重複[我怎樣才能刪除的WinForms上的容器控件邊框填充?](http://stackoverflow.com/questions/4968267/how-can-i-remove-the-border-padding -on-container-controls-in-winforms) –
你在上述問題中的回答在這裏不適用,爲了大家的利益,我找到了一個有效的答案!張貼在這裏! – CodeWrite