Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Passing a Picture from PictureBox to OLE

Posted on 1998-01-08
4
Medium Priority
?
400 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
[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
  • 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 140 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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 …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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

610 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