Solved

Passing a Picture from PictureBox to OLE

Posted on 1998-01-08
4
390 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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 …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

772 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