小例子,大概就是这个思路。Dim tmpStr As String Dim pX, pY As Double Private Sub Command1_Click() Me.MousePointer = 3 End SubPrivate Sub Form_Load() Text1.Visible = False pX = 0: pY = 0 End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 And Me.MousePointer = 3 Then Me.MousePointer = 0 Text1.Text = "" Text1.Left = X: pX = X Text1.Top = Y: pY = Y Text1.Visible = True Text1.SetFocus
ElseIf Button = 2 Then Text1.Text = "" Text1.Visible = False pX = 0: pY = 0 End If End SubPrivate Sub Text1_Change() tmpStr = Text1.Text End SubPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = 13 Then Text1.Visible = False Picture1.ScaleMode = 1 Picture1.ForeColor = RGB(&HFF, 0, 0) Picture1.CurrentX = pX Picture1.CurrentY = pY Picture1.Print tmpStr Picture1.Refresh End If End Sub
visible为false;
2、picturebox_click()事件中:
'判断按钮是否按下(没有按下则跳出)
获得鼠标的坐标;
在该坐标显示textbox;(文字大小、颜色可设置textbox的属性)
Dim pX, pY As Double
Private Sub Command1_Click()
Me.MousePointer = 3
End SubPrivate Sub Form_Load()
Text1.Visible = False
pX = 0: pY = 0
End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 And Me.MousePointer = 3 Then
Me.MousePointer = 0
Text1.Text = ""
Text1.Left = X: pX = X
Text1.Top = Y: pY = Y
Text1.Visible = True
Text1.SetFocus
ElseIf Button = 2 Then
Text1.Text = ""
Text1.Visible = False
pX = 0: pY = 0
End If
End SubPrivate Sub Text1_Change()
tmpStr = Text1.Text
End SubPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = 13 Then
Text1.Visible = False
Picture1.ScaleMode = 1
Picture1.ForeColor = RGB(&HFF, 0, 0)
Picture1.CurrentX = pX
Picture1.CurrentY = pY
Picture1.Print tmpStr
Picture1.Refresh
End If
End Sub
怎么字出不来呢