Use vba to draw inside Object Frame

JohnPapa

Registered User.
Local time
Today, 12:36
Joined
Aug 15, 2010
Messages
1,088
Does anyone know whether I can use vba in Access to draw inside an Object Frame, which is placed on a form? As a start I would like to draw a solid rectangle at a specific location inside the Object Frame.
Thanks,
John
 
Why not build the rectangle at design time and resize/position it at runtime?
 
Does anyone know whether I can use vba in Access to draw inside an Object Frame, which is placed on a form? As a start I would like to draw a solid rectangle at a specific location inside the Object Frame.
Thanks,
John
That is kinda stretching Access' native abilities.

I can think of 3 options.
1. What Chris has said
2. You find or make your own active X control that would work on an access form that draws shapes for you.
3. You use the Windows API to draw a shape.

Both 2 and 3 are very difficult to perfect - and the time it would take to get them to work might cancel out any benefit you gain in having these shapes in the first place.

I really could not give you advise on which to go for until you explain a little more about why you are drawing shapes. It sounds like a rectangle was just an example and there are more shapes to come.
 
Many thanks Darbid and ChrisO for your reply. Darbid is correct in saying that the rectangle is just an example and there are more shapes to come.

We are talking about a dental application and the pictures represent the state of the teeth. The attachment "Pictures.jpg" indicates the sort of pictures that I need to draw on the fly. The rectangle is the simplest form of drawing.

Remember that the drawings will be inside a Object Frame. Maybe a Windows API would do the trick, as Darbid suggested.

John
 

Attachments

  • Pictures.jpg
    Pictures.jpg
    49.8 KB · Views: 470
Ok so here is what I would do.

I would get your full selection of those images and save them in a folder as .gif types. Obviously test with one first in case you are not happy with my suggestion.

Then use a picture box from your tool box to add your pictures where you want.

In the properties of the picture box
Do not embed a picture but use a link and then at run time you simply add a path to the picture you need to add for each patient.

How does that sound?

ps: This is only my opinion maybe Chris will have an alternative for you.
 
Thanks Darbid, I do exactly what you mention today. Actually I use .bmp's that are supported by Access.

I wanted to have the drawing capability so that I would be able to add any picture I want, without going through the process of creating the bmp etc

John
 
I wanted to have the drawing capability so that I would be able to add any picture I want, without going through the process of creating the bmp etc

John

Even if you get something going how will these images be drawn. Will you have a selection of images to draw or will the user somehow sketch a picture with the mouse and that will be drawn and saved for that client?

My suggestions or options, like using the Windows API is pretty wild and very complicated. Whilst it is a possibility it is a lot of work.
 
I understand what you are saying.

At present the state of the teeth of a patient are stored as a text string. I just wanted to investigate the possibility to avoid loading the bmp's and to draw the specific picture on the fly. In other words, if a rectangle represents a "filling", I would like to investigate the possibility of drawing the rectangle on the fly instead of loading the specific bmp.

Maybe it is more trouble, but I have a feeling that it would make matters more flexible. Do you have in mind any Windows APIs that could be used to draw inside an Object Frame on a Form?
 
Well, if you said you were a dentist I wouldn’t have replied. :D
(The only profession that will stick two feet and two hands in your mouth and then ask you a question. :eek: )

But seriously though, drawing on Access forms is not easy even with some of the API call you may find. Most of the API calls I have seen were designed for Visual Basic forms and not Access forms, two different beasts. I would recommend Stephen Lebans site for that because if it’s doable… he’s done it.

So I would stick with what you have, and darbid recommends, and perhaps drag/drop/resize the images using the mouse.

Going down the road a little further I think you could have a button on the form for a new image. Press button, open Paint, draw and save the new image, close Paint, refresh list of drawings, drag new image into position and resize it.

Other things that might throw a spanner in the works are images with transparent backgrounds and the ‘Z’ order on the screen.

Sounds like a lot of code to me but I guess that also makes it rather enticing.
(I don’t suppose that there is already an application out there that does what you want???)
 
I understand what you are saying.

At present the state of the teeth of a patient are stored as a text string. I just wanted to investigate the possibility to avoid loading the bmp's and to draw the specific picture on the fly. In other words, if a rectangle represents a "filling", I would like to investigate the possibility of drawing the rectangle on the fly instead of loading the specific bmp.

I understand your thoughts now. Personally I would avoid this. As Chris has said drawing on a form on the fly is really hard. By having ready made pictures ready and loading them makes it look like you are drawing on the fly. I have a further suggestion of making the pics on the fly but still think loading a picture to your form is the easiest method.

Using the windows API is difficult with Access because: Windows uses a number called a Handle for each thing (window, button, frame etc) on the screen. The "rules" are that there is parent (a window) then children (buttons etc). This works fine in Visual Basic. When MS made access they did not make things easy with these Numbers and thus the FORM you see in access is not always the window. Thus the children are then hard to find.

What does this mean for you. Well you will have to find your object frame, THEN create a child, then draw your pictures with this child.

I may have oversimplified things here, but working with the Windows API and Access is really hard to understand. Stephen Lebans talks about these problems. I have tried to change forms with the API and was never really happy.


Maybe it is more trouble, but I have a feeling that it would make matters more flexible. Do you have in mind any Windows APIs that could be used to draw inside an Object Frame on a Form?

I have another 1/2 solution.

You could make your pictures on the fly.

Have a look at imagemagik http://www.imagemagick.org/script/index.php

This is a library that you can use to manipulate images. But it also can create images like you want.

What I am thinking is that you have a set of base images of teeth, gums etc in your resources folder.

When a patient is called you move your base folder pictures to a temp folder, overlay with the use of imagemagik your rectagles or what ever you want and then show your newly created image on the form.

Once you close the patient the temp pics are deleted.

If you have a look in their forum I wrote a fairly long post (complaint/frustration). Support is almost zero for us kindergarten VBA'ers but I worked it out in the end.
 
Many thanks ChrisO and Darbid. If it would make ChrisO happier, I am not a dentist :)

If you want to have a look, the application can be found at www.VisualDentist.com and has been around for about 13 years!!

I will try your suggestions for which I am once more thankful.
John
 

Users who are viewing this thread

Back
Top Bottom