Post by Alan Adams
Instead I want my application to ensure PipeDream is running, then use
DataSava and DataLoad messages to simulate draging a file to its iconbar
icon. This requires me, as far as I can see from the manuals, to know the
icon number and window handle. The window handle should be -2 I believe,
but how do I find the icon number.
I can find the task handle using Task_EnumerateTasks looking for the name.
The message protocol has an option to send the message to the task handle.
Do I need the icon number in this case? If not, what do I put in message
block fields 20 and 24 (and indeed 28 and 32 as well)?
I agree with the other replies suggesting you should seek an improvement in
PipeDream, or use the WindOpen module as suggested by druck, but in case
neither of these works out here are some otehr thoughts.
If you use Wimp_SendMessage with R2 set to PipeDream's task number then the
Message_DataLoad will reach PipeDream. The question is, what it will do with
it. (You don't need to start with Message_DataSave if you are loading a file
from disc. The Filer doesn't.)
The registers R2 and R3 in Wimp_SendMessage are used simply to determine
which tasks will receive the message. The contents of the message is
independent pf this. So you could fill in +20 with the window handle -2 as
though the file had been dropped on the icon bar. If you are lucky, that's
the only thing PipeDream will check -- unless it has two icons on the iconbar
it is not going to be bothered about the value in +24, and probably will not
examine +28 or +32 either.
Whether that would work entirely depends on PipeDream's implementation
details, and you cannot rely on this working for every application.
If you are wanting to find out the icon number of an application on the
iconbar, there is a trick you can use. This is employed within Impact. It's
code I inherited from John Skingley: I do not know whether it was his
original idea or whether this was a generally known technique.
First of all, determine how many icons there are on the iconbar by calling
Wimp_GetWindowInfo for the iconbar window, handle -2. Call the result n.
Then loop through the icon numbers (let i range from 0 to n-1) and for each
icon call Wimp_SendMessage with R0=19, R2=-2 and R3=i. Doesn't matter what
is in the message block but R1 had probably better be valid. As documented
in the PRM, using R0=19 when you're not actually acknowledging a message
allows the task handle to be found as on returning from Wimp_SendMessage the
value of R2 will be the task handle. For the iconbar this, unusually, will
vary from one icon to the next.
You can then use TaskManager_TaskNameFromHandle to look up the task name for
the icon, and if it's PipeDream, break out of the loop.