Naked » 10.01.2006 (Вт) 4:01
Можно и возможно.
Создаем новый проэкт (по умолчанию создается форма, назовем Form1 и в свойствах ставим MDIChild = Да), добавляем MDIForm обзываем MDIForm1, добавляем еще одну форму с названием tmpChild.
в модуле формы MDIForm1 пишем
Private Sub MDIForm_Load()
tmpChild.Show
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
End
End Sub
в модуле формы tmpChild пишем
Private Sub Form_Click()
Call HookChildForm(hWnd)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call UnHookChildForm(hWnd)
End Sub
пишем в модуле Module1
Option Explicit
Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function DefMDIChildProc Lib "user32" Alias "DefMDIChildProcA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const GWL_EXSTYLE = (-20)
Public Const GWL_STYLE = (-16)
Public Const WS_EX_MDICHILD = &H40
Public Const WS_CHILD = &H40000000
Public Const GWL_WNDPROC = (-4)
Public ChildWndProc As Long
Dim MDIClient As Long
Dim GWL As Long
Sub HookChildForm(hWnd As Long)
MDIClient = GetWindow(MDIForm1.hWnd, 5)
Call SetParent(hWnd, MDIClient)
GWL = GetWindowLong(hWnd, GWL_STYLE)
Call SetWindowLong(hWnd, GWL_STYLE, GWL Or WS_CHILD)
GWL = GetWindowLong(hWnd, GWL_EXSTYLE)
Call SetWindowLong(hWnd, GWL_EXSTYLE, GWL Or WS_EX_MDICHILD)
ChildWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf ChildWindowProc)
End Sub
Sub UnHookChildForm(hWnd As Long)
Call SetWindowLong(hWnd, GWL_WNDPROC, ChildWndProc)
End Sub
Function ChildWindowProc(ByVal hWnd As Long, ByVal message As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case message
Case Else
ChildWindowProc = DefMDIChildProc(hWnd, message, wParam, lParam)
End Select
End Function
Конец.