1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
/*-----------------------------------------------------------------------------------*/
/* INRIA 2005 */
/* Allan CORNET */
/*-----------------------------------------------------------------------------------*/
#include "DragnDrop.h"
/*-----------------------------------------------------------------------------------*/
extern void GetCurrentPrompt(char *CurrentPrompt);
extern int StoreCommand( char *command);
extern BOOL IsToThePrompt(void);
extern LPTSTR ScilabPathFindExtension(LPCTSTR pPath);
/*-----------------------------------------------------------------------------------*/
BOOL LaunchFilebyExtension(char *File);
/*-----------------------------------------------------------------------------------*/
void DragFunc (LPTW lptw, HDROP hdrop)
{
static char szFile[MAX_PATH];
int i, cFiles;
cFiles = DragQueryFile (hdrop, 0xffffffff, (LPSTR) NULL, 0);
lptw->bGetCh =FALSE;
for (i = 0; i < cFiles; i++)
{
DragQueryFile (hdrop, i, szFile, MAX_PATH);
LaunchFilebyExtension(szFile);
}
DragFinish (hdrop);
}
/*-----------------------------------------------------------------------------------*/
BOOL LaunchFilebyExtension(char *File)
{
BOOL bOK=FALSE;
char save_prompt[10];
char *CommandLine=NULL;
char *ExtensionFilename=NULL;
ExtensionFilename=ScilabPathFindExtension(File);
GetCurrentPrompt(save_prompt);
if ( (_stricmp(ExtensionFilename,".bin")==0) || (_stricmp(ExtensionFilename,".sav")==0) )
{
bOK=TRUE;
CommandLine=(char*)MALLOC( (strlen(File)+strlen("load('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
if (IsToThePrompt())
wsprintf(CommandLine,"load('%s');printf('\n%s');",File,save_prompt);
else
wsprintf(CommandLine,"load('%s');",File);
}
else
if ( (_stricmp(ExtensionFilename,".graph")==0) || (_stricmp(ExtensionFilename,".graphb")==0) )
{
bOK=TRUE;
CommandLine=(char*)MALLOC( (strlen(File)+strlen("edit_graph('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
if (IsToThePrompt())
wsprintf(CommandLine,"edit_graph('%s');printf('\n%s');",File,save_prompt);
else
wsprintf(CommandLine,"edit_graph('%s');",File);
}
else
if ( (_stricmp(ExtensionFilename,".cos")==0) || (_stricmp(ExtensionFilename,".cosf")==0) )
{
bOK=TRUE;
CommandLine=(char*)MALLOC( (strlen(File)+strlen("scicos('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
if (IsToThePrompt())
wsprintf(CommandLine,"scicos('%s');printf('\n%s');",File,save_prompt);
else
wsprintf(CommandLine,"scicos('%s');printf('%s');",File);
}
else
if (_stricmp(ExtensionFilename,".sci")==0)
{
bOK=TRUE;
CommandLine=(char*)MALLOC( (strlen(File)+strlen("getf('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
if (IsToThePrompt())
wsprintf(CommandLine,"getf('%s');printf('\n%s');",File,save_prompt);
else
wsprintf(CommandLine,"getf('%s');",File);
}
else
if ( (_stricmp(ExtensionFilename,".sce")==0) || (_stricmp(ExtensionFilename,".tst")==0) || (_stricmp(ExtensionFilename,".dem")==0) )
{
bOK=TRUE;
CommandLine=(char*)MALLOC( (strlen(File)+strlen("exec('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
if (IsToThePrompt())
wsprintf(CommandLine,"exec('%s');printf('\n%s');",File,save_prompt);
else
wsprintf(CommandLine,"exec('%s');",File);
}
else
if (_stricmp(ExtensionFilename,".scg")==0)
{
bOK=TRUE;
CommandLine=(char*)MALLOC( (strlen(File)+strlen("xload('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
if (IsToThePrompt())
wsprintf(CommandLine,"xload('%s');printf('\n%s');",File,save_prompt);
else
wsprintf(CommandLine,"xload('%s');",File);
}
else
{
CommandLine=(char*)MALLOC( (strlen(File)+strlen("disp('unknown file type : %s\n');printf('%s');")+strlen(save_prompt))*sizeof(char) );
if (IsToThePrompt())
wsprintf(CommandLine,"disp('unknown file type : %s\n');printf('%s');",ExtensionFilename,save_prompt);
else
wsprintf(CommandLine,"disp('unknown file type : %s\n');",ExtensionFilename);
bOK=FALSE;
}
StoreCommand(CommandLine);
if (CommandLine) {FREE(CommandLine);CommandLine=NULL;}
FREE(ExtensionFilename);
return bOK;
}
/*-----------------------------------------------------------------------------------*/
|