nicthu
asked on
Is there a way to Edit or Open a Picture control at Runtime?
In VB6: When I select Project / Components, go to the Insertable Objects tab, and tick "Bitmap Image" (MSPAINT.exe), then click on the "Picture" icon on the Palette & draw one on my Form...
At Design Time, I can right-click that Picture control and select Edit, and voila! I can draw free-form right in the picture! Or I can right-click and Open to bring up MSPAINT and edit it with all the Paint features, and when I close, the changes are copied back to the form. That's great, but...
Question:
How do I do that at RUNTIME?
I want to include a little drawable area in my form, at least with freeform drawing and ability to enter and position your own text. I can handle saving and loading that bitmap to/from a file at the appropriate times.
But how do I talk to that MSPAINT.EXE invocation that seems to be loaded??
Or is there another Control or OCX that would let me do that?
Thanks in advance if you can help!
At Design Time, I can right-click that Picture control and select Edit, and voila! I can draw free-form right in the picture! Or I can right-click and Open to bring up MSPAINT and edit it with all the Paint features, and when I close, the changes are copied back to the form. That's great, but...
Question:
How do I do that at RUNTIME?
I want to include a little drawable area in my form, at least with freeform drawing and ability to enter and position your own text. I can handle saving and loading that bitmap to/from a file at the appropriate times.
But how do I talk to that MSPAINT.EXE invocation that seems to be loaded??
Or is there another Control or OCX that would let me do that?
Thanks in advance if you can help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Which OLE control do I insert?
Or where do I find such an OLE control?
Or where do I find such an OLE control?
ASKER
Nevermind, I found it on the Palette!
Awesome -- you get the points, dude!
p.s. Is there another DoVerb for "Save current object to a file"?
Awesome -- you get the points, dude!
p.s. Is there another DoVerb for "Save current object to a file"?
ASKER
Nevermind again, I found the ReadFromFile and SaveToFile methods!
Option Explicit
Dim lastX As Single
Dim lastY As Single
Dim mouseIsDown As Boolean
Private Sub Form_Load()
Picture1.AutoRedraw = True
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
lastX = X
lastY = Y
mouseIsDown = True
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If mouseIsDown Then
Picture1.Line (lastX, lastY)-(X, Y)
lastX = X
lastY = Y
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
mouseIsDown = False
End Sub