Creating graphics with VBA

J

Joe Dunfee

I am creating a VBA application for Access. I want the user form to show a
graphic illustration of the top view of a room, and for that drawing to
change to show different size rooms. Essentially, a very simple
architectural floor plan.

I am approaching this by creating a template drawing using rectangles,
lines, and text boxes. The position properties of each of these entities are
changed to show the user input. It is updated anytime the form is opened or
the user changes to a new record. Here are two lines of code that set the
properties of the rectangle for the outside perimeter of the room.

==============
Me.OutsidePlan.Width = RoomWidth * RoomScale * 1440
Me.OutsidePlan.Height = RoomDepth * RoomScale * 1440
==============

The "Me.OutsidePlan.Width" is the name of a rectangle. The Room scale is a
variable set to something like 0.021 [1/4"=1']. The 1440 is a number used
to convert the inch units into twerps units. [VBA requires that you use
"twerps" as the unit for referring to sizes of objects]

This is working well, but I also want to show dimension on the drawing.
I've simplified the dimensions as much as I am willing to go, but it still
will require 6 lines and one text box for each dimension. This is quickly
going to get complicated.

I had originally thought of simply storing each point of the template
drawing in an array, and simply multiplying the array by the correct width
and height. But certain things like the width of the walls won't scale
properly. For example, assume I drew my original template rectangle (one
outside rectangle for the outside perimeter, and one for the inside) at 10' x
10' with a 8" wall. If I wanted to make it 20' x 15' with an 8" wall, simply
scaling it would give me the outside perimeter correctly, but the wall
thickness would scale to be 16" on two sides, and 12" on the other two sides!

I know I can simply hard code the inside perimeter to offset from the
outside perimeter, but I will have the same issues when I add dimension
lines, which should be placed at a uniform spacing away from the walls.

I am looking for a better approach.

One other problem I am having is that I am using a bitmapped imaged to show
the door. I am successful at placing the image of the door in the correct
spot on the drawing. However, the image overlaps lines I want to show
through. There seems to be a property of an image to make it transparent,
but for some reason it doesn't seem to work. The image is only two colors,
B/W and one would assume the white background would go transparent when that
property is set. Is there something incorrect about the way I am doing this?
Perhaps this property doesn't work, even though it is there.

I've searched the internet, but there doesn't seem to be much in the way of
VBA graphics being discussed.

Note that I am writing this application for a company that uses MS Office
Suite 2003. I would rather keep all the graphics inside the Access Form,
rather than imbedding a Power Point drawing or something like that. There
seem to be a lot of complications with that method.

Any suggestions?

Joe Dunfee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top