"Chris Coho, Jr." <ne*******@mattbooty.com> wrote in message
news:va***************@nwrdny02.gnilink.net...
Everything is working great now, thanks again for the help but
I have one last question for you. Now when moving the image
around and resizing it, etc, the image flickers a lot while its in
motion. Is this just a problem inherint to image boxes or is there
something I can do to fix this? Its a very minor problem and one
i'm not really worried about, but if there is an easy way to fix it
Image controls always flicker when you move them around, because of the way
VB updates it's display of "VB drawn" controls. One simple way to overcome
the problem is to use a Picture Box instead while the "Image" is being
dragged and then replace the Picture Box with an Image Control when the user
stops dragging and releases the mouse button. The problem with this method
is that the Picture Box will appear on top of all other Image Controls while
it is being dragged and will only revert to its correct Z Order when the
user releases the mouse button, whereas your existing Image Control would
drag itself in the correct Z Order at all times. Personally, if you want
full control over everything I would suggest that you don't actually display
any controls at all on the screen (Picture Boxes or Labels or Image
Controls) and instead "draw" each desired item directly onto the Form (with
Autoredraw being set to True). This method is fairly simple to program if
all you want is "rectangular" images (with no transparent sections), but
will require a bit more programming if you want to have irregularly shaped
images. Either way, of course, it would probably be a bit of a major rewrite
of your existing display code, but I think you would find it worth it in the
end.
There are various methods of writing stuff such as this so that you only
ever draw stuff to the sections of the Form that have actually changed, but
on today's machines you will find that it is perfectly feasible to instead
draw the entire Form, including every single image and piece of text, every
time the display changes (for example, when the user drags an object). For
example, for every image and piece of text you could create a borderless
Picture Box of exactly the desired display size and paint or print the image
or text into it (preferably using the API StretchBlt and Text APIs). This
stuff will be very much easier to program if you use a ScaleMode of
vbPixels. These Picture Boxes would all be part of an array of Picture
Boxes, with the Index property value specifying the desired Z Order. You
would also have separate arrays of Longs containing the same number of
elements to specify the initial x and y cordinates (and size if desired) of
each element. You should set the Form's Autoredraw property to True. You
would then call a routine to initialise the display. This routine would
first of all clear the screen or alternatively paint the desired overall
background picture using BitBlt (if you want one) and would then run through
each element of the Picture Box array in turn, using BitBlt to transfer its
contents to the desired area of the Form (as indicated by the positional
arrays). In the MouseClick of the Form you would look at each element of the
"position" and "size" arrays in turn to determine if the Mouseclick x and y
coordinates both lie within the rectangle that it currently occupies on the
Form. The first element that fits the bill is the one that you need to move,
so you set a "Form level" variable accordinbgly to specify its number. Then,
in the MouseMove event you update the appropriate element of the "position"
array according to the x and y values picked up by the MouseMove event.
(This Mousedown and Mousemove code is similar to the code that you already
probably have). The (still in the MouseMove event) you call the "Initialise"
routine again, which will of course clear the display (or renew the
background picture) and then draw each element into position. Because you
have set the Form's Autoredraw property to True all of this stuff will be
drawn into the "unseen" Image property of the Form, and if you are using the
API for all your drawings and text (which I would recommend) then you would
need at this time to use a Form Refresh statement to transfer the entire
drawn composite image into the display. A bit more work is required for
irregularly shaped elements with transparent sections and areas, but it is
certainly possible.
Mike