'新建两个窗体、一个按钮、一个图片框。
'// Window attribute functions
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
'// Z-order and placement APIs
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'// Focus and activation functions
Private Declare Function winSetFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Private Declare Function winGetFocus Lib "user32" Alias "GetFocus" () As Long
Private Sub Command1_Click()
Dim hWndPage As Long
Dim hForm As VB.Form
Dim hWndBin As Long
Dim dwStyle As Long
Set hForm = New Form2
Load hForm
hWndPage = hForm.hwnd
hWndBin = Picture1.hwnd
dwStyle = GetWindowLong(hWndPage, GWL_STYLE)
dwStyle = dwStyle Or WS_CHILD
Call SetWindowLong(hWndPage, GWL_STYLE, dwStyle)
Call SetParent(hWndPage, hWndBin)
Call SetWindowPos(hWndPage, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE)
hForm.Visible = True
End Sub