Solved

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

Posted on 2004-04-23
5
393 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 85

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

Independent Software Vendors: 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

740 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