vb 中borderstyle设置为0 怎么让窗体最前端啊?且能随意移动窗体啊?

 我来答
律怜烟EB
2010-08-11 · TA获得超过702个赞
知道小有建树答主
回答量:190
采纳率:100%
帮助的人:39.1万
展开全部
'虽然我自己的问题还没有人回答,解决不了问题,下面的事就没有办法开展...
'在模块中声明以下函数
Public 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
Public Const a& = -1
Public Const b& = &H1
Public Const c& = &H2
Public Const HTCAPTION = 2
Public Const WM_NCLBUTTONDOWN = &HA1
Public Declare Function ReleaseCapture Lib "user32" () As Long '!!!!!!!!
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then '移动
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Form_Load()
SetWindowPos Me.hwnd, a, 0, 0, 0, 0, b Or c '置顶
End Sub
百度网友30cc6ab
2010-08-11 · TA获得超过574个赞
知道小有建树答主
回答量:1336
采纳率:0%
帮助的人:856万
展开全部
要移动窗体就要在窗体的鼠标事件里调用函数来控制窗体。
至于最前端?都要用API函数才能搞定。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
伯虎点蚊香6120
2010-08-11 · TA获得超过543个赞
知道小有建树答主
回答量:417
采纳率:0%
帮助的人:84.1万
展开全部
'看来阁下是想做一个恶搞的程序吧,做个窗体让它永远最前端,而且能移动。我给它再增加一个功能吧,让它透明。

'1.这段时随意移动
Private Sub Timer1_Timer()
Dim X As Integer
Dim Y As Integer
X = Int(Rnd * 10000) + 1
Y = Int(Rnd * 10000) + 1

Form1.Left = X
Form1.Top = Y
End Sub

'2.这段是窗体最前端
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 '(API函数)

Private Sub Form_Resize()
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友d4f370c7e
2010-08-11 · TA获得超过2676个赞
知道小有建树答主
回答量:3606
采纳率:100%
帮助的人:1694万
展开全部
'在bas加入:
Declare Function ReleaseCapture Lib "user32" () As Long
Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Public Const HTCAPTION = 2
Public Const WM_NCLBUTTONDOWN = &HA1
'''''

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式