我现在已经在运行时用鼠标划出n个区域,代码如下:
'在窗体上放置 shape 控件,一切属性取初始值
option explicit
dim a as boolean '判断鼠标是否按下状态
dim x1 as integer '矩形区域左上角 x 值
dim y1 as integer '矩形区域左上角 y 值
dim x2 as integer '矩形区域右下角 x 值
dim y2 as integer '矩形区域右下角 y 值

private sub form_load()
shape1.height = 0
shape1.width = 0
shape1.left = 0
shape1.top = 0
shape1.bordercolor = vbyellow '矩形边框颜色
end sub
private sub form_mousedown(button as integer, shift as integer, x as single, y as single)
a = true
x1 = x '保存矩形左上角坐标
y1 = y
shape1.left = x '设置矩形位置
shape1.top = y
end sub
private sub form_mousemove(button as integer, shift as integer, x as single, y as single)
on error goto e
if a then
shape1.height = y - shape1.top '画出矩形
shape1.width = x - shape1.left
end if
e:
end sub
private sub form_mouseup(button as integer, shift as integer, x as single, y as single)
a = false
x2 = x - x1 '保存矩形右下角位置
y2 = y - y1
'在此加入设置播放器的大小与位置的代码,这里用commandbutton控件作演示
'command1的visible=false,index=0
'程序修改如下
if y2 < 0 then y2 = 0
if x2 < 0 then x2 = 0
load command1(command1.count)
command1(command1.count - 1).left = x1
command1(command1.count - 1).top = y1
command1(command1.count - 1).height = y2
command1(command1.count - 1).width = x2
command1(command1.count - 1).visible = true
end sub
现在我想要实现以下几个效果:1:用一个combo1控件,当鼠标划出第一个区域时,下拉列表框中就会出现区域1;当划出第n个区域时,下拉列表框中就出有区域1,区域2……区域n。
2:我需要在form中设置一个picturebox控件,让鼠标划的区域者在picturebox控件中,这时我要设置text1和text2控件,用来显示所画的区域相对于picturebox控件的x坐标和y坐标。这时当选中所画的一个区域时,组合框中就会显示出这个区域是区域几,text中就会显示出它相对于相对于picturebox控件的x坐标和y坐标。
我做了有点实现不了,各位高手帮帮忙,最好是把代码加到我的原码中,不甚感激,谢了!!
arrow
arrow
    全站熱搜

    vbqa 發表在 痞客邦 留言(0) 人氣()