FILES.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX - Modelling, Animation and Rendering Package
00003 -- */
00004 
00005 
00006 /* file FILES.C */
00007 
00008 // This file also includes the program's main message loop plus code
00009 // to create and handle the main viewing windows.
00010 
00011 #define MODULE_FILES 1
00012 
00013 #include "design.h"
00014 
00015 int SelectFileName(int save, char *szfile, char *szdir,
00016                    char *szTitle, char *szfilter, HWND parent){
00017  int i;
00018  OPENFILENAME ofn;
00019  char szFilter[256],szdummy[MAX_FILE];
00020  szdummy[0]='\0';
00021  strcpy(szFilter,szfilter);
00022  i=0; while(szFilter[i] != '\0'){
00023    if(szFilter[i] == '|')szFilter[i]='\0'; i++;
00024  }
00025  memset(&ofn,0,sizeof(OPENFILENAME));
00026  ofn.lStructSize=sizeof(OPENFILENAME);
00027  ofn.hwndOwner=parent;
00028  ofn.lpstrFilter=szFilter;
00029  ofn.nFilterIndex=1;
00030  ofn.lpstrFile=szfile;              /* will contain file + path */
00031  ofn.nMaxFile=MAX_FILE;
00032  ofn.lpstrFileTitle=szdummy;         /* file name only */
00033  ofn.nMaxFileTitle=MAX_FILE;
00034  ofn.lpstrInitialDir=szdir;
00035  ofn.lpstrTitle=szTitle;
00036  if(parent == ghwnd_main)EnableToolPannels(ALL_PANNELS,FALSE);
00037  if(save){
00038   ofn.Flags=OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;
00039    i=(int)(GetSaveFileName(&ofn));
00040  }
00041  else{
00042   ofn.Flags=OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
00043    i=(int)(GetOpenFileName(&ofn));
00044  }
00045  if(parent == ghwnd_main)EnableToolPannels(ALL_PANNELS,TRUE);
00046  if(i){
00047    strcpy(szdummy,szfile);
00048    *AnsiPrev(szdummy,FileInPath(szdummy)) = '\0';
00049    strcpy(szdir,szdummy);
00050  }
00051    {MSG msg;  /* allow WM_COMMAND message to be processed */
00052     while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){
00053       TranslateMessage(&msg);
00054       DispatchMessage(&msg);
00055     }
00056    }
00057  return i;
00058 }
00059 
00060 int SelectSfxFileName(int save, char *szfile, char *szdir, long ID,
00061                       char *szfilter, HWND parent){
00062  char szTitle[256];
00063  LoadString(ghinst_main,ID,szTitle,255);
00064  return SelectFileName(save,szfile,szdir,szTitle,szfilter,parent);
00065 }

Generated on Sun Apr 27 14:20:08 2014 for OpenFX by  doxygen 1.5.6