Picture Object

VeRiTo
01-10-2005, 06:56 AM
Hi people. I have this app wich draws a barcode (from any given number code) into a picturebox. It works great.
Now i have to build an activeX dll with a function called "GetBarCode" wich returns a picturebox object containing the barcode drawed.
Eg.:


Public Function GetBarCode (strCode As String) As Object
... 'Do something
'I start drawing
GetBarCode.Line (barStart, startY)-Step(barWidth, barHeight), vbBlack, BF
End Function


I get an error: "Run-time error 424 : Object required"
Is it possible to draw an image and then return it as an object?
Thanks in advance!

Dennis DVR
01-10-2005, 07:22 AM
I don't see where you are passing the picture object to a getbarcode function.

and I believe you just want to return the picture object not the picturebox control itself?

VeRiTo
01-10-2005, 07:29 AM
i want to return a picture with the barcode drawed, how could i do it?

Dennis DVR
01-10-2005, 07:41 AM
OK, I don't have VB installed right now, so I can't really test whether it should work or not, but i'll try to help you as possible as I can or I would ask somebody to drop by to help you :)

First you need to modify the return value of your GetBarcode function to StdPicture then in your GetBarcode function you need to draw everything to your Picturebox control then pass the Image property of your picturebox control to your GetBarcode function i.e.


Public Function GetBarcode(strCode As String) As StdPicture
'Draw what ever has to be drawn to picturebox control
Set GetBarcode = Picturebox1.Image 'pass the picture object to GetBarcode function.
End Function

VeRiTo
01-10-2005, 07:44 AM
the thing is i get an error trying to draw into the picturebox!

Public Function GetBarcode(strCode As String) As StdPicture
Dim oPic as PictureBox
oPic.Print "xxx" 'i get an error here!
Set GetBarcode = oPic.Image
End Function

Dennis DVR
01-10-2005, 08:19 AM
ow... I think we have a problem here, you are creating an ActiveX DLL, you can't use a variable as your picturebox. VB won't allow you to do so :)

why do you need to create an ActiveX DLL anyway?

lebb
01-10-2005, 10:51 AM
I would recommend that you take a look at the GDI tutorials on www.elitevb.com. Then pass your function an hDC and use the GDI functions to draw to that device context, instead of relying on the picturebox.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum