home *** CD-ROM | disk | FTP | other *** search
/ CICA 1994 September / CICA_Shareware_for_Windows_Walnut_Creek_September_1994.iso / win3 / programr / atre27.exe / ATREE_27 / LFWIN / FILEDLG.C < prev    next >
C/C++ Source or Header  |  1992-08-01  |  6KB  |  147 lines

  1. /*****************************************************************************
  2.  ****                                                                     ****
  3.  **** filedlg.c                                                           ****
  4.  ****                                                                     ****
  5.  **** atree release 2.7 for Windows                                       ****
  6.  **** Adaptive Logic Network (ALN) simulation program.                    ****
  7.  **** Copyright (C) A. Dwelly, R. Manderscheid, M. Thomas, W.W. Armstrong ****
  8.  ****               1991, 1992                                            ****
  9.  ****                                                                     ****
  10.  **** License:                                                            ****
  11.  **** A royalty-free license is granted for the use of this software for  ****
  12.  **** NON_COMMERCIAL PURPOSES ONLY. The software may be copied and/or     ****
  13.  **** modified provided this notice appears in its entirety and unchanged ****
  14.  **** in all derived source programs.  Persons modifying the code are     ****
  15.  **** requested to state the date, the changes made and who made them     ****
  16.  **** in the modification history.                                        ****
  17.  ****                                                                     ****
  18.  **** Patent License:                                                     ****
  19.  **** The use of a digital circuit which transmits a signal indicating    ****
  20.  **** heuristic responsibility is protected by U. S. Patent 3,934,231     ****
  21.  **** and others assigned to Dendronic Decisions Limited of Edmonton,     ****
  22.  **** W. W. Armstrong, President.  A royalty-free license is granted      ****
  23.  **** by the company to use this patent for NON_COMMERCIAL PURPOSES to    ****
  24.  **** adapt logic trees using this program and its modifications.         ****
  25.  ****                                                                     ****
  26.  **** Limited Warranty:                                                   ****
  27.  **** This software is provided "as is" without warranty of any kind,     ****
  28.  **** either expressed or implied, including, but not limited to, the     ****
  29.  **** implied warrantees of merchantability and fitness for a particular  ****
  30.  **** purpose.  The entire risk as to the quality and performance of the  ****
  31.  **** program is with the user.  Neither the authors, nor the             ****
  32.  **** University of Alberta, its officers, agents, servants or employees  ****
  33.  **** shall be liable or responsible in any way for any damage to         ****
  34.  **** property or direct personal or consequential injury of any nature   ****
  35.  **** whatsoever that may be suffered or sustained by any licensee, user  ****
  36.  **** or any other party as a consequence of the use or disposition of    ****
  37.  **** this software.                                                      ****
  38.  **** Modification history:                                               ****
  39.  ****                                                                     ****
  40.  **** 91.05.20 Initial implementation, M. Thomas                          ****
  41.  **** 91.07.17 atree v2.0 for Windows, M. Thomas                          ****
  42.  **** 92.04.27 atree v2.5 for Windows, M. Thomas                          ****
  43.  **** 92.03.07 Release 2.6, Monroe Thomas                                 ****
  44.  **** 92.01.08 Release 2.7, Monroe Thomas                                 ****
  45.  ****                                                                     ****
  46.  *****************************************************************************/
  47.  
  48. #include <windows.h>
  49. #include "commdlg.h"
  50.  
  51. LPSTR lstrchr  (LPSTR str, char ch);
  52. LPSTR lstrrchr (LPSTR str, char ch);
  53.  
  54. int DoFileOpenDlg (HWND hwnd, LPSTR szFileName)
  55. {
  56.     OPENFILENAME ofn;
  57.     BOOL nResult;
  58.  
  59.     memset(&ofn, 0, sizeof(OPENFILENAME));
  60.  
  61.     ofn.lStructSize = sizeof(OPENFILENAME);
  62.     ofn.hwndOwner = hwnd;
  63.     ofn.lpstrFilter = "LF Files(*.LF)\0*.lf\0LF Output Files(*.OUT)\0*.out\0All Files(*.*)\0*.*\0";
  64.     ofn.nFilterIndex = 1;
  65.     ofn.lpstrFileTitle = (LPSTR)szFileName;
  66.     ofn.nMaxFileTitle = 127;
  67.     ofn.Flags = OFN_CREATEPROMPT;
  68.     ofn.lpstrDefExt = "LF";
  69.  
  70.     nResult = GetOpenFileName(&ofn);
  71.     return (nResult);
  72. }
  73.  
  74. int DoFileSaveDlg (HWND hwnd, LPSTR szFileName)
  75. {
  76.     OPENFILENAME ofn;
  77.     BOOL nResult;
  78.     char szFile[128];
  79.  
  80.     lstrcpy(szFile, szFileName);
  81.  
  82.     memset(&ofn, 0, sizeof(OPENFILENAME));
  83.  
  84.     ofn.lStructSize = sizeof(OPENFILENAME);
  85.     ofn.hwndOwner = hwnd;
  86.     ofn.lpstrFilter = "LF Files(*.LF)\0*.lf\0LF Output Files(*.OUT)\0*.out\0All Files(*.*)\0*.*\0";
  87.     ofn.nFilterIndex = 1;
  88.     ofn.lpstrFile = (LPSTR)szFile;
  89.     ofn.nMaxFile = 127;
  90.     ofn.lpstrFileTitle = (LPSTR)szFileName;
  91.     ofn.nMaxFileTitle = 127;
  92.     ofn.Flags = OFN_OVERWRITEPROMPT;
  93.     ofn.lpstrDefExt = "LF";
  94.      
  95.     nResult = GetSaveFileName(&ofn);
  96.     return (nResult);
  97. }
  98.  
  99. int DoOutFileDlg (HWND hwnd, LPSTR szFileName)
  100. {
  101.     OPENFILENAME ofn;
  102.     BOOL nResult;
  103.     char szFile[128];
  104.  
  105.     lstrcpy(szFile, szFileName);
  106.  
  107.     memset(&ofn, 0, sizeof(OPENFILENAME));
  108.  
  109.     ofn.lStructSize = sizeof(OPENFILENAME);
  110.     ofn.hwndOwner = hwnd;
  111.     ofn.lpstrFilter = "LF Output Files(*.OUT)\0*.out\0Text Files(*.TXT)\0*.txt\0All Files(*.*)\0*.*\0";
  112.     ofn.nFilterIndex = 1;
  113.     ofn.lpstrFile = (LPSTR)szFile;
  114.     ofn.nMaxFile = 127;
  115.     ofn.lpstrFileTitle = (LPSTR)szFileName;
  116.     ofn.nMaxFileTitle = 127;
  117.     ofn.Flags = OFN_OVERWRITEPROMPT;
  118.     ofn.lpstrDefExt = "OUT";
  119.      
  120.     nResult = GetSaveFileName(&ofn);
  121.     return (nResult);
  122. }
  123.  
  124. LPSTR lstrchr (LPSTR str, char ch)
  125. {
  126.   while (*str)
  127.   {
  128.     if (ch == *str) return str;
  129.     str = AnsiNext(str);
  130.   }
  131.   return NULL;
  132. }
  133.  
  134. LPSTR lstrrchr (LPSTR str, char ch)
  135. {
  136.   LPSTR strl = str + lstrlen(str);
  137.  
  138.   do
  139.   {
  140.     if (ch == *strl) return strl;
  141.     strl = AnsiPrev(str, strl);
  142.     }
  143.     while (strl > str);
  144.  
  145.   return NULL;
  146. }
  147.