Solved

Passing a Picture from PictureBox to OLE

Posted on 1998-01-08
4
387 Views
Last Modified: 2012-05-04
Hello!

  I'm trying to pass an image from a PictureBox control to a OLE container, so I can edit the pictue.
   I use this:
      SavePicture Picture1.Picture, App.Path & "\myfile.bmp"
      OLE1.CreateEmbed App.Path & "\myfile.bmp", "Paint.Picture"
   The problem is that the Class of the OLE object is not "Paint.Picture", but "Package"

  Is it possible to pass directly the image from the PictureBox to the OLE?, Or if it is not, what is wrong with my code?
  Thank you!
0
Comment
Question by:taco
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:rantanen
ID: 1449852
Taco,

your code works at least in my computer (VB5 (SP2), Win95) if I make following

    SavePicture Picture1.Picture, App.Path & "\myfile.bmp"
    OLE1.Class = "Paint.Picture"
    OLE1.CreateEmbed App.Path & "\myfile.bmp"

I think your problem is that you have set the Class type at design time and CreateEmbed ignores the type, if SourceDoc is specified (as you did)

HTH
0
 

Author Comment

by:taco
ID: 1449853
The problem I have I think is because all my graphic files (GIF, JPEG, BMP are asociated to ACDSee program (it's a graphic viewer), and when I do the .createembed, OLE container ignores the class I'm giving to it, and inserts the file as a 'Package' Class, so when I double click the picture (it's just the icon) it opens ACDSee, but I want to open Paintbrush to edit the picture.
   Anyway I would like to know if I can do it directly, from my PictureBox to the OLE.
0
 
LVL 4

Accepted Solution

by:
rantanen earned 70 total points
ID: 1449854
Taco,

it is not possible to transfer a bitmap from PictureBox to OLE control directly - you have to go thru a disk file. (It works only the other way around).

To avoid the association problem, rename your files something else than myfile.bmp, for example myfile.xxx and then use the code you had.
0
 

Author Comment

by:taco
ID: 1449855
Well, I've tried that and doesn't seems to work. I even create an asociation between my *.xxx files and PaintBrush, so I can
open my files double clicking them in my Windows Explorer. But my OLE control doesn't recognize this asociation, and when I
try to Embed  my *.xxx file as a PBrush file, OLE control doesn't wants to, and make ma a 'Package' class.
      Anyway I think you are pointing in the right direction, rantanen, so I will try a little bit more and if I get nothing better I will accept and grade your answer. Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

912 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now