Solved

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

Posted on 2004-04-23
5
396 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 125 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

728 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