Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

images in a form... 1

Status
Not open for further replies.

dotolee

Technical User
Jan 27, 2008
134
0
0
CA
hi.
i need to display a graphic in a ms access form. this graphic / image will have several regions. each region will be assigned a value from 0 - 6. depending on where they click, i want to capture the region value in a database field.
in order to do something like this, what type of an image object should i create? has anyone tried this before? can you direct me to some examples?
thank you!
 
if the diagram is a radial image ie looks like a pie cut into segments. How about using opton or check boxes positioned outside the area. You may have to load the image as the bacground of the form if you want to position the check/option boxes near enough.
Hope that helps a little.

Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 
Insert the image on the form and then set the image's "Enabled" property to "Yes". You will then be able to capture the x and y coordinates when the user clicks on the image and process them accordingly by writing code for the image's "OnMouseDown" event.

Regards,
Lisa
 
hi lisaway.
i don't see an "enabled" property for my image...
I'm using 2003..
 
i've attached a screenshot of the properties i have...
 
Oops - sorry about that! You need to add the image as an unbound object frame, not as an "image". To prevent the user from editing the image via double-click or right-clicking and selecting "Edit", place the following code in the control's MouseDown routine:
Code:
DoCmd.CancelEvent

Regards,
Lisa
 
what event am i trying to capture to get the x / y coordinates?
 
The unbound object frame's MouseDown routine returns the button that was pressed to trigger the event, the state of the SHIFT, CTRL, and ALT keys, and the x and y coordinates for the current location of the mouse pointer, in twips.
Code:
Private Sub MyOLEUnbound_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MsgBox X & " " & Y ' x and y coordinates
    DoCmd.CancelEvent ' prevent user from editing the image
End Sub

Regards,
Lisa
 
thanks lisaway. one last question.
how do i know the range of x and y values across my image?
meaning, i want to now divide my image into sections... and to do that i need to know all the possible x values.
 
The x and y coordinates returned by the MouseDown routine are measured in twips. A twip is a unit of screen measurement equal to 1/20 point. A twip is a screen-independent unit used to ensure that placement and proportion of screen elements in your screen application are the same on all display systems. There are approximately 1440 twips to a logical inch or 567 twips to a logical centimeter (the length of a screen item measuring one inch or one centimeter when printed).

Example usage: Say your image is two inches wide by three inches high, and you want to divide it into 4 equal rectangles. Then your MouseDown routine could look like this:
Code:
Private Sub MyOLEUnbound_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    MsgBox X & " " & Y ' Display x and y coordinates
    DoCmd.CancelEvent ' Prevent user from editing the image
    
    If X < 1 * 1440 Then
        If Y < 1.5 * 1440 Then
           ' Upper left processing ...
        Else
           ' Lower left processing ...
        End If
    Else
        If Y < 1.5 * 1440 Then
           ' Upper right processing ...
        Else
           ' Lower right processing ...
        End If
    End If
    
End Sub

If you want to divide the image into rectangles that are not all the same size, then you should implement the MouseDown routine I posted above, then open the form and click at various points on your image to determine the x and y coordinates of the area boundaries. Then modify your MouseDown routine accordingly.




Regards,
Lisa
 
i've created a polygon image map in front page for my image... which in turn gave me a bunch of x/y pairs to identify the boundary i'm interested in.

is there any function in vba that i can use to check if my X value is "in" a list of vals?
kind of like the SQL IN function?
 
Please forgive me if I don't understand your question, but it doesn't make sense to me that you would want to look for x "in" a certain list of values. Your x- and y-values will be in ranges of values.

Regards,
Lisa
 
i believe it has to be specific values... as opposed to a range. for example, if i had an image of a head, and wanted one message to display if the user clicks on the head as opposed to the eyes, i'd have to be very specific. a range of values will not work.
 
dotolee,

If the image is complicated you may need to go back to Ian's solution, which is to make the image as the background and place radio buttons on it.

Or, you can still use Lisa's idea, which makes the interface look nicer. But you have to make complicated rules about x,y coordinates. For example, if the center coordinate of one eye is 300 by 400 and presumably the shape of the eye is round, you need to create a routine to determine whether a click's coordinate is within the radius.

Hope this helps.

Seaport
 
Example: If you had an image of a head that was 3" wide, then the left eye could be from x=.75" to x=1.25" and the right eye could be from x=1.75 to x=2.25". If the user clicked at x=.75 or .8 or .81 or .87 or .83 or 1.1 or 1.13 or any other value up to 1.25, you would have to process the left eye. Another way of saying this would be if x>=.75 and <= 2.25, process the left eye. This is a range of x values, not a specific x value.

Regards,
Lisa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top