GSerg писал(а):if typeof obj is frame then...
if typeof obj is frame or typeof obj is picturebox then...
API-Guide писал(а):The SetParent function changes the parent window of the specified child window.
...
· hWndChild
Identifies the child window.
· hWndNewParent
Identifies the new parent window. If this parameter is NULL, the desktop window becomes the new parent window.
...
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
'Create a new project and add this code to Form1
Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H100
Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
Const LANG_NEUTRAL = &H0
Const SUBLANG_DEFAULT = &H1
Const ERROR_BAD_USERNAME = 2202&
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Declare Sub SetLastError Lib "kernel32" (ByVal dwErrCode As Long)
Private Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Form_Click()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
SetParent Command2.hWnd, Command1.hWnd
DoEvents
Dim Buffer As String
'Create a string buffer
Buffer = Space(200)
'Set the error number
'SetLastError ERROR_BAD_USERNAME
'Format the message string
FormatMessage FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, GetLastError, LANG_NEUTRAL, Buffer, 200, ByVal 0&
'Show the message
MsgBox Buffer
End Sub
Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Function CheckContainterness(hwnd As Long) As Boolean
SetParent Command1.hwnd, hwnd
DoEvents
If GetParent(Command1.hwnd) = hwnd Then CheckContainterness = True
End Function
Private Sub Form_Load()
MsgBox CheckContainterness(Picture1.hwnd)
End Sub
Сейчас этот форум просматривают: Google-бот, Yandex-бот и гости: 148