00001
00002
00003
00004
00005 #include "DragnDrop.h"
00006
00007 extern void GetCurrentPrompt(char *CurrentPrompt);
00008 extern int StoreCommand( char *command);
00009 extern BOOL IsToThePrompt(void);
00010
00011 BOOL LaunchFilebyExtension(char *File);
00012
00013 void DragFunc (LPTW lptw, HDROP hdrop)
00014 {
00015 static char szFile[MAX_PATH];
00016 int i, cFiles;
00017
00018 cFiles = DragQueryFile (hdrop, 0xffffffff, (LPSTR) NULL, 0);
00019
00020 lptw->bGetCh =FALSE;
00021
00022 for (i = 0; i < cFiles; i++)
00023 {
00024 DragQueryFile (hdrop, i, szFile, MAX_PATH);
00025 LaunchFilebyExtension(szFile);
00026 }
00027 DragFinish (hdrop);
00028 }
00029
00030 BOOL LaunchFilebyExtension(char *File)
00031 {
00032 BOOL bOK=FALSE;
00033 char save_prompt[10];
00034 char *CommandLine=NULL;
00035 char *ExtensionFilename=NULL;
00036
00037 ExtensionFilename=PathFindExtension(File);
00038 GetCurrentPrompt(save_prompt);
00039
00040 if ( (_stricmp(ExtensionFilename,".bin")==0) || (_stricmp(ExtensionFilename,".sav")==0) )
00041 {
00042 bOK=TRUE;
00043 CommandLine=(char*)MALLOC( (strlen(File)+strlen("load('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
00044 if (IsToThePrompt())
00045 wsprintf(CommandLine,"load('%s');printf('\n%s');",File,save_prompt);
00046 else
00047 wsprintf(CommandLine,"load('%s');",File);
00048 }
00049 else
00050 if ( (_stricmp(ExtensionFilename,".graph")==0) || (_stricmp(ExtensionFilename,".graphb")==0) )
00051 {
00052 bOK=TRUE;
00053 CommandLine=(char*)MALLOC( (strlen(File)+strlen("edit_graph('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
00054 if (IsToThePrompt())
00055 wsprintf(CommandLine,"edit_graph('%s');printf('\n%s');",File,save_prompt);
00056 else
00057 wsprintf(CommandLine,"edit_graph('%s');",File);
00058 }
00059 else
00060 if ( (_stricmp(ExtensionFilename,".cos")==0) || (_stricmp(ExtensionFilename,".cosf")==0) )
00061 {
00062 bOK=TRUE;
00063 CommandLine=(char*)MALLOC( (strlen(File)+strlen("scicos('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
00064 if (IsToThePrompt())
00065 wsprintf(CommandLine,"scicos('%s');printf('\n%s');",File,save_prompt);
00066 else
00067 wsprintf(CommandLine,"scicos('%s');printf('%s');",File);
00068 }
00069 else
00070 if (_stricmp(ExtensionFilename,".sci")==0)
00071 {
00072 bOK=TRUE;
00073 CommandLine=(char*)MALLOC( (strlen(File)+strlen("getf('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
00074 if (IsToThePrompt())
00075 wsprintf(CommandLine,"getf('%s');printf('\n%s');",File,save_prompt);
00076 else
00077 wsprintf(CommandLine,"getf('%s');",File);
00078 }
00079 else
00080 if ( (_stricmp(ExtensionFilename,".sce")==0) || (_stricmp(ExtensionFilename,".tst")==0) || (_stricmp(ExtensionFilename,".dem")==0) )
00081 {
00082 bOK=TRUE;
00083 CommandLine=(char*)MALLOC( (strlen(File)+strlen("exec('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
00084 if (IsToThePrompt())
00085 wsprintf(CommandLine,"exec('%s');printf('\n%s');",File,save_prompt);
00086 else
00087 wsprintf(CommandLine,"exec('%s');",File);
00088 }
00089 else
00090 if (_stricmp(ExtensionFilename,".scg")==0)
00091 {
00092 bOK=TRUE;
00093 CommandLine=(char*)MALLOC( (strlen(File)+strlen("xload('%s');printf('\n%s');")+strlen(save_prompt))*sizeof(char) );
00094 if (IsToThePrompt())
00095 wsprintf(CommandLine,"xload('%s');printf('\n%s');",File,save_prompt);
00096 else
00097 wsprintf(CommandLine,"xload('%s');",File);
00098 }
00099 else
00100 {
00101 CommandLine=(char*)MALLOC( (strlen(File)+strlen("disp('unknown file type : %s\n');printf('%s');")+strlen(save_prompt))*sizeof(char) );
00102 if (IsToThePrompt())
00103 wsprintf(CommandLine,"disp('unknown file type : %s\n');printf('%s');",ExtensionFilename,save_prompt);
00104 else
00105 wsprintf(CommandLine,"disp('unknown file type : %s\n');",ExtensionFilename);
00106
00107 bOK=FALSE;
00108 }
00109
00110 StoreCommand(CommandLine);
00111 if (CommandLine) {FREE(CommandLine);CommandLine=NULL;}
00112
00113 FREE(ExtensionFilename);
00114 return bOK;
00115
00116 }
00117
00118