VB6,如何在Picture控件里绘制网格
首先是调出张图来,然后建立正方型的网格.单纯的建立固定网格我知道如何能建立条能动的网格,就是通过ScoreBar拖动可以改变网格的大小.网格能否可以互动,能够选择网格,并...
首先是调出张图来,然后建立正方型的网格.单纯的建立固定网格我知道
如何能建立条能动的网格,就是通过ScoreBar拖动可以改变网格的大小.
网格能否可以互动,能够选择网格,并输入数据.
回答越全分越高啊. 展开
如何能建立条能动的网格,就是通过ScoreBar拖动可以改变网格的大小.
网格能否可以互动,能够选择网格,并输入数据.
回答越全分越高啊. 展开
展开全部
'以下代码仅用于参考,只是用来说明原理而已
'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
'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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询