home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / ddjmag / ddj9103.zip / MEWEL.ASC < prev    next >
Text File  |  1991-02-15  |  20KB  |  670 lines

  1. _THE MEWEL WINDOW SYSTEM_
  2. by Al Stevens
  3.  
  4. [LISTING ONE]
  5.  
  6. /* ------------ memopad.h ------------- */
  7.  
  8. /* -------- window identifiers ----------- */
  9. #define ID_MAIN                1
  10. #define ID_MDICLIENT           2
  11. #define ID_EDITOR              3
  12. #define ID_FIRSTEDITOR       100
  13.  
  14. /* ------- menu command identifiers -------- */
  15. #define ID_NEWFILE             5
  16. #define ID_OPENFILE            6
  17. #define ID_SAVE                7
  18. #define ID_SAVEAS              8
  19. #define ID_PRINT               9
  20. #define ID_EXIT               10
  21.  
  22. #define IDM_WINDOWTILE        12
  23. #define IDM_WINDOWCASCADE     13
  24. #define IDM_WINDOWICONS       14
  25. #define IDM_WINDOWCLOSEALL    15
  26.  
  27. #define ID_HELP               99
  28.  
  29. /* -------- string identifiers --------- */
  30. #define IDS_TITLE              0
  31. #define IDS_HELP               1
  32. #define IDS_ERROR              2
  33. #define IDS_OVERWRITE          3
  34. #define IDS_WRITEERROR         4
  35. #define IDS_SELECTERROR        5
  36. #define IDS_NOFILE             6
  37. #define IDS_FORMFEED           7
  38. #define IDS_UNTITLED           8
  39.  
  40.  
  41. [LISTING TWO]
  42.  
  43. #include <style.h>
  44. #include "memopad.h"
  45.  
  46. #include "fileopen.dlg"
  47.  
  48. MPmenu MENU
  49. BEGIN
  50.     POPUP "~File"    
  51.     BEGIN
  52.         MENUITEM "~New",           ID_NEWFILE       SHADOW
  53.         MENUITEM "~Open...",       ID_OPENFILE
  54.         MENUITEM "~Save",          ID_SAVE
  55.         MENUITEM "Save ~As...",    ID_SAVEAS
  56.         MENUITEM SEPARATOR
  57.         MENUITEM "~Print",         ID_PRINT
  58.         MENUITEM SEPARATOR
  59.         MENUITEM "E~xit",          ID_EXIT
  60.     END
  61.     POPUP "~Window"
  62.     BEGIN
  63.         MENUITEM "~Tile",          IDM_WINDOWTILE    SHADOW
  64.         MENUITEM "~Cascade",       IDM_WINDOWCASCADE
  65.         MENUITEM "Arrange ~Icons", IDM_WINDOWICONS
  66.         MENUITEM "Close ~All",     IDM_WINDOWCLOSEALL
  67.     END
  68.     MENUITEM "~Help", ID_HELP HELP
  69. END
  70.  
  71. STRINGTABLE
  72. BEGIN
  73.     IDS_TITLE,         "MemoPad"
  74.     IDS_HELP,          
  75. "MemoPad is a multiple document\
  76. memo processor. You can have\
  77. several *.PAD documents open at\
  78. one time. It demonstrates the\
  79. MDI document feature of MEWEL."
  80.     IDS_ERROR,         "Error!"
  81.     IDS_OVERWRITE,     "Overwrite Existing File?"
  82.     IDS_WRITEERROR,    "Cannot write file"
  83.     IDS_SELECTERROR,   "Select an open document first"
  84.     IDS_NOFILE,        "No such file"
  85.     IDS_FORMFEED,      "Send a Form Feed?"
  86.     IDS_UNTITLED,      "Untitled"
  87. END
  88.  
  89.  
  90.  
  91. [LISTING THREE]
  92.  
  93. /* ------------ memopad.c -------------- */
  94.  
  95. #include <stdio.h>
  96. #include <stdlib.h>
  97. #include <window.h>
  98. #include <string.h>
  99. #include <sys\stat.h>
  100. #include <io.h>
  101. #include "memopad.h"
  102.  
  103. long FAR PASCAL FrameWndProc(HWND, WORD, WORD, DWORD);
  104. long FAR PASCAL EditorProc(HWND, WORD, WORD, DWORD);
  105. void NewFile(void);
  106. void SelectFile(void);
  107. void SaveFile(BOOL);
  108. void PrintPad(void);
  109. void OpenWindow(char *);
  110. void LoadFile(HWND, char *, int);
  111. void BuildEditor(HWND);
  112. HWND GetEditorHandle(void);
  113. int ErrorMessage(int);
  114.  
  115. char EditorClass[] = "Editor";
  116. char FrameClass[] = "FrameClass";
  117. char Untitled[26];
  118.  
  119. HWND hClient;
  120. HWND hEditor;
  121. HWND hFrame;
  122.  
  123. int hInstance;
  124.  
  125. void main(void)
  126. {
  127.     MSG event;
  128.     WNDCLASS wndclass;
  129.     CLIENTCREATESTRUCT ccs;
  130.     char Title[26];
  131.  
  132.     WinInit();
  133.     WinUseSysColors(NULLHWND, TRUE);
  134.     MDIInitialize();
  135.  
  136.     /* Register the Editor Document Window */
  137.     memset (&wndclass, 0, sizeof (wndclass));
  138.     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
  139.     wndclass.lpfnWndProc   = EditorProc ;
  140.     wndclass.lpszMenuName  = NULL;
  141.     wndclass.lpszClassName = EditorClass;
  142.     if (!RegisterClass (&wndclass))
  143.         exit(1);
  144.  
  145.     /* Register the Frame Window */
  146.     memset (&wndclass, 0, sizeof (wndclass));
  147.     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
  148.     wndclass.lpfnWndProc   = FrameWndProc ;
  149.     wndclass.lpszMenuName  = "MPMenu";
  150.     wndclass.lpszClassName = FrameClass;
  151.     if (!RegisterClass (&wndclass))
  152.         exit(1);
  153.  
  154.     /* Open the Resource File */
  155.     hInstance = OpenResourceFile("MEMOPAD");
  156.     LoadString(hInstance, IDS_UNTITLED, Untitled, 25);
  157.  
  158.     /* Create the frame window */
  159.     LoadString(hInstance, IDS_TITLE, Title, 25);
  160.     hFrame = CreateWindow(
  161.                          FrameClass,
  162.                          Title,
  163.                          WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN
  164.                             | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
  165.                          CW_USEDEFAULT,
  166.                          CW_USEDEFAULT,
  167.                          CW_USEDEFAULT,
  168.                          CW_USEDEFAULT,
  169.                          SYSTEM_COLOR,
  170.                          ID_MAIN,
  171.                          NULLHWND,
  172.                          NULLHWND,
  173.                          hInstance,
  174.                          (LPSTR) NULL
  175.                        );
  176.  
  177.     /* display the frame window */
  178.     ShowWindow(hFrame, SW_SHOW);
  179.  
  180.     /* create the MDI client window */
  181.     ccs.hWindowMenu = GetSubMenu(GetMenu(hFrame), 1);
  182.     ccs.idFirstChild = ID_FIRSTEDITOR;
  183.  
  184.     hClient = CreateWindow("mdiclient",
  185.                                   NULL,
  186.                                   WS_CHILD | WS_CLIPCHILDREN |
  187.                                         WS_CLIPSIBLINGS,
  188.                                   0,0,0,0,
  189.                                   SYSTEM_COLOR,
  190.                                   ID_MDICLIENT,
  191.                                   hFrame,
  192.                                   NULL,
  193.                                   hInstance,
  194.                                   (LPSTR) &ccs);
  195.     ShowWindow(hClient, SW_SHOW);
  196.  
  197.     /* set focus for keyboard users */
  198.     SetFocus(hFrame);
  199.  
  200.     /* message loop */
  201.     while (GetMessage(&event, NULLHWND, 0, 0))    {
  202.         TranslateMessage(&event);
  203.         DispatchMessage(&event);
  204.     }
  205.  
  206.     CloseResourceFile(hInstance);
  207.     exit(0);
  208. }
  209.  
  210. /* wndproc for the frame window */
  211. long FAR PASCAL FrameWndProc(HWND hWnd, WORD message,
  212.                                 WORD wParam, DWORD lParam)
  213. {
  214.     HWND hwndCheck;
  215.     char Hmsg[501];
  216.  
  217.     switch (message)    {
  218.         case WM_HELP:
  219.             LoadString(hInstance, IDS_HELP, Hmsg, 500);
  220.             MessageBox(hFrame, Hmsg, NULL, MB_OK);
  221.             break;
  222.         case WM_COMMAND:
  223.             switch (wParam)    {
  224.                 case ID_NEWFILE:
  225.                     NewFile();
  226.                     break;
  227.                 case ID_OPENFILE:
  228.                     SelectFile();
  229.                     break;
  230.                 case ID_SAVE:
  231.                     SaveFile(FALSE);
  232.                     break;
  233.                 case ID_SAVEAS:
  234.                     SaveFile(TRUE);
  235.                     break;
  236.                 case ID_PRINT:
  237.                     PrintPad();
  238.                     break;
  239.                 case ID_EXIT:
  240.                     PostQuitMessage(0);
  241.                     break;
  242.                 case IDM_WINDOWTILE:
  243.                     SendMessage(hClient,WM_MDITILE,0,0);
  244.                     break;
  245.                 case IDM_WINDOWCASCADE:
  246.                     SendMessage(hClient,WM_MDICASCADE,0,0);
  247.                     break;
  248.                 case IDM_WINDOWICONS:
  249.                     SendMessage(hClient,WM_MDIICONARRANGE,0,0);
  250.                     break;
  251.                 case IDM_WINDOWCLOSEALL:
  252.                     while ((hwndCheck =
  253.                             GetWindow(hClient, GW_CHILD))
  254.                                 != NULLHWND)
  255.                         SendMessage(hClient, WM_MDIDESTROY,
  256.                             hwndCheck, 0);
  257.                     break;
  258.                 default:
  259.                     break;
  260.             }
  261.             break;
  262.         default:
  263.             break;
  264.     }
  265.     return DefFrameProc(hWnd,hClient,message,wParam,lParam);
  266. }
  267.  
  268. /* The New command. Open an empty editor window */
  269. void NewFile(void)
  270. {
  271.     OpenWindow(Untitled);
  272. }
  273.  
  274. /* The Open... command. Select a file   */
  275. void SelectFile(void)
  276. {
  277.     char FileName[64];
  278.     if (DlgOpenFile(hFrame, "*.PAD", FileName))    {
  279.         HWND hWnd, hEditor;
  280.         /* test to see if the document is already open */
  281.         if ((hWnd = FindWindow(EditorClass, FileName))
  282.                                          != NULLHWND)    {
  283.             /* document is open, activate its window */
  284.             BringWindowToTop(hWnd);
  285.             OpenIcon(hWnd);
  286.             hEditor = GetTopWindow(hWnd);
  287.             SetFocus(hEditor);
  288.         }
  289.         else
  290.             OpenWindow(FileName);
  291.     }
  292. }
  293.  
  294. /* get the current active editor window handle  */
  295. HWND GetEditorHandle(void)
  296. {
  297.     HWND hCurEd;
  298.  
  299.     hCurEd = GetFocus();
  300.     if (!IsChild(hClient, GetParent(hCurEd)))
  301.         hCurEd = NULLHWND;
  302.     return hCurEd;
  303. }
  304.  
  305. /* Save the notepad file  */
  306. void SaveFile(BOOL SaveAs)
  307. {
  308.     char FileName[64];
  309.     HWND hCurEd, hEditor;
  310.     char *text;
  311.     FILE *fp;
  312.  
  313.     /*  get the handle of the active notepad editor window */
  314.     if ((hCurEd = GetEditorHandle()) != NULLHWND)    {
  315.         hEditor = GetParent(hCurEd);
  316.         /* --- get the editor window's file name --- */
  317.         GetWindowText(hEditor, FileName, 64);
  318.         /* get a name for untitled window or Save As command */
  319.         if (SaveAs || strcmp(FileName, Untitled) == 0)    {
  320.             if (!DlgOpenFile(hFrame, "*.PAD", FileName))
  321.                 return;
  322.             if (access(FileName, 0) == 0)    {
  323.                 char omsg[81];
  324.                 LoadString(hInstance, IDS_OVERWRITE, omsg, 80);
  325.                 if (MessageBox(hFrame, omsg,
  326.                             NULL, MB_YESNO) == IDNO)
  327.                     return;
  328.             }
  329.             SetWindowText(hEditor, FileName);
  330.         }
  331.         /* - get the address of the editor text - */
  332.         text = (char *) SendMessage(hCurEd, EM_GETHANDLE,0,0);
  333.         if ((fp = fopen(FileName, "wt")) != NULL)    {
  334.             fwrite(text, strlen(text), 1, fp);
  335.             fclose(fp);
  336.         }
  337.         else
  338.             ErrorMessage(IDS_WRITEERROR);
  339.     }
  340.     else
  341.         ErrorMessage(IDS_SELECTERROR);
  342. }
  343.  
  344. /* open a document window and load a file  */
  345. void OpenWindow(char *FileName)
  346. {
  347.     MDICREATESTRUCT mcs;
  348.     HWND hWnd, hEditor;
  349.     struct stat sb;
  350.  
  351.     if (strcmp(FileName, Untitled) && stat(FileName, &sb))    {
  352.         ErrorMessage(IDS_NOFILE);
  353.         return;
  354.     }
  355.  
  356.     mcs.szTitle = FileName;
  357.     mcs.szClass = EditorClass;
  358.     mcs.hOwner = hInstance;
  359.     mcs.lParam = NULL;
  360.     mcs.x = mcs.y = mcs.cy = mcs.cx = CW_USEDEFAULT;
  361.     mcs.style = WS_CLIPCHILDREN;
  362.  
  363.     /* tell the client window to create the document window */
  364.     hWnd = SendMessage(hClient, WM_MDICREATE, 0,
  365.                         (LONG) (LPMDICREATESTRUCT) &mcs);
  366.  
  367.     hEditor = GetTopWindow(hWnd);
  368.     SetFocus(hEditor);
  369.  
  370.     if (strcmp(FileName, Untitled))
  371.         LoadFile(hEditor, FileName, (int) sb.st_size);
  372. }
  373.  
  374. /* wndproc for the editor window  */
  375. long FAR PASCAL EditorProc(HWND hWnd, WORD message,
  376.                                 WORD wParam, DWORD lParam)
  377. {
  378.     RECT rc;
  379.     int rtn;
  380.  
  381.     switch (message)    {
  382.         case WM_SIZE:
  383.             /* Resize the edit control box. */
  384.             GetClientRect (hWnd, &rc);
  385.  
  386.             WinSetSize(GetTopWindow(hWnd),
  387.                 rc.bottom-rc.top+1,
  388.                 rc.right-rc.left+1);
  389.             break;
  390.         case WM_SETFOCUS:    {
  391.             rtn = DefMDIChildProc(hWnd,message,wParam,lParam);
  392.             /* Set the focus on the editor window */
  393.             SetFocus(GetTopWindow(hWnd));
  394.             return rtn;
  395.         }
  396.         case WM_CREATE:
  397.             /* create the file window's editor box */
  398.             BuildEditor(hWnd);
  399.             break;
  400.         default:
  401.             break;
  402.     }
  403.     return DefMDIChildProc(hWnd, message, wParam, lParam);
  404. }
  405.  
  406. /* Create the editor window  */
  407. void BuildEditor(HWND hWnd)
  408. {
  409.     CreateWindow(
  410.             "edit",
  411.             NULL,
  412.             WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | 
  413.                 ES_MULTILINE | ES_AUTOVSCROLL,
  414.             CW_USEDEFAULT,
  415.             CW_USEDEFAULT,
  416.             CW_USEDEFAULT,
  417.             CW_USEDEFAULT,
  418.             SYSTEM_COLOR,
  419.             ID_EDITOR,
  420.             hWnd,
  421.             NULLHWND,
  422.             hInstance,
  423.             (LPSTR) NULL);
  424. }
  425.  
  426. /* Load the notepad file into the editor text buffer  */
  427. void LoadFile(HWND hEditor, char *FileName, int tLen)
  428. {
  429.     int bfsize;
  430.     char *Buf;
  431.     FILE *fp;
  432.  
  433.     Buf = (char *)
  434.         SendMessage(hEditor, EM_GETHANDLE, 0, (long) &bfsize);
  435.     if (bfsize < tLen+1)    {
  436.         Buf = LocalReAlloc(Buf, tLen+1, 0);
  437.         SendMessage(hEditor, EM_SETHANDLE, tLen+1, (long) Buf);
  438.     }
  439.     if (Buf != NULL)    {
  440.         if ((fp = fopen(FileName, "rt")) != NULL)    {
  441.             memset (Buf, 0, tLen+1);
  442.             fread(Buf, tLen, 1, fp);
  443.             SendMessage(hEditor, WM_SETTEXT, 0, (long) Buf);
  444.             fclose(fp);
  445.         }
  446.     }
  447. }
  448.  
  449. /* print the current notepad  */
  450. void PrintPad(void)
  451. {
  452.     char FileName[64];
  453.     HWND hCurEd;
  454.  
  455.     if ((hCurEd = GetEditorHandle()) != NULLHWND)    {
  456.         char *text;
  457.         char msg[81];
  458.         HWND hEditor = GetParent(hCurEd);
  459.         /* --- get the editor window's file name --- */
  460.         GetWindowText(hEditor, FileName, 64);
  461.  
  462.         /* ---------- print the file name ---------- */
  463.         fputs("\r\n", stdprn);
  464.         fputs(FileName, stdprn);
  465.         fputs(":\r\n\n", stdprn);
  466.  
  467.         /* ---- get the address of the editor text ----- */
  468.         text = (char *) SendMessage(hCurEd, EM_GETHANDLE,0,0);
  469.  
  470.         /* ------- print the notepad text --------- */
  471.         while (*text)    {
  472.             if (*text == '\n')
  473.                 fputc('\r', stdprn);
  474.             fputc(*text++, stdprn);
  475.         }
  476.  
  477.         /* ------- follow with a form feed? --------- */
  478.         LoadString(hInstance, IDS_FORMFEED, msg, 80);
  479.         if (MessageBox(hFrame, msg, NULL, MB_YESNO) == IDYES)
  480.             fputc('\f', stdprn);
  481.     }
  482.     else
  483.         ErrorMessage(IDS_SELECTERROR);
  484. }
  485.  
  486. /* Error message handler  */
  487. int ErrorMessage(int ErrorNumber)
  488. {
  489.     char ErrorMsg[81];
  490.     char Error[26];
  491.  
  492.     LoadString(hInstance, ErrorNumber, ErrorMsg, 80);
  493.     LoadString(hInstance, IDS_ERROR, Error, 26);
  494.     MessageBeep(0);
  495.     return MessageBox(hFrame, ErrorMsg, Error, MB_OK);
  496. }
  497.  
  498.  
  499. [LISTING FOUR]
  500.  
  501. /* ------------ fileopen.h --------------- */
  502.  
  503. /* ------- file open dialog box identifiers --------- */
  504. #define ID_FILEOPEN           20
  505. #define ID_PATH               21
  506. #define ID_FILES              22
  507. #define ID_FILENAME           23
  508. #define ID_DRIVE              24
  509.  
  510.  
  511.  
  512. [LISTING SIX]
  513.  
  514. /* ----------- fileopen.c ------------- */
  515.  
  516. #include <window.h>
  517. #include <string.h>
  518. #include "fileopen.h"
  519.  
  520. static int pascal DlgFnOpen(HDLG, WORD, WORD, DWORD);
  521. static BOOL InitDlgBox(HDLG);
  522. static void StripPath(char *);
  523.  
  524. static char OrigSpec[80];
  525. static char FileSpec[80];
  526. static char FileName[80];
  527.  
  528. static int FileSelected;
  529.  
  530. #define HasWildCards(s) (strchr(s, '?') || strchr(s, '*'))
  531.  
  532. /* Dialog Box to select a file from the disk system  */
  533. int pascal DlgOpenFile(HWND hParent, BYTE *Fpath, BYTE *Fname)
  534. {
  535.     HDLG hDlg;
  536.     int  rtn;
  537.     extern int hInstance;
  538.  
  539.     hDlg = LoadDialog(hInstance, MAKEINTRESOURCE(ID_FILEOPEN),
  540.                 hParent, DlgFnOpen);
  541.     strncpy(FileSpec, Fpath, sizeof(FileSpec));
  542.     strcpy(OrigSpec, FileSpec);
  543.  
  544.     if ((rtn = DialogBox(hDlg)) == TRUE)
  545.         strcpy(Fname, FileName);
  546.     else
  547.         *Fname = '\0';
  548.  
  549.     return rtn;
  550. }
  551.  
  552. /* Process dialog box messages  */
  553. static int pascal DlgFnOpen(HDLG hDlg, WORD msg, WORD wParam,
  554.                                             DWORD lParam)
  555. {
  556.     switch (msg)    {
  557.         case WM_INITDIALOG:
  558.             if (!InitDlgBox(hDlg))
  559.                 EndDialog(hDlg, 0);
  560.             return TRUE;
  561.  
  562.         case WM_COMMAND:
  563.             switch (wParam)    {
  564.                 case ID_FILENAME:
  565.                     /* allow user to modify the file spec */
  566.                     GetDlgItemText(hDlg, ID_FILENAME,
  567.                             FileName, 64);
  568.                     if (HasWildCards(FileName))    {
  569.                         strcpy(OrigSpec, FileName);
  570.                         StripPath(OrigSpec);
  571.                     }
  572.                     break;
  573.                 case IDOK:
  574.                     if (HasWildCards(FileName))    {
  575.                         /* no file name yet */
  576.                         strcpy(FileSpec, FileName);
  577.                         if (InitDlgBox(hDlg))    {
  578.                             SetDlgItemText(hDlg, ID_FILENAME,
  579.                                                 FileSpec);
  580.                             strcpy(OrigSpec, FileSpec);
  581.                         }
  582.                     }
  583.                     else
  584.                         EndDialog(hDlg, 1);
  585.                     return TRUE;
  586.  
  587.                 case IDCANCEL:
  588.                     EndDialog(hDlg, 0);
  589.                     return TRUE;
  590.  
  591.                 case ID_FILES:
  592.                     switch (HIWORD(lParam))    {
  593.                         case LBN_SELCHANGE :
  594.                             /* selected a different filename */
  595.                             DlgDirSelect(hDlg, FileName,
  596.                                         ID_FILES);
  597.                             SetDlgItemText(hDlg, ID_FILENAME,
  598.                                             FileName);
  599.                             FileSelected = TRUE;
  600.                             break;
  601.                         case LBN_DBLCLK :
  602.                             /* chose a file name */
  603.                             DlgDirSelect(hDlg, FileName,
  604.                                     ID_FILES);
  605.                             EndDialog(hDlg, 1);
  606.                             return TRUE;
  607.                     }
  608.                     break;
  609.                 case ID_DRIVE:
  610.                     switch (HIWORD(lParam))    {
  611.                         case LBN_SELCHANGE :
  612.                             /* selected different drive/dir */
  613.                             DlgDirSelect(hDlg, FileName,
  614.                                                 ID_DRIVE);
  615.                             strcat(FileName, OrigSpec);
  616.                             strcpy(FileSpec, FileName);
  617.                             SetDlgItemText(hDlg, ID_FILENAME,
  618.                                                     FileSpec);
  619.                             break;
  620.                         case LBN_DBLCLK :
  621.                             /* chose drive/dir */
  622.                             if (InitDlgBox(hDlg))
  623.                             SetDlgItemText(hDlg, ID_FILENAME,
  624.                                                     FileSpec);
  625.                             else
  626.                                 strcpy(FileSpec, OrigSpec);
  627.                             return TRUE;
  628.                     }
  629.                     break;
  630.  
  631.                 default:
  632.                     break;
  633.             }
  634.     }
  635.     return FALSE;
  636. }
  637.  
  638. /* Initialize the dialog box  */
  639. static BOOL InitDlgBox(HDLG hDlg)
  640. {
  641.     FileSelected = FALSE;
  642.     SetDlgItemText(hDlg, ID_FILENAME, FileSpec);
  643.     if (!DlgDirList(hDlg, FileSpec, ID_FILES, ID_PATH, 0))
  644.         return FALSE;
  645.     /* MEWEL DlgDirList should do this, but does not */
  646.     StripPath(FileSpec);
  647.     return DlgDirList(hDlg, "*.*", ID_DRIVE, 0, 0xc010);
  648. }
  649.  
  650. /* Strip the drive and path information from a file spec  */
  651. static void StripPath(char *filespec)
  652. {
  653.     char *cp, *cp1;
  654.  
  655.     cp = strchr(filespec, ':');
  656.     if (cp != NULL)
  657.         cp++;
  658.     else
  659.         cp = filespec;
  660.     while (TRUE)    {
  661.         cp1 = strchr(cp, '\\');
  662.         if (cp1 == NULL)
  663.             break;
  664.         cp = cp1+1;
  665.     }
  666.     strcpy(filespec, cp);
  667. }
  668.  
  669.  
  670.