• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 492
  • Last Modified:

Binding a Picture object to a Image data type field

Hello,

In a VB6 SQL 2000 application, I use an Image data type field to store .bmp file.

Is there a way to display the bmp file in a Picture object without having to save the file locally?
I know I can save the file somewhere using

    Dim rs         As ADODB.Recordset
    Dim stmDocTest As ADODB.Stream
    Dim strFile    As String

    Set stmDocTest = New ADODB.Stream
    stmDocTest.Type = adTypeBinary
    stmDocTest.Open
    stmDocTest.Write rsDocument!docInsert
   
    strFile = App.Path & "\TEMP\"
    stmDocTest.SaveToFile strFile, adSaveCreateOverWrite

I would like to bind directly the Picture object to the Image data field without having to save the file locally
Something like...

   Set Picture1.Picture = rsDocument!docInsert  (wich does work)

 .... without having to save the file locally is my key issue

Thank you

Mario
0
MarioCantin
Asked:
MarioCantin
1 Solution
 
HoweverCommaCommented:
The problem is that loading from a file is built in to the picture box control, that is the only way it knows how to do it.
You can 'trick' it though, just place your picturebox wherever you want it to be.
Then you will have to use some API calls to modify the hDC (windows device handle to the bitmap displayed), in VB you can not change the hDC property it is read only you can modify the BMP that the hDC points to. Unless you want to go the route of setting pixels manually (your own BMP decode routine NOT recommended) or find a custom Picturebox replacement that will load from a stream then this is the only way I can think of doing this. You may need more robust support you can get the BMP header info for the formats you desire to support by searching for "BMP file structure" and replacing the code in this accordingly. This should get you going.

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20608231.html 
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now