Graphics in General 
Author Message
 Graphics in General

I've encountered a problem with drag and drop operations that may be of
interest to some of you.  I've lost quite a bit of hair with this one, and
have spent the entire weekend trying to resolve the problem.

First, I am working on a usercontrol.  This may not matter, then again it
may, since I don't know if graphics are handled differently for
usercontrols than for a normal project.

Here is the situation.  I have found that, some of the time, if you click
on the right or left edge of the picturebox and start a drag operation,
that the mouse will jump to the center of the control.  Normally, this
wouldn't be a problem, but since I am restraining the X-axis of motion for
the mouse, it becomes a major problem. (When I restrain the X-axis, the
mouse moves from the centered position, dragging the control with it.)  For
those of you interested in recreating this, you will find it hard to do
unless you implement a good drag and drop model, and set the width of the
picturebox to something unusual (155 twips is a good number)

I still am not sure what is causing this, exactly.  My guess is that it has
to do with the alignment of the control in respect to pixel boundaries.  I
think that certain graphic operations require considerations related to 4
pixel alignments, and that the drag operation moves the mouse cursor to the
center of the control when the border of drag-rectangle shifts inward (thus
keeping the mouse inside of the drag rectangle).  For instance, I cannot
recreate this problem if I prevent the drag from happening when the mouse
is located on the far right or far left pixels.

If anyone has any deeper knowledge about this, I would appreciate hearing
about it.  In some cases, it would be better for me to force the proper
alignment of the picturebox.  But I don't know if 4 pixels is correct, or
if it is even pixels, or whatever.

Thanks,

Tim



Thu, 04 Nov 1999 03:00:00 GMT  
 Graphics in General

Quote:
> Here is the situation.  I have found that, some of the time, if you click
> on the right or left edge of the picturebox and start a drag operation,
> that the mouse will jump to the center of the control.  Normally, this

Here is the best solution that I have found to the aforementioned problem:

        Dim psRect As RECT

        GetWindowRect picGizmo.hwnd, psRect
        With psRect
            .Bottom = .Bottom - 1
            .Right = .Right - 1
            .Top = .Top + 1
            .Left = .Left + 1
        End With

        GetClipCursor m_BeforeDragRect
        ClipCursor psRect
        ClipCursor m_BeforeDragRect

        picGizmo.Drag

Clipcursor moves the cursor in a fairly intelligent manner, and gets you
neatly out of using Event_Mouse methods (which are pretty gruesome, since
you have to convert pixels to mickeys and hope that the rounding works
out).  It also doesn't require you to check on the cursor position and
doesn't effect the cursor if it is within the boundaries.  As far as
solutions go, it is clean.

If anyone can shed any light on just what it is that I fixed <g>, I'd still
like to hear about it.

Tim



Fri, 05 Nov 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Graphics in General

2. graphics filter to convert array(x,y) to standard graphics

3. Saving graphics objects to an standard graphics file

4. Graphic example - 'smart' connected graphic objects

5. Graphic example - 'smart' connected graphic objects

6. Overlaying text onto a graphic and saving as graphic

7. How to overlay graphics on text/graphics

8. ADO .Open problem (posted on general news too)

9. General protection Faults in Win 2000

10. Changing general Access options form VBA?

11. VBA to Open Append Query General Properties

12. General question on Access reliability / database corruption problems

 

 
Powered by phpBB® Forum Software