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

📄 program2.frm

📁 是API教程5
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2235
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4980
   LinkTopic       =   "Form1"
   ScaleHeight     =   2235
   ScaleWidth      =   4980
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox Text5 
      Height          =   330
      Left            =   2940
      TabIndex        =   9
      Text            =   "Text5"
      Top             =   1680
      Width           =   1695
   End
   Begin VB.TextBox Text4 
      Height          =   315
      Left            =   2940
      TabIndex        =   6
      Text            =   "Text4"
      Top             =   780
      Width           =   1695
   End
   Begin VB.TextBox Text3 
      Height          =   315
      Left            =   2940
      TabIndex        =   5
      Text            =   "Text3"
      Top             =   420
      Width           =   1695
   End
   Begin VB.CommandButton Command1 
      Caption         =   "比较"
      Height          =   315
      Left            =   600
      TabIndex        =   4
      Top             =   1680
      Width           =   1575
   End
   Begin VB.TextBox Text2 
      Height          =   330
      Left            =   900
      TabIndex        =   1
      Text            =   "Text2"
      Top             =   780
      Width           =   1875
   End
   Begin VB.TextBox Text1 
      Height          =   315
      Left            =   900
      TabIndex        =   0
      Text            =   "Text1"
      Top             =   420
      Width           =   1875
   End
   Begin VB.Label Label5 
      Caption         =   "设备场景句柄"
      Height          =   255
      Left            =   960
      TabIndex        =   10
      Top             =   180
      Width           =   1575
   End
   Begin VB.Label Label4 
      Alignment       =   2  'Center
      Caption         =   "Form1的窗口句柄"
      Height          =   315
      Left            =   2940
      TabIndex        =   8
      Top             =   1440
      Width           =   1695
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      Caption         =   "关联窗体句柄"
      Height          =   255
      Left            =   2760
      TabIndex        =   7
      Top             =   240
      Width           =   1575
   End
   Begin VB.Label Label2 
      Caption         =   "hDC"
      Height          =   255
      Left            =   240
      TabIndex        =   3
      Top             =   840
      Width           =   1395
   End
   Begin VB.Label Label1 
      Caption         =   "GetDC"
      Height          =   315
      Left            =   240
      TabIndex        =   2
      Top             =   480
      Width           =   1275
   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 GetDC& Lib "user32" (ByVal hwnd As Long)
Private Declare Function WindowFromDC& Lib "user32" (ByVal hdc As Long)


Private Sub Command1_Click()
   Dim MyDC As Long

   Form1.AutoRedraw = True
   MyDC = GetDC(Form1.hwnd)
   Text1.Text = MyDC
   Text2.Text = Form1.hdc
      
   Text3.Text = WindowFromDC(MyDC)
   Text4.Text = WindowFromDC(Form1.hdc)
   
   Text5.Text = Form1.hwnd
   
   If Text3.Text = "0" Then
      Text3.Text = "无"
   End If
   If Text4.Text = "0" Then
      Text4.Text = "无"
   End If
End Sub


⌨️ 快捷键说明

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