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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Graphic Active X

Status
Not open for further replies.

Mrall

Programmer
Nov 22, 2008
64
US
I believe that this request may not be possible in VFP but maybe someone has some ideas as to how it may be done with some sort of active x or C routine that can be called from VFP.

I would like to take a 2d graphic (floorplan) and be able to click anywhere on it adding a very small icon and linking it to a record in a table that contains information.

Can this be done or has it been done in VFP?

Thank for any ideas
 
It probably can be done in VFP.

Is the floor plan a static image? Or do you want to be able to generate it on the fly, perhaps in response to user input? If the latter, it would probably be too difficult.

But if the floor plan already exists as an image, you could display it in an image control on your form. That part is easy.

To trap the mouse clicks, you could write code in the image's MouseMove event. The code would constantly store the mouse's X and Y co-ords (which MouseMove receives as parameters) in a pair of custom form properties.

The image's Click event could then use those co-ords to determine which part of the floor plan the user clicked in. Those co-ords are relative to the form, so you would have to adjust them to make them relative to the image. That would be no problem.

The final step would be to use a lookup table that relates the co-ordinates to specific items in the plan (specific rooms or whatever). That will tell you exactly what the user clicked on. You would then have all the information you need to update the table.

Does that meet your requirements? As I indicated earlier, if the floor plan has to be generated each time, you would probably need to find a third-party solution.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
As you talk about floorplan, I'd rather suggest you do that with a third party image software, instead of painting with VFP and simply use the image and put buttons or containers on it for the interaction. The floorplan itself should not vary that often, so a static image (you can edit anytime needed) should be sufficent for your application, shouldn't it?

You then add buttons and/or transparent containers on top of an image control to define clickable icons and mousover areas.

Besides that idea, you can draw quite anything via the VFPX GDIPlusX library.

Actually that library is just a lot of declares to gdiplus.dll functions warpping that up in a easy to use fashion with several very helpful classes surrounding this, which sum up in a system.app file you simply start once (Do system.app) and then have some public object _screen.system with a substructure of methods, subobjects, properties, etc. The object hierarchy is organised as in .NET namespaces (eg System.Drawing.Graphics is mapped to _screen.System.Drawing.Graphics) This allows you to more easier adapt .NET code you may google for drawing to VFP.
The app file also makes it easier to integrate that library without adding classes to your project, just a side-by-side app like you already should be used to for reportoutput.app etc.

In regard to clickable areas within the graphics you either would do that by mapping the mouse location you get in the mousover event to clickable areas or areas sensitive to mouseover events. Again said, you may simply use transparent borderless containers for that, or add small command buttons on the graphic at the positions you want them.

Bye, Olaf.
 
Thanks for your quick response

The floorplan would be a jpg of bmp(I have managed to obtain free external application to scan in the floorplan and adjust the size to a predetermined size (it works really well))It would be a set size (always the same) and may be selected using a getfile() This would be set one time and associated with the project and all the records. It will require the use of slider bars to view the entire jpg or bmp file. (Will this cause any issues?)

I am currently looking into GDIPLUS.VCX and am not sure what commands or how to use them to place a jpg with scroll bars into a form. I also want to place say (a stick pin icon) onto the jpg and link it to input.

Thanks
 
You say the image is static, and you are planning to scan it in. If that's so, I don't see why you need GDIPLUSX.VCX. You already have the image.

The issue is how to detect the location of the mouse clicks. I've already suggested one solution to that. Olaf has suggested another: placing transparent shapes over the image to receive the clicks.

Regarding the use of scroll bars, GDIPLUSX won't help you with either.

If the image can occupy the entire form, you can just add the scroll bars to the form. If the image is only part of the form, you can place the image in a scrollable form which is in turn placed inside an outer form (if you're not sure how to do that, see Create a scrolling region within a form - but note that it will only work if the form is modeless).

If I have misunderstood your requirements, my apologies.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Perhaps I should explain further

The maps(jpg) are 1800x1200 and I don't believe will fit on a form without some sort of scrolling ability on the image control. (or just how big can a form be?)

The map is not divided into any sections or special areas. It is basically just a picture with points that refer to a record.

The points are NOT preplaced(during the creation of the form) they placed on the picture by the user. (Can a mouse point be read on a picture that scrolls and would it be unique?) Can a button or shape be placed on that spot over top of the picture(at that unique mousepoint)?(the picture could be in the background)

Here is what I do know
I do know that mousing over a button or any other object can display information which is very useful.

I also know that clicking on any object can result in the ability to input information.

If a button or object is associated with a record, that record can be viewed.


Here is what I need to know
How to view a very large picture in a form

How to place a object(icon,button,ect..) at a certain point on the large picture in the form when it is running and not during the creation of the form.

How to capture a mouse point when it is over the picture at any spot (even if the picture is scrolling)

I truily hope this has cleared up any questions. I sure hope this is possible.

As alway thanks for all your input.
 
The IDE Form designer has a limitation you can set in options, but a form size itself is only limited by the screen size. There is no limit, as a form also can be larger than the screen/desktop, it's just not that practical.

The image control can also crop or resize the image. How good or bad that looks depends on line widths, single pix lines may vanish by the resize to smaller sizes.

There is no easy scrollable area and the image control itself offers no scrollbars, but you could use this scrollable container: or this done without activex:
As Mike said, you may not need gdiplus anymore, as you already have a floorplan image, but I talked of gdiplusX, not the gdiplus.vcx of VFP - see
In general take a look at what the VFPX project at offers.

Bye, Olaf.
 
One more detail answer: To programmatically put something on a form, you simply use Thisform.Addobject():

Code:
Thisform.AddObject("container1","container")
Thisform.container1.top = 10
Thisform.container1.left = 100
Thisform.container1.visible = .T.

If you don't use the base container but your onw container class and have code in it's click method the user can click on the container and you don't need to determine mouse positions, you just need to initially put the container or some other shape object at the place that should be clikable. If both the image and the clickable container or shape is put into a scrollable container, both will scroll in sync and so you don't need to worry about mouse positions relative to image or screen.

Bye, Olaf.
 
Mrall,

You are now saying that you have multiple plans, not a single plan as you originally suggested. That makes it more complicated - but not impossible.

But I'll try to answer some of your specific points.

Regarding the scrolling, the article I referenced tells you how to do what you want. Did you read it yet? There should be no problem in using the technique to display an 1800 x 1200 image in a scrolling region in a form.

Regarding the placement of an icon (such as a pin) at the point where the user clicks. Yes, that should be no problem. You need another (smaller) image control to represent the icon; this is initially invisible. At the time the user clicks, you make it visible and move it into position. You know the co-ordinates of the click (relative to the form), so you just have to move the pin icon (or whatever) to the point.

Because the floor plan can scroll, you would have to adjust the co-ordinates to take account of the current viewport. That's easy. Just add the current values of ViewportTop and ViewportLeft to the co-ords.

As far as I can see, that should give you what you want. If it doesn't, I obviously still don't understand the requirements.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top