用SetWindowPos,參數(shù)TOP_MOST
成都創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站制作、網(wǎng)站建設(shè)、夏津網(wǎng)絡(luò)推廣、小程序開發(fā)、夏津網(wǎng)絡(luò)營銷、夏津企業(yè)策劃、夏津品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供夏津建站搭建服務(wù),24小時服務(wù)熱線:18980820575,官方網(wǎng)址:jinyejixie.com
就是直接設(shè)置窗口的TOPMOST屬性也行啊,把默認(rèn)的false改成true,自己在窗口的屬性列表里找找吧
你說的是保持在最前面吧!你再說明白點!
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 Form_Load()
Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
'其它代碼
End Sub
將下面的代碼復(fù)制到記事本中,并將其保持為Form1.frm
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 0 'None
ClientHeight = 4695
ClientLeft = 0
ClientTop = 0
ClientWidth = 6975
LinkTopic = "Form1"
ScaleHeight = 4695
ScaleWidth = 6975
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.Shape Shape3
BackColor = H000080FF
BackStyle = 1 'Opaque
BorderStyle = 0 'Transparent
Height = 855
Left = 3480
Shape = 3 'Circle
Top = 960
Width = 975
End
Begin VB.Shape Shape2
BackColor = H000080FF
BackStyle = 1 'Opaque
BorderStyle = 0 'Transparent
Height = 855
Left = 1560
Shape = 3 'Circle
Top = 960
Width = 975
End
Begin VB.Shape Shape1
BackColor = H000080FF
BackStyle = 1 'Opaque
BorderStyle = 0 'Transparent
Height = 1095
Left = 1920
Shape = 2 'Oval
Top = 1320
Width = 2055
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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 Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Dim mouse_x As Single
Dim mouse_y As Single
Private Sub Form_Load()
Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
Me.BackColor = HFF0000
Dim rtn As Long
BorderStyler = 0
rtn = GetWindowLong(hwnd, -20)
rtn = rtn Or H80000
SetWindowLong hwnd, -20, rtn
SetLayeredWindowAttributes hwnd, HFF0000, 0, H1
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mouse_x = 0
mouse_y = 0
If Button = 1 Then
mouse_x = X
mouse_y = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Form1.Left = Form1.Left + (X - mouse_x)
Form1.Top = Form1.Top + (Y - mouse_y)
End If
End Sub
這是一個關(guān)于模態(tài)窗口與非模態(tài)窗口的問題。
實現(xiàn)非模態(tài)窗口也沒什么難度
Dim form As New Form1
form.TopMost = True
form.Show()
你再將鼠標(biāo)移到父窗口上,彈出的窗口也不會消失。
shell加個參數(shù):
Shell("D:\Program Files\Microsoft Office\Office14\WINWORD.EXE", AppWinStyle.NormalFocus)
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
HWND_TOPMOST
=
-1
'
將窗口置于列表頂部,并位于任何最頂部窗口的前面
Private
Const
SWP_NOSIZE
=
H1
'
保持窗口大小
Private
Const
SWP_NOMOVE
=
H2
'
保持窗口位置
Private
Sub
Form_Load()
SetWindowPos
Me.hwnd,
HWND_TOPMOST,
0,
0,
0,
0,
SWP_NOMOVE
Or
SWP_NOSIZE
'
將窗口設(shè)為總在最前
End
Sub
網(wǎng)站題目:vb.net將程序置頂 vb窗口置頂
網(wǎng)頁URL:http://jinyejixie.com/article40/dodopho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、品牌網(wǎng)站建設(shè)、移動網(wǎng)站建設(shè)、網(wǎng)站收錄、全網(wǎng)營銷推廣、網(wǎng)站維護
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)