1个回答
展开全部
首先要知道你所要置顶的窗口的名字,比如"我的电脑"..
你的是"大话西游"..
程序这么写..
-------->
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
Declare
Function
FindWindow
Lib
"user32"
Alias
"FindWindowA"
(ByVal
lpClassName
As
String,
ByVal
lpWindowName
As
String)
As
Long
Private
Sub
Form_Load()
Dim
winH
As
Long
winH
=
FindWindow(vbNullString,
"大话西游")
'窗口名也可以换为别的,根据程序的窗口名来定
SetWindowPos
winH,
-1,
0,
0,
0,
0,
3
End
Sub
<--------
这样的话打开程序,如果大话西游正在运行的话,就会立即置顶.
如果要取消置顶的话,添加个command控件,里面写上
-------->
Dim
winH
As
Long
winH
=
FindWindow(vbNullString,
"大话西游")
SetWindowPos
winH,
-2,
0,
0,
0,
0,
3
<--------
即可.
谢谢.
你的是"大话西游"..
程序这么写..
-------->
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
Declare
Function
FindWindow
Lib
"user32"
Alias
"FindWindowA"
(ByVal
lpClassName
As
String,
ByVal
lpWindowName
As
String)
As
Long
Private
Sub
Form_Load()
Dim
winH
As
Long
winH
=
FindWindow(vbNullString,
"大话西游")
'窗口名也可以换为别的,根据程序的窗口名来定
SetWindowPos
winH,
-1,
0,
0,
0,
0,
3
End
Sub
<--------
这样的话打开程序,如果大话西游正在运行的话,就会立即置顶.
如果要取消置顶的话,添加个command控件,里面写上
-------->
Dim
winH
As
Long
winH
=
FindWindow(vbNullString,
"大话西游")
SetWindowPos
winH,
-2,
0,
0,
0,
0,
3
<--------
即可.
谢谢.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询