|
|
Add a “DataLoad” event-handler
When a file is dragged from a Filer display onto an object belonging to the application the PROCDealWith_DataLoad event-handler is called. The pathname and type of the file are given in the arguments of this procedure.
The following definition of this event-handler loads a dragged drawfile into memory and forces the window to be redrawn. Notice the use of the method PROCWindow_WimpToToolbox to convert the Wimp handle of the window to its Toolbox id.
DEF PROCDealWith_DataLoad(file$,filetype%,window,icon)
IF filetype%=&AFF THEN
PROCLoadFile(file$,maxlength)
PROCWindow_WimpToToolbox(window,icon)
PROCForceRedraw(window)
ENDIF
ENDPROC
DEF PROCForceRedraw(window_id)
LOCAL x,y,X,Y
PROCWindow_GetExtent(window_id,x,y,X,Y)
PROCWindow_ForceRedraw(window_id,x,y,X,Y)
ENDPROC
|

At this stage of application development, drawfiles dragged from the Filer onto the window will be loaded and displayed. However, files dragged directly from another application (e.g. !Draw) onto the window will produce no response.
|
|
|
Add a “DataSave” event-handler
Files dragged from another application call the DataSave event-handler. All that needs to be done is to reply to a DataSave message by calling the PROCData_SendVia method to say what file should be used as an intermediary carrier for the file (usually Wimp$Scrap). The sending application will save its file to this intermediary and then the event-handler PROCDealWith_DataLoad will be called.
DEF PROCDealWith_DataSave(file$,filetype%,window,icon)
IF filetype%=&AFF THEN PROCData_SendVia("<Wimp$Scrap>")
ENDPROC
|
|