终于找到答案了,大家分享一下
原始C#
Code Block
private const int SB_BOTH = 3;
private const int WM_NCCALCSIZE = 0x83;
[DllImport("user32.dll")]
private static extern int ShowScrollBar(IntPtr hWnd, int wBar, int bShow);
protected override void WndProc(ref Message m)
{
if (mdiClient != null)
{
ShowScrollBar(mdiClient.Handle, SB_BOTH, 0 /*Hide the ScrollBars*/);
}
base.WndProc(ref m);
}
MdiClient mdiClient = null;
private void Form1_Load(object sender, EventArgs e)
{
foreach (Control c in this.Controls) //Find the MdiClient in the MdiWindow
{
if (c is MdiClient)
{
mdiClient = c as MdiClient;
}
}
Form2 form = new Form2();
form.MdiParent = this;
form.Show();
}
修改後的
程式碼區塊
Imports System.Runtime.InteropServices
Public Class Form1
Dim mdiClient As MdiClient = Nothing
Dim SB_BOTH As Integer = 3
<DllImport("user32.dll")> _
Private Shared Function ShowScrollBar(ByVal hWnd As IntPtr, ByVal wBar As Integer, ByVal bShow As Integer) As Integer
End Function
Protected Overrides Sub WndProc(ByRef m As Message)
If mdiClient IsNot Nothing Then
ShowScrollBar(mdiClient.Handle, SB_BOTH, 0)
End If
MyBase.WndProc(m)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each c As Control In Me.Controls
If TypeOf c Is MdiClient Then
mdiClient = c
End If
Next
Dim fm As Form = New Form2
fm.MdiParent = Me
fm.Show()
End Sub
End Class