Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Is there a way to Edit or Open a Picture control at Runtime?

Posted on 2004-04-23
5
Medium Priority
?
399 Views
Last Modified: 2013-12-26
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!
0
Comment
Question by:nicthu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 10899472
Just add a PictureBox to your form and use this code to allow the user to draw on it:

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
0
 
LVL 5

Accepted Solution

by:
JMoon5FTM earned 500 total points
ID: 10902320
I don't know if you can do that by inserting the Bitmap Image directly, but I know this'll work.

Insert an OLE control.  Tell it to create a Bitmap image (or any other type of object you might want to do this with).  Then, at run-time:

ole1.DoVerb -1 'edit in-frame, if supported; otherwise, open in new window
ole1.DoVerb -2 'open in own window

0
 
LVL 1

Author Comment

by:nicthu
ID: 10905178
Which OLE control do I insert?
Or where do I find such an OLE control?
0
 
LVL 1

Author Comment

by:nicthu
ID: 10905660
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"?
0
 
LVL 1

Author Comment

by:nicthu
ID: 10908033
Nevermind again, I found the ReadFromFile and SaveToFile methods!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question