[comp.sys.mac] Dragging Icons

franco@bbn.com (Frank A. Lonigro) (02/19/88)

[[[[[ Line eaters unite ]]]]]

To all LSC users:
	I'm new to programming the MAC and have a request.  Could some
of you send me your favorite piece of code for choosing and dragging
ICONs with the mouse(not the whole program, just that section of code).

	I have this great book on programming the MAC in "C", "Using the
Macintosh ToolBox with C".  It's a good book and I'm learning alot, but
it doesn't explain how to code the most used aspect of the Mac desktop,
namely, choosing an ICON and have it become its mask and then dragging it
to another spot on the desktop(be it in a window or the desktop itself).
I have this idea that I need to define a rectangle, stick the image of the
ICON in it and then detect a mouseDown event and determine if the Event.where
point is enclosed by that rectangle.  This is all well and good except
how do you have it change to its mask?  I also could use OffsetRect() to
move it, but there must be an easier way to find out the "dh, dv" parameters.
Is there such a function called DragRect() synonymous to DragWindow()??

	Any and all help you can give would be greatly appreciated.

Thanks in advance,
-franco

franco@bbn.com
franco%bbn.com@relay.cs.net
...!harvard!bbn!franco































































hen dragging it
to a new place on the desktop(be it in a window or the desktop itself).

borscht@eleazar.Dartmouth.EDU (Andy J. Williams) (02/20/88)

[Fodder for Linear Digestius Insipidieous]

In article <20958@bbn.COM> franco@bbn.com (Frank A. Lonigro) writes:

>To all LSC users:
>	I'm new to programming the MAC and have a request.  Could some
>of you send me your favorite piece of code for choosing and dragging
>ICONs with the mouse(not the whole program, just that section of code).


I need to do the same thing if LightSpeed Pascal.  I am trying to set up an
environment which is very like the finder.  Anyone have snatches of code for
scrolling, clicking, and Masking icons?  (NOTE: ICON not ICN#)


>	Any and all help you can give would be greatly appreciated.
>
>Thanks in advance,
>-franco

Thanks from me too.
-Andy

-- 
Andy J. Williams    |_   /| |BITNET: borscht@eleazar.dartmouth.edu
HB 509 Dartmouth Clg|\`o_O' |UUCP: {ihnp4,decvax,linus}!dartvax!eleazar!borscht
Hanover, NH 03775   |  ( )  |_ DISCLAIMER: You better like my opinions,
603-643-7727        |   U ACK!|            my mother can beat up your mother...

smethers@psu-cs.UUCP (Paul Smethers) (02/22/88)

In article <8196@eleazar.Dartmouth.EDU> borscht@eleazar.Dartmouth.EDU (Andy J. Williams) writes:
>[Fodder for Linear Digestius Insipidieous]
>
>In article <20958@bbn.COM> franco@bbn.com (Frank A. Lonigro) writes:
>
>>To all LSC users:
>>	I'm new to programming the MAC and have a request.  Could some
>>of you send me your favorite piece of code for choosing and dragging
>>ICONs with the mouse(not the whole program, just that section of code).
>
>
>I need to do the same thing if LightSpeed Pascal.  I am trying to set up an
>environment which is very like the finder.  Anyone have snatches of code for
>scrolling, clicking, and Masking icons?  (NOTE: ICON not ICN#)

I haven't done the exact code that you are looking for, but I might be able
to guide you in the right direction.

First of all, to perform operations on the desktop (which is against Apple's
user interface standards in the first place), you have to work in the desktop's
window manager port, which is the port you get if you call GetWMgrPort() the
first thing after initializing your Inside Mac managers.  I'm not sure, but
pretty sure that this port can then be used by DragGrayRgn() which is
documented in the Window Manager of Inside Macintosh.

I wish I had the exact code for you, but if you follow up on these two leads
then you may be able to figure out how to drag icons on the desktop.  If these
fail, then you may try using a separate window for each icon, and using
DragWindow to move them if they are pressed on.  I'm not sure, but it might be
that DragWindow will work for plainDBox windows to move them from their
content area (you might try it and get back to me, I'd be curious).

Good Luck.

Paul Smethers
SmethersBarnes