home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / lan / wbtrex.arj / DIALOGS.C < prev    next >
Text File  |  1979-12-31  |  5KB  |  149 lines

  1. /***************************************************************************/
  2. /*                             T E A M - E D                               */
  3. /***************************************************************************/
  4. /*                                                                         */
  5. /* DIALOG.c                                                                */
  6. /*                                                                         */
  7. /*   DialogBox routines for sample MS-Windows application                  */
  8. /*                                                                         */
  9. /*   Routines - AboutBoxWindowProc                                         */
  10. /*              OpenFileBoxWindowProc                                      */
  11. /*              BtrvOpsListBoxWindowProc                                   */
  12. /*                                                                         */
  13. /***************************************************************************/
  14. /***************************************************************************/
  15. #include <windows.h>
  16. #include "sample.h"
  17. #include "extern.h"
  18.  
  19.  
  20. /* Btrieve DLL interface functions */
  21. extern int SHELLINIT (char far *);
  22. extern int BTRVINIT (char far *);
  23. extern int BTRVSTOP (void);
  24. extern unsigned BTRV (int, char far *, char far *, unsigned far *, char far *, int);
  25.  
  26.  
  27. BOOL far pascal AboutBoxWindowProc (HWND,unsigned,WORD,LONG);
  28. BOOL far pascal OpenFileBoxWindowProc (HWND,unsigned,WORD,LONG);
  29. BOOL far pascal BtrvOpsListBoxWindowProc (HWND,unsigned,WORD,LONG);
  30.  
  31.  
  32. BOOL FAR PASCAL AboutBoxWindowProc (hDlg, message, wParam, lParam)
  33.   HWND hDlg;
  34.   unsigned message;
  35.   WORD wParam;
  36.   LONG lParam;
  37. {
  38.   if (message == WM_COMMAND)
  39.   {
  40.      EndDialog (hDlg,TRUE);
  41.      return (TRUE);
  42.   }
  43.   else
  44.      if (message == WM_INITDIALOG)
  45.         return (TRUE);
  46.      else
  47.         return (FALSE);
  48. }
  49.  
  50.  
  51. BOOL FAR PASCAL OpenFileBoxWindowProc (hDlg, message, wParam, lParam)
  52.   HWND hDlg;
  53.   unsigned message;
  54.   WORD wParam;
  55.   LONG lParam;
  56. {
  57.   char msg[255];
  58.   int  bStat;
  59.  
  60.   switch (message)
  61.   {
  62.      case WM_INITDIALOG :
  63.           return (TRUE);
  64.  
  65.      case WM_COMMAND :
  66.        switch (wParam)
  67.        {
  68.           case IDOK:          /* retrieve file name and open it            */
  69.              if (GetDlgItemText (hDlg, SAMPLE_FILENAME, keyBuf, 255) == 0)
  70.                break;
  71.  
  72.              if ((posBlk = GlobalLock (hPosBlk)) == NULL)
  73.              {
  74.                  MessageBox (NULL, "ERROR - Could not lock POSBLK",
  75.                             " ERROR ", MB_OK);
  76.                  break;
  77.              }
  78.  
  79.              if (fileIsOpen)   /* Close previous file                      */
  80.                 BTRV (1, posBlk, dataBuf, &dataLen, keyBuf, 0);
  81.  
  82.              if (bStat = BTRV (0, posBlk, dataBuf, &dataLen, keyBuf, 0))
  83.              {
  84.                 fileIsOpen = FALSE;
  85.                 sprintf (msg, "*** Open failed ***\nFile: %s\nStatus = %d",
  86.                          keyBuf, bStat);
  87.                 MessageBox (hDlg, msg, " TEAM-ED ", MB_OK);
  88.              }
  89.              else
  90.                 fileIsOpen = TRUE;
  91.              GlobalUnlock (hPosBlk);
  92.              EndDialog (hDlg, TRUE);
  93.              return (TRUE);
  94.  
  95.           case IDCANCEL :
  96.              EndDialog (hDlg, TRUE);
  97.              return (TRUE);
  98.  
  99.           default :
  100.              return (FALSE);
  101.        }
  102.   }
  103.   return (FALSE);
  104. }
  105.  
  106.  
  107. BOOL FAR PASCAL BtrvOpsListBoxWindowProc (hDlg, message, wParam, lParam)
  108.   HWND hDlg;
  109.   unsigned message;
  110.   WORD wParam;
  111.   LONG lParam;
  112. {
  113.   int i;
  114.   switch (message)
  115.   {
  116.      case WM_INITDIALOG :               /* Fill listbox with operations and  */
  117.                                         /* set default position to Get First */
  118.           SendDlgItemMessage (hDlg, SAMPLE_OPLIST, LB_RESETCONTENT, 0, 0L);
  119.           for (i = 0; i < NUMFUN; ++i)
  120.              SendDlgItemMessage (hDlg, SAMPLE_OPLIST, LB_INSERTSTRING, i,
  121.                             (LONG) ((LPSTR) Operations[i]));
  122.           SendDlgItemMessage (hDlg, SAMPLE_OPLIST, LB_SETCURSEL, GET_FIRST, 0L);
  123.           op = OpCodes[GET_FIRST];
  124.           opNdx = GET_FIRST;
  125.           return (TRUE);
  126.  
  127.      case WM_COMMAND :
  128.        switch (wParam)
  129.        {
  130.           case SAMPLE_OPLIST:                     /* Get new operation code */
  131.              if (HIWORD (lParam) == LBN_SELCHANGE)
  132.              {
  133.                 opNdx = (WORD) SendDlgItemMessage (hDlg, SAMPLE_OPLIST, LB_GETCURSEL, 0, 0L);
  134.                 op = OpCodes[opNdx];
  135.              }
  136.             return (TRUE);
  137.  
  138.           case SAMPLE_OPCLOSE:
  139.             DestroyWindow (hDlg);
  140.             hDlgModeless = 0;
  141.             return (TRUE);
  142.  
  143.           default :
  144.              return (FALSE);
  145.        }
  146.   }
  147.   return (FALSE);
  148. }
  149.