Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print from keyboard to picturebox 1

Status
Not open for further replies.

magicme

Technical User
Jun 11, 2003
22
US
hello
i wrote a utility to add text to an imported image in a picturebox control.
the user imports the picture, enters text in a text box, then clicks on the picturebox and it writes the contents of the text box at that point on the picture.
this was very simple.

i would like to eliminate the textbox and simply click at a point on the picture, type on the keyboard and have that text appear on the picture at the mouse point.

i cannot find a discussion on doing this.

any advice would be appreciated.


daveleo
 
Without seeing the code you use to add the text, I would imagine that you would be able to call it on the KeyDown/Keypress event of the picturebox and add it that way, doing a letter at a time rather than a string of text (from the textbox)?

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Place a picture box to your form, load your desired picture. Add a textbox to the form, try the following code.
___
[tt]
Option Explicit
Private Sub Form_Load()
Text1.Visible = False
Text1.BorderStyle = 0
Text1.Height = TextHeight(vbNullString)
Set Text1.Container = Picture1
Picture1.AutoRedraw = True
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = ""
Text1.Move X, Y
Text1.Visible = True
Text1.SetFocus
End Sub

Private Sub Text1_Change()
Text1.Width = TextWidth(Text1.Text) + 300
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case vbKeyReturn, vbKeyEscape
If KeyAscii = vbKeyReturn Then
Picture1.CurrentX = Text1.Left
Picture1.CurrentY = Text1.Top
Picture1.Print Text1.Text
End If
KeyAscii = 0
Text1.Visible = False
End Select
End Sub[/tt]
 
thanks Hypetia
i see what you're doing here and will start there and work it through.

daveleo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top