⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pro2.frm

📁 是API教程3
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3690
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3690
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   315
      Left            =   420
      TabIndex        =   2
      Top             =   300
      Width           =   1275
   End
   Begin VB.TextBox Text1 
      Height          =   1875
      Left            =   60
      MultiLine       =   -1  'True
      TabIndex        =   1
      Top             =   1680
      Width           =   4575
   End
   Begin VB.PictureBox Picture1 
      BackColor       =   &H00FF8080&
      ForeColor       =   &H00000000&
      Height          =   1395
      Left            =   2820
      ScaleHeight     =   1335
      ScaleWidth      =   1755
      TabIndex        =   0
      Top             =   60
      Width           =   1815
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Option Explicit




Private Declare Function GetParent& Lib "user32" (ByVal hWnd As Long)
Private Declare Function GetTopWindow& Lib "user32" (ByVal hWnd As Long)
Private Declare Function SetParent& Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long)
Private Declare Function GetClassName& Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long)


Private Sub Command1_Click()
    Dim dl&
    dl& = SetParent(Command1.hWnd, Picture1.hWnd)
    Command1.Move (Picture1.Width - Command1.Width) \ 2, (Picture1.Height - Command1.Height) \ 2
    info Command1, Command1.hWnd
End Sub

Private Sub Form_Click()
    info Form1, Form1.hWnd
End Sub

Private Sub Picture1_Click()
    info Picture1, Picture1.hWnd
End Sub
Sub info(obj As Object, hWnd As Long)
    Dim TxtName As String * 256
    Dim TextLength As Long
    Dim dl As Long
    Dim Handle As Long
    Text1.Text = "名称∶" & obj.Name & Chr(13) & Chr(10)
    TextLength = GetClassName(hWnd, TxtName, 255)          '获得类名
    Text1.Text = Text1.Text & "类名∶" & Left(TxtName, TextLength) & Chr(13) & Chr(10)
    
    Handle& = GetParent(hWnd)        ' 检查是否存在父窗口
      If Handle Then
         TextLength = GetClassName(Handle, TxtName, 255)
         Text1.Text = Text1.Text & "父窗口∶" & Left(TxtName, TextLength) & Chr(13) & Chr(10)
      Else
         Text1.Text = Text1.Text & "父窗口∶" & "没有" & Chr(13) & Chr(10)
      End If
    
    Handle& = GetTopWindow(hWnd)      '检查是否存在子窗口
      If Handle Then
         TextLength = GetClassName(Handle, TxtName, 255)
         Text1.Text = Text1.Text & "第一个子窗口∶" & Left(TxtName, TextLength) & Chr(13) & Chr(10)
      Else
         Text1.Text = Text1.Text & "第一个子窗口∶" & "没有" & Chr(13) & Chr(10)
      End If
End Sub

Private Sub Text1_Click()
     info Text1, Text1.hWnd
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -