How to create a filedrop icon?

6 posts / 0 new
Last post
walkero
walkero's picture
Offline
Last seen: 3 months 2 days ago
Joined: 2009-05-03 16:54
How to create a filedrop icon?

Some of the older applications have a feature where when it is running a filedrop icon appears on the workbench. Using that you can open files in the app by drag 'n dropping them at the icon. It is quite useful especially if the app is opened on a different screen. If I recall correctly, CodeBench does that as well.

I'd like to add that feature to one of my applications, but I don't know the logic of how this is working nor have I managed to find any info anywhere.

Has anyone done that before? Do you guys have any info to share or any documentation to point me to?

LyleHaze
LyleHaze's picture
Offline
Last seen: 1 year 4 months ago
Joined: 2011-05-26 03:58
Re: How to create a filedrop icon?

I have not done it myself, but you might look into the various Window class flags for "AppWindow", which allow reducing a window to an icon on the workbench.
I'll bet the file drop stuff begins there.

LyleHaze

msteed
msteed's picture
Offline
Last seen: 1 week 6 days ago
Joined: 2022-01-18 08:34
Re: How to create a filedrop icon?

@walkero

I think what you're looking for is Workbench's AddAppIcon(), which was designed specifically to support that sort of thing.

mlehto
mlehto's picture
Offline
Last seen: 1 year 4 months ago
Joined: 2022-10-29 10:52
Re: How to create a filedrop icon?

@Walkero

I crawled recently new and old probably intresting source-examples for this and that...

This was closest to appicon what I found for OS4.

https://wiki.amigaos.net/wiki/Workbench_Library

There is section "An appicon example".

Then there is one general programmable appicon source on aminet.net, DropBox1_1.lha, wich is probably not what you are searching for. It is anyway source for OS3.

http://aminet.net/package/dev/src/DropBox1_1

I'm personally at very beginnig to understand and learn C/Amiga-C.

OldFart
OldFart's picture
Offline
Last seen: 2 hours 33 min ago
Joined: 2010-11-30 14:09
Re: How to create a filedrop icon?

@Walkero
Hi,

When reading your post I think I know what you want and I applied it to my HexView utility. This one opens up on a screen of its own and leaves an icon on workbench for icons to be dropped on. So if my assumption is correct, then somehow I feel like being some kind of an expert in this field.

For this to implement you require a dedicated messageport that you listen to in your Wait()-cycle.
Next you need an icon to display on workbench for icons to be dropped on.
Addendum: When using a private screen, you must apply AddAppIcon()/RemoveAppIcon().
In your Wait()-cycle you need a section that gets triggered when a message appears on your dedicated port. And when that's the case, get that message. Check what kind of message you got (struct AppMessage). See workbench/workbench.h. It's the AppMessage type (am_Type) of AMTYPE_APPICON to look for.
Then check am_NumArgs for the number of arguments (= icons dropped) you've got, which may be 0 in which case you've simply clicked the icon. Anything more is the number of icons dropped. Do you expect only 1 icon or are more icons welcome? Check!
Next you may have to verify whether the icon dropped is of of the appropriate type: load the icon's disk object (struct DiskObject) from am_ArgList (note: wa_Lock and wa_Name. See workbench/startup.h) and check the DiskObject's do_Type against WBDISK and/or WBDRAWER and/or WBPROJECT and/or WBTOOL.
When WBPROJECT is the one you are after, then further investigation may be required as to the type or contents of the file. After all you may be only interested in, say, an IFF-file.
If everything matches you expectations, you can then proceed and perform your imagined medzjiq to the object dropped.

Success!

OldFart

walkero
walkero's picture
Offline
Last seen: 3 months 2 days ago
Joined: 2009-05-03 16:54
Re: How to create a filedrop icon?

Thank you for your replies guys. Now I have a good idea of what to do to implement that feature in one of my projects. Will let you know if there are issues or not.

Log in or register to post comments