home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / PMFLOPPY.ZIP / COPYDLGS.C next >
C/C++ Source or Header  |  1990-04-23  |  5KB  |  212 lines

  1. #define INCL_PM
  2. #define INCL_DOSERRORS
  3. #define INCL_BASE
  4. #include <os2.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "pmfloppy.h"
  8.  
  9.  
  10.  
  11. // prototypes
  12. MRESULT EXPENTRY ReadDlgProc(HWND, USHORT, MPARAM, MPARAM);
  13. MRESULT EXPENTRY WriteDlgProc(HWND, USHORT, MPARAM, MPARAM);
  14. MRESULT EXPENTRY FmtDlgProc(HWND, USHORT, MPARAM, MPARAM);
  15. MRESULT EXPENTRY AboutDlgProc(HWND, USHORT, MPARAM, MPARAM);
  16. MRESULT EXPENTRY QuitDlgProc(HWND, USHORT, MPARAM, MPARAM);
  17.  
  18.  
  19. // User response vbls
  20. extern USHORT DriveActive;       // Bit map indicating active drives
  21. extern USHORT FormatOptions;     // Bit map indicating formatting choice
  22. extern USHORT usReadDrive;       // Drive to read from (from dialog box)
  23. extern CHAR   szReadDrive[];     // Drive to read from (from dialog box)
  24. extern USHORT usWriteDrive;      // Drive to write to (from dialog box)
  25. extern CHAR   szWriteDrive[];    // Drive to write to (from dialog box)
  26. extern USHORT usFmtDrive;        // Drive to format (from dialog box)
  27. extern CHAR   szFmtDrive[];      // Drive to format (from dialog box)
  28. extern CHAR   Volume[11];        // Volume Name
  29.  
  30.  
  31. //  ReadDlgProc  --  Disk Read dialog procedure.
  32. //
  33. //  Output:  ReadDrive  --  Global name of selected drive
  34. MRESULT CALLBACK ReadDlgProc(HWND hwnd, USHORT id, MPARAM mp1, MPARAM mp2)
  35. {
  36.  
  37.   switch (id)
  38.     {
  39.     case WM_INITDLG:
  40.       usReadDrive = IDD_DRV_A;
  41.       return 0;
  42.  
  43.     case WM_CONTROL:  // get the button that was clicked
  44.       usReadDrive = SHORT1FROMMP(mp1);
  45.       szReadDrive[0] = (CHAR)usReadDrive + 'A' - (CHAR)1;
  46.         return(0);
  47.  
  48.     case WM_COMMAND:
  49.       switch (COMMANDMSG(&id)->cmd)
  50.           {
  51.           case IDD_START:
  52.           WinDismissDlg(hwnd, TRUE);
  53.           return(0);
  54.  
  55.         case IDD_CANCEL:
  56.           usReadDrive = 0;
  57.             WinDismissDlg(hwnd, FALSE);
  58.           return(0);
  59.       } // switch on commandID
  60.         break;
  61.     } // switch on msgID
  62.  
  63.   return(WinDefDlgProc(hwnd, id, mp1, mp2));
  64. } // ReadDlgProc
  65.  
  66.  
  67. //  FmtDlgProc  --  Disk Format dialog procedure.
  68. //
  69. //  Output:  FmtDrive  --  Global name of selected drive
  70. MRESULT CALLBACK FmtDlgProc(HWND hwnd, USHORT id, MPARAM mp1, MPARAM mp2)
  71. {
  72.  
  73.   switch (id)
  74.     {
  75.     case WM_INITDLG:
  76.       usFmtDrive = IDD_DRV_A;
  77.       return 0;
  78.  
  79.     case WM_CONTROL:  // get the button that was clicked
  80.       usFmtDrive = SHORT1FROMMP(mp1);
  81.       szFmtDrive[0] = (CHAR)usFmtDrive + 'A' - (CHAR)1;
  82.         return(0);
  83.  
  84.     case WM_COMMAND:
  85.       switch (COMMANDMSG(&id)->cmd)
  86.           {
  87.           case IDD_START:
  88.           WinQueryDlgItemText(hwnd, IDD_FMT_VOLUME, sizeof Volume, Volume);
  89.           WinDismissDlg(hwnd, TRUE);
  90.           return(0);
  91.  
  92.         case IDD_CANCEL:
  93.           usFmtDrive = 0;
  94.             WinDismissDlg(hwnd, FALSE);
  95.           return(0);
  96.  
  97.       } // switch on commandID
  98.         break;
  99.     } // switch on msgID
  100.  
  101.   return(WinDefDlgProc(hwnd, id, mp1, mp2));
  102. } // FmtDlgProc
  103.  
  104.  
  105. //  WriteDlgProc  --  Disk Write dialog procedure.
  106. //
  107. //  Output:  WriteDrive  --  Global name of selected drive
  108. MRESULT CALLBACK WriteDlgProc(HWND hwnd, USHORT id, MPARAM mp1, MPARAM mp2)
  109. {
  110. HWND hAWnd;
  111. HWND hBWnd;
  112.  
  113.   switch (id)
  114.     {
  115.     case WM_INITDLG:
  116.       hAWnd = WinWindowFromID(hwnd,IDD_DRV_A);
  117.       if (DriveActive & IDD_DRV_A)
  118.         WinEnableWindow(hAWnd,FALSE);
  119.       else
  120.         WinEnableWindow(hAWnd,TRUE);
  121.  
  122.       hBWnd = WinWindowFromID(hwnd,IDD_DRV_B);
  123.       if (DriveActive & IDD_DRV_B)
  124.         WinEnableWindow(hBWnd,FALSE);
  125.       else
  126.         WinEnableWindow(hBWnd,TRUE);
  127.  
  128.       WinSendDlgItemMsg(hwnd, IDD_WRF_MAYBE, BM_SETCHECK,
  129.         MPFROMSHORT(1), NULL);
  130.       FormatOptions = IDD_WRF_MAYBE;
  131.       usWriteDrive = IDD_DRV_A;
  132.       return(0);
  133.  
  134.     case WM_CONTROL:  // get the button that was clicked
  135.       if ((SHORT1FROMMP(mp1) == IDD_DRV_A) ||
  136.           (SHORT1FROMMP(mp1) == IDD_DRV_B))
  137.       {
  138.         usWriteDrive = SHORT1FROMMP(mp1);
  139.         szWriteDrive[0] = (CHAR)usWriteDrive + 'A' - (CHAR)1;
  140.       }
  141.       else
  142.         FormatOptions = SHORT1FROMMP(mp1);
  143.         return(0);
  144.  
  145.     case WM_COMMAND:
  146.       switch (COMMANDMSG(&id)->cmd)
  147.           {
  148.           case IDD_START:
  149.           WinDismissDlg(hwnd, TRUE);
  150.           return(0);
  151.  
  152.         case IDD_CANCEL:
  153.           usWriteDrive = 0;
  154.             WinDismissDlg(hwnd, FALSE);
  155.           return(0);
  156.       } // switch on commandID
  157.         break;
  158.     } // switch on msgID
  159.  
  160.   return(WinDefDlgProc(hwnd, id, mp1, mp2));
  161. } // WriteDlgProc
  162.  
  163.  
  164. //  AboutDlgProc  --  About box dialog procedure.
  165. //
  166. MRESULT CALLBACK AboutDlgProc(HWND hwnd, USHORT id, MPARAM mp1, MPARAM mp2)
  167. {
  168.  
  169.   switch (id)
  170.     {
  171.     case WM_COMMAND:
  172.       switch (COMMANDMSG(&id)->cmd)
  173.           {
  174.           case DID_OK:
  175.         case DID_CANCEL:
  176.             WinDismissDlg(hwnd, TRUE);
  177.           return 0;
  178.       } // switch on commandID
  179.         break;
  180.     } // switch on msgID
  181.  
  182.   return(WinDefDlgProc(hwnd, id, mp1, mp2));
  183. } // AboutDlgProc
  184.  
  185.  
  186. //  QuitDlgProc  --  Quit prompt dialog procedure.
  187. //
  188. MRESULT CALLBACK QuitDlgProc(HWND hwnd, USHORT id, MPARAM mp1, MPARAM mp2)
  189. {
  190.  
  191.   switch (id)
  192.     {
  193.     case WM_COMMAND:
  194.       switch (COMMANDMSG(&id)->cmd)
  195.           {
  196.           case IDD_START:
  197.             WinDismissDlg(hwnd, TRUE);
  198.           return 0;
  199.  
  200.         case IDD_CANCEL:
  201.             WinDismissDlg(hwnd, FALSE);
  202.           return 0;
  203.       } // switch on commandID
  204.         break;
  205.     } // switch on msgID
  206.  
  207.   return(WinDefDlgProc(hwnd, id, mp1, mp2));
  208. } // QuitDlgProc
  209.  
  210.  
  211.  
  212.