Home > Archive > Visual Basic Syntax > April 2005 > Problem with metafile image handle
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Problem with metafile image handle
|
|
|
| Hi,
I have problem with metafile image handle. I have handle, but how I can get
image to the StdPicture variable?
Language is VB 6 SP6.
Thank in advance,
Sakke
| |
|
|
|
| Hi
Picture is only in memory so I can't use LoadPicture??
I have one dll which give only handle to the picture in memory.
Sakke
""Peter Huang" [MSFT]" <v-phuang@online.microsoft.com> wrote in message
news:8swe8NYRFHA.2480@TK2MSFTNGXA02.phx.gbl...
> Hi
>
> Commonly I think we just need to call LoadPicture to load the file
> directly.
> If you do want to do convert, you may take a look at the links below.
>
> http://www.vbaccelerator.com/home/V...ator/VB5_Alpha_
> Icon_Creator_zip_cFileIcon_cls.asp
>
> http://www.vbcity.com/forums/topic.asp?tid=5742
>
> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support
>
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
| |
| Karl E. Peterson 2005-04-20, 8:59 pm |
| Sakke wrote:
> Picture is only in memory so I can't use LoadPicture??
> I have one dll which give only handle to the picture in memory.
I think you're looking for PlayMetafile and/or PlayEnhMetaFile? See
http://vb.mvps.org/samples/Wmf2Emf for some usage examples.
Later... Karl
--
Working Without a .NET?
http://classicvb.org/petition
| |
|
| Hi!
There is something what I don't understant :(
I have one module with this declaration:
Declare Function PlayMetaFile Lib "GDI32" (ByVal hDC As Long, ByVal hmf As
Long) As Long
And one test form with this code:
Private Sub Command1_Click()
Dim pic1 As New StdPicture
Dim picHnd As Long
Dim i As Long
picHnd = LoadPicture("C:\Downloads\Wmf2Emf\MVPLogo.wmf")
i = PlayMetaFile(pic1.Handle, picHnd)
End Sub
Why I can't get picture to the pic1 variable?
Sakke
"Karl E. Peterson" <karl@mvps.org> wrote in message
news:uKAbXTeRFHA.244@TK2MSFTNGP12.phx.gbl...
> Sakke wrote:
>
> I think you're looking for PlayMetafile and/or PlayEnhMetaFile? See
> http://vb.mvps.org/samples/Wmf2Emf for some usage examples.
>
> Later... Karl
> --
> Working Without a .NET?
> http://classicvb.org/petition
>
>
| |
| Karl E. Peterson 2005-04-21, 4:01 pm |
| Sakke wrote:
> There is something what I don't understant :(
>
> I have one module with this declaration:
> Declare Function PlayMetaFile Lib "GDI32" (ByVal hDC As Long, ByVal
> hmf As Long) As Long
>
> And one test form with this code:
>
> Private Sub Command1_Click()
> Dim pic1 As New StdPicture
> Dim picHnd As Long
> Dim i As Long
>
> picHnd = LoadPicture("C:\Downloads\Wmf2Emf\MVPLogo.wmf")
>
> i = PlayMetaFile(pic1.Handle, picHnd)
>
> End Sub
>
> Why I can't get picture to the pic1 variable?
Metafiles are a weird lot. LoadPicture returns a StdPicture object, though, not a
handle. To load a disk file into a Picture box, just assign LoadPicture directly to
its Picture property. No need for PlayMetaFile in that case.
Later... Karl
--
Working Without a .NET?
http://classicvb.org/petition
[color=darkred]
> "Karl E. Peterson" <karl@mvps.org> wrote in message
> news:uKAbXTeRFHA.244@TK2MSFTNGP12.phx.gbl...
| |
|
| Hi
This is my actual needs:
I have one dll which give me handle to the barcode metafile image. I want
put image to the StdPicture variable so I can use that image later for
Crystal Report 8.5.
So my problem is that I can't put image from handle to StdPicture variable.
I know that it should work with PlayMetaFile but it not work.
Why I can't get picture to the pic2 variable from pic1 with this example
code?
This is only example code wherewith I try understant PlayMetaFile.
Private Sub Command1_Click()
Dim pic1 As New StdPicture
Dim pic2 As New StdPicture
Dim picHnd As Long
Dim i As Long
Set pic1 = LoadPicture("C:\Downloads\Wmf2Emf\MVPLogo.wmf")
i = PlayMetaFile(pic2.Handle, pic1.Handle)
End Sub
Sakke
"Karl E. Peterson" <karl@mvps.org> wrote in message
news:uHrPCMpRFHA.1528@TK2MSFTNGP09.phx.gbl...
> Sakke wrote:
>
> Metafiles are a weird lot. LoadPicture returns a StdPicture object,
> though, not a
> handle. To load a disk file into a Picture box, just assign LoadPicture
> directly to
> its Picture property. No need for PlayMetaFile in that case.
>
> Later... Karl
> --
> Working Without a .NET?
> http://classicvb.org/petition
>
>
>
>
>
>
| |
| Karl E. Peterson 2005-04-22, 4:03 pm |
| Did you look at the code I pointed you to earlier? You "play" metafiles to device
contexts. The concepts are not readily abstracted by VB for you. It really requires
digging in and understanding what's going on. StdPicture objects don't have DCs
associated with them. I have no idea what CR is wanting (never used it), but if it's
a StdPicture object with an embedded metafile, you are going to have to get really
creative here. I'd suspect it's looking for a bitmap representation instead?
Anyway, odds are, you'll probably need to play the metafile to a memory based device
context, then do in memory transfers of the resulting image. Another angle to look
at this from might be found at http://vb.mvps.org/samples/MemoryDC. It's going to
take the sorts of techniques offered there, along with the earlier link I pointed you
to, to arrive at a hybrid solution of the sort you s .
--
Working Without a .NET?
http://classicvb.org/petition
Sakke wrote:[color=darkred]
> Hi
>
> This is my actual needs:
> I have one dll which give me handle to the barcode metafile image. I
> want put image to the StdPicture variable so I can use that image
> later for Crystal Report 8.5.
>
> So my problem is that I can't put image from handle to StdPicture
> variable.
>
> I know that it should work with PlayMetaFile but it not work.
>
> Why I can't get picture to the pic2 variable from pic1 with this
> example code?
> This is only example code wherewith I try understant PlayMetaFile.
>
> Private Sub Command1_Click()
> Dim pic1 As New StdPicture
> Dim pic2 As New StdPicture
> Dim picHnd As Long
> Dim i As Long
>
> Set pic1 = LoadPicture("C:\Downloads\Wmf2Emf\MVPLogo.wmf")
>
> i = PlayMetaFile(pic2.Handle, pic1.Handle)
>
> End Sub
>
> Sakke
>
> "Karl E. Peterson" <karl@mvps.org> wrote in message
> news:uHrPCMpRFHA.1528@TK2MSFTNGP09.phx.gbl...
|
|
|
|
|