vb6什么代码可以用鼠标移动无标题栏的窗体
vb6中用什么代码可以做出移动没有标题栏的窗体移动来?谢谢.按dos62你的回复,成功了,但是在任务栏上也没有窗口显示了,怎么避免这个问题?谢谢s_b_w,如果将窗体的B...
vb6中用什么代码可以做出 移动 没有标题栏的窗体移动来?谢谢
.
按 dos62 你的回复,成功了,但是在任务栏上也没有窗口显示了,怎么避免这个问题?谢谢
s_b_w,如果 将窗体的BorderStyle属性应该为2 ,那么标题栏怎么去掉呢?我不想要标题栏和边框
. 展开
.
按 dos62 你的回复,成功了,但是在任务栏上也没有窗口显示了,怎么避免这个问题?谢谢
s_b_w,如果 将窗体的BorderStyle属性应该为2 ,那么标题栏怎么去掉呢?我不想要标题栏和边框
. 展开
3个回答
展开全部
在设计阶段,将窗体的BorderStyle设置为0,ShowInTaskbar设置为True就可以了。移动窗体的代码如下:
Dim MoveScreen As Boolean
Dim MousX As Integer
Dim MousY As Integer
Dim CurrX As Integer
Dim CurrY As Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
MoveScreen = True
MousX = X
MousY = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MoveScreen Then
CurrX = Form1.Left - MousX + X
CurrY = Form1.Top - MousY + Y
Form1.Move CurrX, CurrY
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveScreen = False
End Sub
Dim MoveScreen As Boolean
Dim MousX As Integer
Dim MousY As Integer
Dim CurrX As Integer
Dim CurrY As Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
MoveScreen = True
MousX = X
MousY = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MoveScreen Then
CurrX = Form1.Left - MousX + X
CurrY = Form1.Top - MousY + Y
Form1.Move CurrX, CurrY
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveScreen = False
End Sub
展开全部
'---------------------------------------------
' 移动无标题栏窗体的例子
'---------------------------------------------
' 洪恩在线 求知无限
'---------------------------------------------
'程序说明:
'本例演示了怎样移动无标题栏的窗体的方法,程序中涉
'及到MouseDown、MouseMove、MouseUp三个鼠标事件的
'使用,我们可以从中学习到它们的用法。
'---------------------------------------------
Option Explicit
'变量声明
'MoveScreen,布尔型变量,标示窗体是否处于被移动状态
Dim MoveScreen As Boolean
'鼠标位置
Dim MousX As Integer
Dim MousY As Integer
'窗体位置
Dim CurrX As Integer
Dim CurrY As Integer
'“退出”按钮
Private Sub CmdExit_Click()
End
End Sub
'当鼠标在窗体上按下时
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'---------------------------------------------
'参数说明:
'---------------------------------------------
'button 返回一个整数,用来标识按下或释放的是哪一
'个按钮。button 参数的值为相应于左按钮(1)右按钮
'(2),以及中间按钮(4)。
'---------------------------------------------
'shift 返回一个整数,在鼠标按钮被按下或者被释放
'的同时,SHIFT,CTRL,和 ALT 键的状态,返回的shift
'参数值分别为1,2,和 4。指示这些键的状态。
'---------------------------------------------
'x, y 返回一个指定鼠标指针当前位置的数。
'---------------------------------------------
'如果是鼠标左键按下
If Button = 1 Then
'标示为移动状态
MoveScreen = True
'得到鼠标在窗体上的位置(相对与窗体内部坐标)
MousX = X
MousY = Y
End If
End Sub
'当鼠标在窗体上移过时
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'如果处于鼠标左键按下的状态,即MoveScreen = True时
If MoveScreen Then
'计算新的窗体坐标值
'仔细想一下,看看是不是这样
CurrX = Form1.Left - MousX + X
CurrY = Form1.Top - MousY + Y
'移动窗体到新的位置
Form1.Move CurrX, CurrY
End If
'把新的窗体坐标显示出来,是相对于屏幕的坐标
Label3.Caption = CurrX
Label4.Caption = CurrY
'把鼠标点击的位置显示出来,是相对与窗体的坐标
Label7.Caption = MousX
Label8.Caption = MousY
End Sub
'如果鼠标松开,则停止拖动
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveScreen = False
End Sub
' 移动无标题栏窗体的例子
'---------------------------------------------
' 洪恩在线 求知无限
'---------------------------------------------
'程序说明:
'本例演示了怎样移动无标题栏的窗体的方法,程序中涉
'及到MouseDown、MouseMove、MouseUp三个鼠标事件的
'使用,我们可以从中学习到它们的用法。
'---------------------------------------------
Option Explicit
'变量声明
'MoveScreen,布尔型变量,标示窗体是否处于被移动状态
Dim MoveScreen As Boolean
'鼠标位置
Dim MousX As Integer
Dim MousY As Integer
'窗体位置
Dim CurrX As Integer
Dim CurrY As Integer
'“退出”按钮
Private Sub CmdExit_Click()
End
End Sub
'当鼠标在窗体上按下时
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'---------------------------------------------
'参数说明:
'---------------------------------------------
'button 返回一个整数,用来标识按下或释放的是哪一
'个按钮。button 参数的值为相应于左按钮(1)右按钮
'(2),以及中间按钮(4)。
'---------------------------------------------
'shift 返回一个整数,在鼠标按钮被按下或者被释放
'的同时,SHIFT,CTRL,和 ALT 键的状态,返回的shift
'参数值分别为1,2,和 4。指示这些键的状态。
'---------------------------------------------
'x, y 返回一个指定鼠标指针当前位置的数。
'---------------------------------------------
'如果是鼠标左键按下
If Button = 1 Then
'标示为移动状态
MoveScreen = True
'得到鼠标在窗体上的位置(相对与窗体内部坐标)
MousX = X
MousY = Y
End If
End Sub
'当鼠标在窗体上移过时
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'如果处于鼠标左键按下的状态,即MoveScreen = True时
If MoveScreen Then
'计算新的窗体坐标值
'仔细想一下,看看是不是这样
CurrX = Form1.Left - MousX + X
CurrY = Form1.Top - MousY + Y
'移动窗体到新的位置
Form1.Move CurrX, CurrY
End If
'把新的窗体坐标显示出来,是相对于屏幕的坐标
Label3.Caption = CurrX
Label4.Caption = CurrY
'把鼠标点击的位置显示出来,是相对与窗体的坐标
Label7.Caption = MousX
Label8.Caption = MousY
End Sub
'如果鼠标松开,则停止拖动
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveScreen = False
End Sub
参考资料: http://www.hongen.com/pc/program/codtutor/code0012/code01.htm
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我把楼上的代码修改了一下,删除了无用的代码,修改后如下:
为了避免任务栏中的应用程序消失,应该将窗体的BorderStyle属性应该为2!
Dim MoveScreen As Boolean
Dim MousX As Integer
Dim MousY As Integer
Dim CurrX As Integer
Dim CurrY As Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
MoveScreen = True
MousX = X
MousY = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MoveScreen Then
CurrX = Form1.Left - MousX + X
CurrY = Form1.Top - MousY + Y
Form1.Move CurrX, CurrY
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveScreen = False
End Sub
为了避免任务栏中的应用程序消失,应该将窗体的BorderStyle属性应该为2!
Dim MoveScreen As Boolean
Dim MousX As Integer
Dim MousY As Integer
Dim CurrX As Integer
Dim CurrY As Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
MoveScreen = True
MousX = X
MousY = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MoveScreen Then
CurrX = Form1.Left - MousX + X
CurrY = Form1.Top - MousY + Y
Form1.Move CurrX, CurrY
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveScreen = False
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询