VB中将窗口置顶的代码是什么?
用SetWindowPos函数,通用部分声明: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) As Long
Private Const a& = -1
Private Const b& = &H1
Private Const c& = &H2窗体部分:
Private Sub Form_Load() 。
Visual Basic是一种由微软公司开发的包含协助开发环境的事件驱动编程语言。从任何标准来说,VB都是世界上使用人数最多的语言——不仅是盛赞VB的开发者还是抱怨VB的开发者的数量。它源自于BASIC编程语言。VB拥有图形用户界面(GUI)和快速应用程序开发(RAD)系统,可以轻易的使用DAO、RDO、ADO连接数据库,或者轻松的创建ActiveX控件。程序员可以轻松的使用VB提供的组件快速建立一个应用程序。
新建立类模块:
Option Explicit
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)
窗口代码:
Dim rtn
'让窗口在顶层
rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
'取消窗口在顶层
'rtn = SetWindowPos(F_V.hwnd, -2, 0, 0, 0, 0, 3)