form.frm

来自「vb 窗体实例 都是自己的例子」· FRM 代码 · 共 78 行

FRM
78
字号
VERSION 5.00
Begin VB.Form form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "设置窗口置前,置后"
   ClientHeight    =   1275
   ClientLeft      =   1710
   ClientTop       =   1605
   ClientWidth     =   5535
   Icon            =   "form.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   1275
   ScaleWidth      =   5535
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton Command1 
      Caption         =   "窗口在前模式"
      Height          =   360
      Left            =   75
      TabIndex        =   3
      Top             =   465
      Width           =   1335
   End
   Begin VB.CommandButton Command4 
      Caption         =   "退出"
      Height          =   360
      Left            =   4125
      TabIndex        =   2
      Top             =   465
      Width           =   1335
   End
   Begin VB.CommandButton Command2 
      Caption         =   "常规模式"
      Height          =   360
      Left            =   1425
      TabIndex        =   1
      Top             =   465
      Width           =   1335
   End
   Begin VB.CommandButton Command3 
      Caption         =   "窗口置后模式"
      Height          =   360
      Left            =   2775
      TabIndex        =   0
      Top             =   465
      Width           =   1335
   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 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)

Private Sub Command1_Click()
' 窗口置前
  Dim myval
  myval = SetWindowPos(form1.hwnd, -1, 0, 0, 0, 0, 3)
End Sub
Private Sub Command2_Click()
'窗口正常
  Dim myval
  myval = SetWindowPos(form1.hwnd, -2, 0, 0, 0, 0, 3)
End Sub
Private Sub Command3_Click()
'窗口置后
  Dim myval
  myval = SetWindowPos(form1.hwnd, 1, 0, 0, 0, 0, 3)
End Sub
Private Sub Command4_Click()
  End
End Sub

⌨️ 快捷键说明

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