|
>魔界の仮面弁士 さん
> 通常の SDI における「子.Show(親)」で表示させる方法ではなく、
> あくまでも親のクライアント領域内に子を表示させる画面構成でしょうか。
これはどういう画面構成のことをさしていますか?
自分としては、
通常の MDI における「子.Show(親)」で表示させる方法を使うつもりですので
異なる方法でしょうか?
>とっちゃん さん
検索して調べたところ、恐らくこの方法を使えばいけると思います。
https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1475227379
翻訳サイトを使ってVBに変換したのですが
InitializeComponent()
Dim hwnd As IntPtr = Form1.GetWindow(Me.Handle, GW_CHILD)
Me.wpd = New WndProcDelegate(NewWndProc)
の三カ所でエラーが出てしまいます。
一体どのように修正すればよろしいでしょうか?
Private Declare Function GetWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal uCmd As Integer) As IntPtr
Private Declare Function GetClassName Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal lpClassName As StringBuilder, ByVal nMaxCount As Integer) As Integer
Private Declare Function SetWindowLong Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal NewWndProc As WndProcDelegate) As IntPtr
Private Declare Function SetWindowLongPtr Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal NewWndProc As WndProcDelegate) As IntPtr
Private Declare Function CallWindowProc Lib "user32.dll" (ByVal lpPrevWndFunc As IntPtr, ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Const GW_HWNDNEXT As Integer = 2
Private Const GW_CHILD As Integer = 5
Private Const WM_NCCALCSIZE As Integer = 131
Private Const GWL_WNDPROC As Integer = -4
Private PrevWndProc As IntPtr
Public Delegate Function WndProcDelegate(ByVal hWnd As IntPtr, ByVal uMsg As UInteger, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private wpd As WndProcDelegate
Public Sub New()
MyBase.New
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim sb As StringBuilder = New StringBuilder(100)
Dim hwnd As IntPtr = Form1.GetWindow(Me.Handle, GW_CHILD)
While (hwnd <> IntPtr.Zero)
Form1.GetClassName(hwnd, sb, sb.Capacity)
If (sb.ToString.IndexOf("MDICLIENT") <> -1) Then
Me.wpd = New WndProcDelegate(NewWndProc)
If (IntPtr.Size = 4) Then
Me.PrevWndProc = Form1.SetWindowLong(hwnd, GWL_WNDPROC, Me.wpd)
Else
Me.PrevWndProc = Form1.SetWindowLongPtr(hwnd, GWL_WNDPROC, Me.wpd)
End If
Return
End If
hwnd = Form1.GetWindow(hwnd, GW_HWNDNEXT)
End While
End Sub
Private Function NewWndProc(ByVal hWnd As IntPtr, ByVal uMsg As UInteger, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
If (uMsg = WM_NCCALCSIZE) Then
Return 0
End If
Return Form1.CallWindowProc(Me.PrevWndProc, hWnd, uMsg, wParam, lParam)
End Function
End Class
|