VB6,如何在Picture控件里绘制网格

首先是调出张图来,然后建立正方型的网格.单纯的建立固定网格我知道如何能建立条能动的网格,就是通过ScoreBar拖动可以改变网格的大小.网格能否可以互动,能够选择网格,并... 首先是调出张图来,然后建立正方型的网格.单纯的建立固定网格我知道
如何能建立条能动的网格,就是通过ScoreBar拖动可以改变网格的大小.
网格能否可以互动,能够选择网格,并输入数据.
回答越全分越高啊.
展开
 我来答
jxh2003zfr
2010-05-15 · TA获得超过214个赞
知道小有建树答主
回答量:356
采纳率:0%
帮助的人:185万
展开全部
'以下代码仅用于参考,只是用来说明原理而已
'Form1中有P1、HS、txt1三个控件
Private XC As Single, YC As Single
Private Sub Form_Load()
HS.Value = 300
P1.FontSize = Txt1.FontSize
P1.Font = Txt1.Font
P1.ForeColor = Txt1.ForeColor
End Sub

Private Sub Form_Resize()
P1.Width = Me.ScaleWidth - P1.Left * 2
P1.Height = Me.ScaleHeight - HS.Height - HS.Top
End Sub

Private Sub HS_Change()
P1.Refresh
End Sub

Private Sub P1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
XC = X - X Mod HS.Value
YC = Y - Y Mod HS.Value

Txt1.Left = XC + P1.Left
Txt1.Top = YC + P1.Top
Txt1.Width = HS.Value
Txt1.Height = HS.Height
Txt1.Visible = True
End Sub

Private Sub P1_Paint()
Dim dblW As Single, dblH As Single
Dim X0 As Single, Y0 As Single, X1 As Single, Y1 As Single
Dim X2 As Single, Y2 As Single, X3 As Single, Y3 As Single

dblW = P1.ScaleWidth
dblH = P1.ScaleHeight
If HS.Value = 0 Then Exit Sub

X0 = HS.Value: Y0 = 0
X1 = X0: Y1 = dblH

X2 = 0: Y2 = HS.Value
X3 = dblW: Y3 = Y2
Do While (X0 <= dblW)
P1.Line (X0, Y0)-(X1, Y1), &HFFC0FF
X0 = X0 + HS.Value: X1 = X0
Loop

Do While (Y2 <= dblH)
P1.Line (X2, Y2)-(X3, Y3), &HFFC0FF
Y2 = Y2 + HS.Value: Y3 = Y2
Loop

End Sub

Private Sub Txt1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode <> 13 Then Exit Sub
Txt1.Visible = False
P1.CurrentX = XC
P1.CurrentY = YC
P1.Print Txt1.Text
End Sub
页褐诔捞陡稼9f
2010-05-14 · TA获得超过625个赞
知道大有可为答主
回答量:980
采纳率:0%
帮助的人:1182万
展开全部
能通过ScoreBar拖动可以改变网格的大小,你要在ScoreBar的Change事件里重画网格。至于互动啊,你只能通过MouseDown事件来判断坐标然后在窗体输出。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式