玩酷之家

 找回密码
 立即注册
查看: 187|回复: 0

VB 让窗体始终处于最上层

[复制链接]
发表于 2021-1-8 16:55:36 | 显示全部楼层 |阅读模式
  1. '-----让窗体始终处于最上层
  2. Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Integer, ByVal Y As Integer, ByVal cX As Integer, ByVal cY As Integer, ByVal uFlags As Long) As Boolean

  3. Const SWP_NOMOVE = &H2 '不更动目前视窗位置
  4. Const SWP_NOSIZE = &H1 '不更动目前视窗大小
  5. Const HWND_TOPMOST = -1 '设定为最上层
  6. Const HWND_NOTOPMOST = -2 '取消最上层设定
  7. Const Flags = SWP_NOMOVE Or SWP_NOSIZE
  8. '-----让窗体始终处于最上层


  9. Private Sub Command1_Click()
  10.     SetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left, Me.Top, Me.Width, Me.Height, Flags '设定为最上层
  11. End Sub

  12. Private Sub Command2_Click()
  13.     SetWindowPos Me.hwnd, HWND_NOTOPMOST, Me.Left, Me.Top, Me.Width, Me.Height, Flags '取消最上层设定
  14. End Sub
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|玩酷之家 ( 鄂ICP备14012049号 )

GMT+8, 2021-4-22 11:35 , Processed in 1.092002 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表