Link to home
Start Free TrialLog in
Avatar of ACSpike
ACSpike

asked on

Using VB6's Intrinsic Controls on an MSAccess Form

I wrote a little app in VB6 that uses the intrinsic VB.PictureBox controls. I want to move my app onto a form in MS Access 2000. There is no PictureBox control in the Access toolbox. How can I use the PictureBox and other VB6 intrinsic controls in Access?

I thought about writing an ActiveX wrapper control for a PictureBox that would expose all of the PictureBox's properties, events and methods, but that is a whole bunch over my head. I don't want a third party ActiveX control because I want it to be available on all computers with out worrying about registering OCX's.
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Image control from Access doesn't give you what you need?
Avatar of ACSpike
ACSpike

ASKER

No it doesn't. First an image control has to load an image at design time. I dont' want that.

I'm using an invisible PictureBox to load JPGs. And the PaintPicture method to resize it into a specific location on a second PictureBox. I'm also Printing Text to the second PictureBox.
But you could use something like this:
Private Sub Form_Load()
'img is the image control that comes with Access
Img.Picture = "C:\Documents and Settings\rsimonetti\Mis documentos\Mis imágenes\6.jpg"
End Sub
And you could use API BitBlt instead of PaintPicture i think.
Avatar of ACSpike

ASKER

I still need to load a picture at design time. I can't get an image control to stick on my form with out an image in it. BitBlt could very likely work for PaintPicture but can I print text to an image control?

If I am going to have to do API work to get at BitBlt, is there API work I could do to get at VB.PictureBox? It has to live somewhere! VBRUN60.DLL?
In Accesss you use the OLE control to display pictures. You can bind the OLE control to any tabe field defined as "OLE Object".  It's pretty cool and dead easy to do.
Once you have an OLE control you can create a command button with a caption like "Add Image" which has code like this:

Private Sub Command5_Click()

DoCmd.GoToControl "YourOLEBox"
On Error Resume Next
RunCommand acCmdInsertObject

End Sub
Avatar of ACSpike

ASKER

I'm looking for an unbound control. I don't want to store any image data in the database. I'm drawing multiple pictures and text on one PictureBox and using the second hidden PictureBox as a buffer to load the pictures.
I really want to use the VB.PictureBox. I like its functionality and I am comfortable programing with it.
Then, you haven't a choice. Create a control in VB with Picturebox control in it and expose all its methods, events and properties.
I think there is no way you  get that funcionality doing in other way.
Here is another thought...If you have access to Windows API, then you can create a picture box using API....its starts to get more hard-core.
VB's picturebox is a private class, and is only available to forms, usercontrols, and userdocuments.

If you absolutely HAVE to have a picturebox, you'll have to do as Richie_Simonetti suggested and write your own in VB.  However, you don't need to delegate to an internal picturebox.  Since the usercontrol object provides all of the necessary properties and methods, you can just use the usercontrol directly, like:

Public Property Set Picture(newPicture as IPictureDisp)
   Set UserControl.Picture = newPicture
   'not Set InternalPictureBox.Picture = newPicture
   PropertyChanged
End Property
I agree with JMoon5FTM, besides, you need to map those important methods that you need as Circle, PaintPicture, and so on.
Avatar of ACSpike

ASKER

I guess I will have to embark on writing a wrapper control for the PictureBox, if I am going to stick with doing things my way. I've never written a control before. Can I get a quick run through of what this will take?

A few questions for educational benifit if you want to answer any of them:
Where is the Private VB.PictureBox class stored?
Why is such a versitle control private?

ASKER CERTIFIED SOLUTION
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ACSpike

ASKER

I really appreciate the quick responses! I hope you won't mind if I take a day to read this over and learn Spanish.
(Is that Spanish?)
Don't worry for Spanish, it doesn't care!! Just do what i said and test it.
The comments were all generated by the ActiveX Control wizard that comes with VB; they're pretty worthless, and can be safely deleted.

Don't forget to come back and give Richie_Simonetti some points.
"...they're pretty worthless, and can be safely deleted.
...."
Well ONLY those in spanish...
Avatar of ACSpike

ASKER

Oh I won't forget the points don't worry! Actually let me know if you think I am incurring more points. I'm not real sure how this all works yet.

I tried it in my project. That means I dropped the UC control in place of Picture boxes in my current project. It didn't work because it doesn't support things like .autosize, .cls, .TextHeight, .TextWidth, .CurrentX, .CurrentY and .Print, but I could add those things right?
If I need all these things would it be easier to stick a PictureBox inside of a UserControl? Is there a step by step approach to doing this written out somewhere? like first do the get and set to expose all the properties, then write the methods, then... etc.

Let me know if posting my code will help you understand what I am doing.
All the properties that you mentioned can be addedd.
Unfortunatelly, Autosize is not an option if you don't add a PictureBox control inside user control.
Print cannot be added without the picture control too. :(

But, Autosize could be done using code that we need to write, checking the properties of the picture that is loaded, which scalemode the container is using and resize the control to meet the requirements.
Avatar of ACSpike

ASKER

I think PictureBox inside a UserControl is the way I want to go then.
yeah, unfortunatelly...
Anyway, take in mind that you will need to manage the autosize by yourself since the only thing that is autosize is picturebox not user control.
If not, you could get an autosized image inside an user control that could be less than it in terms of width and height.
Besides, you will need to deploy the VB run-time too.