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

Drag Drop Image and Stretch the Image

Status
Not open for further replies.

Stanley1243

Programmer
Aug 9, 2008
5
CA
I have a form that has been divided into Cells using vertical and horizontally drawn lines which form Cells on the form.(No Containers Used). Just using the Line object.

Next, I have a tool bar with thumbnails of actual images. I want to place these images in the cells on the form.
I have succeeded in dragging and dropping the Image but I need to stretch the images to fit in one cell/Two cellsor more.

Once done the size of the Image will clip to the Place required to occupy (That can be done with the Stretch Property).

In the nutshell. This Operation is made off.
1) Drag and Drop
2) Stretching at runtime with drag of the Image right
corner tip,Just like when we resize a form at runtime
dragging the corner of the form.

Any help will be much appreciated
 
What exactly is the problem?

You presumably are correctly calculating the co-ordinates of the drop point. From there, you are determining which cell the image goes in, and therefore the co-ordinates of the top-left corner of the cell.

So you set the image's Left and Top to match the top-left of the cell, and you set its Height and Width to match the size of the cell.

Does that not give you the result you want?

If I've misunderstood the question, my apologies.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Thanks Mike,
You have understood the Situation well, but the chance is that the image may span many connective cell (More than one cell.) Towards the Bottom or the right.

Well it's a newspaper layout software.
For example if the user wants to use a Quarter Page Advertisment on the top right then it will occupy the
A1-B4 whereby I will place the drag at point A1 Co-ordinate and Grow it to B4 using the right bottom tip

(The form is evenly Laid out into 4 Columns ABCD & eight Rows (1 to 8)

Please Refer to the mentioned link for the screenshot at

Tks
 
Hello Dave,
The container shapes vary too...as per layout of the Picture.

Please refer to my answer to Mike for a more understanding of my problem. The Screenshot will perhaps give you a better idea of what i require.

Tks
 
Stanely,

Ah, I see. You're saying that the user will manually resize the picture by draggings its corners. It's the user's responsibility to make sure the picture fits the correct number of cells. Your problem is knowing how to let the user do the resizing. Is that right?

One option would be to not use a picture at all, but to use a container. The container would contain the image, and also contain four small shapes, one at each corner, to act as handles.

At the start of a drag, you would have to check to see if the mouse was over a handle. If so, in the OLEDragOver, you would resize the container in the direction of the dragging. In the OLEDragDrop, you could work out where the nearest cell boundaries are, and snap the edges to those lines.

It would be do-able, but a little complicated. Also, you wouldn't get a very good visual effect - not like in other applications that support this sort of thing.

How about this for another approach: Instead of using containers or images, use a separate form for each image. The form object already supports all the dragging and resizing you need. You would still have the problem of making the edges snap to the cell boundaries, but that should be straightforward. You would also have to make the forms "always on top", otherwise the main form (the one with the cells) would cover them when they have focus.

I'm not sure how well it would work, but it might be worth thinking about.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Stanley,

did you try using the image's mouseenter, mousedown ,mouseup and mousemove events?

e.g.

in the mouseenter event put

this.borderstyle = 1

so as to get a border

in the mousedown event put something like

LPARAMETERS nButton, nShift, nXCoord, nYCoord
DODEFAULT()
DO CASE
CASE NXCOORD > THIS.LEFT+THIS.WIdTH-5
THIS.MousePointer = 9
THISFORM.MousePointer = 9
CASE NXCOORD < THIS.LEFT+5
THIS.MousePointer = 9
THISFORM.MousePointer = 9
CASE NYCOORD > this.top+this.height-5
THIS.Mousepointer = 7
THISFORM.Mousepointer = 7
*!* and so on for top and corners
ENDCASE

then have mousemove resize the image as you move the mouse

if this.mousepointer = 9
this.width = nxcoord-this.left
endif

and mouseup can capture the new width and optionally snap to a grid.

(all untested)


hth

nigel

 
Hello Mike,

Never thought of the form Object, in other words dragging the form by title bar, resizing as to the cell/s required and then on some click, Release the form, take dimensions of the form and recreate an image to those dimz.


Will try it out.

Thanks.
 
Hello Nigel

Your suggestion is worth trying...interesting concept.
I am sure it will work.

Thanks

Stan
 
Stan,

I wasn't thinking of releasing the forms after they were put into position. I was thinking you'd keep the form in place, the whole time the outer form (the one with the grid) is active.

But, come to think of it, it might be easier to release the forms and replace them by images, as you suggested.

If you did keep the forms in place, you'd have to write code to deal with the moving or resizing the outer form. The "image" forms would have to be moved around to stay in sync with the main form.

Anyway, it's just an idea. I've often done stuff that involves dragging objects round the screen, but never had to resize them.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top