home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Product / Product.zip / DBDEMO.ZIP / DEMOFLS.ZIP / DBDEMO.C < prev    next >
C/C++ Source or Header  |  1991-07-09  |  91KB  |  2,150 lines

  1. /************************************************************************/
  2. /* DATABASE PERFORMANCE CONCEPTS AND TECHNIQUE DEMONSTRATION PROGRAM    */
  3. /* PM DRIVER MODULE                                                     */
  4. /************************************************************************/
  5.  
  6. /************************************************************************/
  7. /* Source File : DBDEMO.C                                               */
  8. /* Use defined Include Files: DBDEMO.H, DBDLGDEM.h DBCOMM.H             */
  9. /************************************************************************/
  10.  
  11. /************************************************************************/
  12. /* PM Functions:                                                        */
  13. /*  main(argc, argv)                                                    */
  14. /*      - main procedure call for PM driver program                     */
  15. /*      - initializes message queue and main window                     */
  16. /*      - calls startdb()                                               */
  17. /*  WndProc(hWnd, message, mp1, mp2)                                    */
  18. /*  OPENMsgProc(hWndDlg, message, mp1, mp2)                             */
  19. /*  PARMMsgProc(hWndDlg, message, mp1, mp2)                             */
  20. /*  CLOSEMsgProc(hWndDlg, message, mp1, mp2)                            */
  21. /*  SHOWTIMEMsgProc(hWndDlg, message, mp1, mp2)                             */
  22. /*  EDITBOXMsgProc(hWndDlg, message, mp1, mp2)                             */
  23. /*  DDOCMENUsgProc(hWndDlg, message, mp1, mp2)                             */
  24. /*  DOCRDSMsgProc(hWndDlg, message, mp1, mp2)                             */
  25. /*  DOCPARMSMsgProc(hWndDlg, message, mp1, mp2)                             */
  26. /*                                                                      */
  27. /*  SetDlgText(Filename)                                                */
  28. /*      - sets the text from file Filename to the dialog window         */
  29. /*  PMErrChk(hAB, hWnd, usermsg)                                        */
  30. /*                                                                      */
  31. /* Database Functions:                                                  */
  32. /*  SQLthread(hWndDlg)                                                  */
  33. /*      - starts a separate thread for database demo programs           */
  34. /*  StartDB()                                                           */
  35. /*      - issues START USING DATABASE command                           */
  36. /*  StopDB()                                                            */
  37. /*      - issues STOP USING DATABASE command                            */
  38. /************************************************************************/
  39. #define EXTERN
  40. /************************************************************************/
  41. /* HEADER FILES - USER DEFINED                                          */
  42. /************************************************************************/
  43.  
  44. #include "DBDEMO.h"
  45. #include "dbcomm.h"
  46. #include "dbdemodb.h" /* user defined variables (non window) */
  47. #include "dlgdbdem.h"
  48.  
  49. SHORT cdecl main(argc, argv)
  50. int argc;
  51. char *argv[];
  52. {
  53.  QMSG qmsg;  /* MSG structure to store your messages                       */
  54.  PID  pid;   /* Process identifier for adding name to switch list          */
  55.  TID  tid;   /* Thread identifier                                          */
  56.  static CHAR szTitle[26];
  57.  
  58.  /* The WinInitialize routine initializes the Presentation Manager         */
  59.  /* facilities for use by this application and returns a handle to the     */
  60.  /* anchor block assigned to the application by PM.                        */
  61.  StartDB(&sqlca);
  62.  
  63.  if((hAB = WinInitialize(0)) == 0)
  64.     return(FALSE);
  65.  
  66.  /* The WinCreateMsgQueue call creates a message queue for this application*/
  67.  
  68.  if((hMQ = WinCreateMsgQueue(hAB, 0)) == 0)
  69.     return(FALSE);
  70.  
  71.  /* The following function registers the classes of all application windows*/
  72.  if(!cwRegisterClass())
  73.     return(FALSE);
  74.  
  75.  /* If the application's Initialization Panel is not already shown, display*/
  76.  /* it on the desktop window before any other application window is shown. */
  77.  if(!WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, (PFNWP)INITMsgProc, 0,
  78.     IDLG_INIT, (PBYTE)HWND_DESKTOP))
  79.     DosExit(0, 1);
  80.  
  81.  /**************************************************************************/
  82.  /* IPF Initialization Structure                                           */
  83.  /**************************************************************************/
  84.  
  85.  hiDBDEMOHelp.cb = sizeof(HELPINIT);  /* size of init structure      */
  86.  hiDBDEMOHelp.ulReturnCode = 0;
  87.  hiDBDEMOHelp.pszTutorialName = 0; /* no tutorial                          */
  88.  hiDBDEMOHelp.phtHelpTable = (PVOID)(0xffff0000 | ID_DBDEMO);
  89.  hiDBDEMOHelp.hmodAccelActionBarModule = 0;
  90.  hiDBDEMOHelp.idAccelTable = 0;
  91.  hiDBDEMOHelp.idActionBar = 0;
  92.  hiDBDEMOHelp.pszHelpWindowTitle = "DBDEMO";
  93.  hiDBDEMOHelp.hmodHelpTableModule = 0;
  94.  hiDBDEMOHelp.usShowPanelId = 0;
  95.  hiDBDEMOHelp.pszHelpLibraryName = "DBDEMO.HLP";
  96.  
  97.  /**************************************************************************/
  98.  /* Create Instance of IPF                                                 */
  99.  /**************************************************************************/
  100.  
  101.  hWndDBDEMOHelp = WinCreateHelpInstance(hAB, &hiDBDEMOHelp);
  102.  if(!hWndDBDEMOHelp || hiDBDEMOHelp.ulReturnCode)
  103.    {
  104.     WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  105.                   (PSZ)"No help is available.",
  106.                   (PSZ) szAppName,
  107.                   1,
  108.                   MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  109.     WinDestroyHelpInstance(hWndDBDEMOHelp);
  110.    }
  111.  
  112.  /* The CreateWindow function creates a frame window for this application's*/
  113.  /* top window, and set the window's size and location as appropriate.     */
  114.  
  115.  WinLoadString(hAB, 0, IDS_TITLE, 26, szTitle);
  116.  hWndFrame = cwCreateWindow((HWND)HWND_DESKTOP,
  117.           FCF_TITLEBAR     |
  118.           FCF_SYSMENU      |
  119.           FCF_MINBUTTON    |
  120.           FCF_MAXBUTTON    |
  121.           FCF_SIZEBORDER   |
  122.           FCF_MENU         |
  123.           FCF_SHELLPOSITION,
  124.           szAppName,
  125.           szTitle,
  126.           ID_DBDEMO,
  127.           0, 0,
  128.           0, 0,
  129.           &hWndClient,
  130.           0L, SWP_MAXIMIZE | SWP_SHOW);
  131.  
  132.  if(hWndFrame == 0)
  133.     return(FALSE);
  134.  
  135.  /**************************************************************************/
  136.  /* Associate Instance of IPF                                              */
  137.  /**************************************************************************/
  138.  if(hWndDBDEMOHelp)
  139.    WinAssociateHelpInstance(hWndDBDEMOHelp, hWndFrame);
  140.  /* The following inline routine fills out the application's switch control*/
  141.  /* structure with the appropriate information to add the application's    */
  142.  /* name to the OS/2 Task Manager List, a list of the jobs currently       */
  143.  /* running on the computer.                                               */
  144.  
  145.  WinQueryWindowProcess(hWndFrame, &pid, &tid);
  146.  Swctl.hwnd = hWndFrame;                         /* Frame window handle    */
  147.  Swctl.idProcess = pid;                          /* Process identifier     */
  148.  Swctl.uchVisibility = SWL_VISIBLE;              /* visibility             */
  149.  Swctl.fbJump = SWL_JUMPABLE;                    /* Jump indicator         */
  150.  strcpy(Swctl.szSwtitle, szTitle);               /* Frame window title     */
  151.  hSwitch = WinAddSwitchEntry(&Swctl);
  152.  
  153.  /* The following is the message loop for the application.                 */
  154.  
  155.  while(WinGetMsg(hAB, (PQMSG)&qmsg, 0, 0, 0))
  156.        WinDispatchMsg(hAB,(PQMSG)&qmsg);
  157.  
  158.  /* Perform clean up before exiting application.                           */
  159.  /**************************************************************************/
  160.  /* Destroy Instance of IPF                                                */
  161.  /**************************************************************************/
  162.  if(hWndDBDEMOHelp)
  163.     WinDestroyHelpInstance(hWndDBDEMOHelp);
  164.  /* The following routine destroys the application's frame window (which   */
  165.  /* also destroys its child windows), destroys its message queue, and      */
  166.  /* disassociates the application from the Presentation Manager system.    */
  167.  
  168.  WinDestroyWindow(hWndFrame); /* Destroy the frame window                  */
  169.  WinDestroyMsgQueue(hMQ);     /* Destroy this application's message queue  */
  170.  WinTerminate(hAB);           /* Terminate this application's use of the   */
  171.                               /* Presentation Manager resources            */
  172. } /* end of main */
  173.  
  174.  
  175. /***************************************************************************/
  176. /*                                                                         */
  177. /* Main Window Procedure                                                   */
  178. /*                                                                         */
  179. /* This procedure provides service routines for the general PM events      */
  180. /* (messages) that PM sends to the window, as well as the user             */
  181. /* initiated events (messages) that are generated when the user selects    */
  182. /* the action bar and pulldown menu controls or the corresponding          */
  183. /* keyboard accelerators.                                                  */
  184. /*                                                                         */
  185. /***************************************************************************/
  186.  
  187. MRESULT EXPENTRY WndProc(hWnd, message, mp1, mp2)
  188. HWND hWnd;
  189. USHORT message;
  190. MPARAM mp1;
  191. MPARAM mp2;
  192. {                        /* Beginning of message processor                 */
  193.    HPS hPS;              /* Handle for the Presentation Space              */
  194.    RECTL rClient;        /* Handle to rectangle formed by client area      */
  195.    USHORT rc;            /* common return code value                       */
  196.  
  197.    switch(message)
  198.      {
  199.       case WM_COMMAND:
  200.         /* The PM messages for action bar and pulldown menu items are      */
  201.         /* processed in this routine.                                      */
  202.  
  203.            switch(SHORT1FROMMP(mp1))
  204.             {
  205.              case IDM_D_STARTUSING:
  206. StartDB(&sqlca);
  207.                   break;
  208.  
  209.              case IDM_D_STOPUSING:
  210. StopDB(&sqlca);
  211.                   break;
  212.  
  213.  
  214.             case IDM_H_HELPFORHELP:
  215.                  if(hWndDBDEMOHelp)
  216.                     WinSendMsg(hWndDBDEMOHelp, HM_DISPLAY_HELP, 0L, 0L);
  217.                  break;
  218.  
  219.                case DOCM_DDOCS: /* Control text: "Demo Docs"               */
  220.                  hWndDDOCMENU = WinLoadDlg(HWND_DESKTOP,
  221.                                                 hWnd, (PFNWP)DDOCMENUMsgProc,
  222.                                                 0, IDLG_DDOCMENU, (PBYTE)hWnd);
  223.                     break;
  224.  
  225.             case DOCM_PTECH: /* Control text: "Perf Techniques"         */
  226.  
  227.              /* set up the text string pszDisplayTxt with the    */
  228.              /* corresponding file for later display in edit box */
  229.                  strcpy( temp_ebox_heading1, eboxh_ptech1);
  230.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_ptech2, eboxh_ptech3);
  231.                  rc = SetDlgText("dbptech.txt");
  232.                  if(rc)
  233.  
  234.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  235.                                                 hWnd, (PFNWP)EDITBOXMsgProc,
  236.                                                 0, IDLG_EDITBOX, (PBYTE)hWnd);
  237.                     break;
  238.  
  239.                case DOCM_PARMS: /* Control text: "Parameter Tuning"        */
  240.                  hWndDOCPARMS = WinLoadDlg(HWND_DESKTOP,
  241.                                                 hWnd, (PFNWP)DOCPARMSMsgProc,
  242.                                                 0, IDLG_DOCPARMS, (PBYTE)hWnd);
  243.                     break;
  244.                case DOCM_RDS: /* Control text: "RDS Docs"                  */
  245.                  hWndDOCRDS = WinLoadDlg(HWND_DESKTOP, hWnd, (PFNWP)DOCRDSMsgProc,
  246.                           0, IDLG_DOCRDS, (PBYTE)hWnd);
  247.                     break;
  248.  
  249.                case DEMOM_ARI: /* Control text: "A R I"                    */
  250.                 demo_num = DEMO_ARI ;
  251.                 strcpy(temp_timeh_heading1, timeh_ari1 );
  252.                 strcpy(temp_timeh_heading2, timeh_ari2 );
  253.                 strcpy(temp_timeh_heading3, timeh_ari3 );
  254.                  hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
  255.                                                 hWnd, (PFNWP)SHOWTIMEMsgProc,
  256.                                                 0, IDLG_SHOWTIME, (PBYTE)hWnd);
  257.                     break;
  258.  
  259.                case DEMOM_RBLOCK: /* Control text: "Record Blocking"       */
  260.                 demo_num = DEMO_RBLOCK ;
  261.                 strcpy(temp_timeh_heading1, timeh_rblock1 );
  262.                 strcpy(temp_timeh_heading2, timeh_rblock2 );
  263.                 strcpy(temp_timeh_heading3, timeh_rblock3 );
  264.                  hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
  265.                                                 hWnd, (PFNWP)SHOWTIMEMsgProc,
  266.                                                 0, IDLG_SHOWTIME, (PBYTE)hWnd);
  267.                     break;
  268.  
  269.                case DEMOM_STATDYN: /* Control text: "Static vs Dynamic"    */
  270.                 demo_num = DEMO_STATDYN ;
  271.                 strcpy(temp_timeh_heading1, timeh_statdyn1 );
  272.                 strcpy(temp_timeh_heading2, timeh_statdyn2 );
  273.                 strcpy(temp_timeh_heading3, timeh_statdyn3 );
  274.                  hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
  275.                                                 hWnd, (PFNWP)SHOWTIMEMsgProc,
  276.                                                 0, IDLG_SHOWTIME, (PBYTE)hWnd);
  277.  
  278.                     break;
  279.  
  280.                case DEMOM_INDICES: /* Control text: "I N D I C E S"        */
  281.                 demo_num = DEMO_INDICES ;
  282.                 strcpy(temp_timeh_heading1, timeh_indices1 );
  283.                 strcpy(temp_timeh_heading2, timeh_indices2 );
  284.                 strcpy(temp_timeh_heading3, timeh_indices3 );
  285.                  hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
  286.                                                 hWnd, (PFNWP)SHOWTIMEMsgProc,
  287.                                                 0, IDLG_SHOWTIME, (PBYTE)hWnd);
  288.                     break;
  289.  
  290.                case MMENU_EXIT: /* Control text: "EXIT"                    */
  291.          WinSendMsg(hWnd, WM_CLOSE, MPFROMSHORT(WM_CLOSE), 0L);
  292.                     break;
  293.  
  294.                case MMENU_HELP: /* Control text: "HELP"                    */
  295.                     break;
  296.  
  297.  
  298.              default:
  299.                   break; /* End of default case for switch(mp1) */
  300.             }
  301.            break; /* End of WM_COMMAND */
  302.  
  303.       case WM_CONTROL:
  304.            break; /* End of WM_COMMAND */
  305.  
  306.       case HM_QUERY_KEYS_HELP:
  307.            /* If the user requests Keys Help from the help pulldown,       */
  308.            /* IPF sends the HM_QUERY_KEYS_HELP message to the application, */
  309.            /* which should return the panel id of the Keys Help panel      */
  310.            return((MRESULT)999);
  311.            break;
  312.  
  313.       case HM_ERROR:
  314.            /* If an IPF error occurs, an HM_ERROR message will be sent to  */
  315.            /* the application.                                             */
  316.            if(hWndDBDEMOHelp && ((ULONG)mp1) == HMERR_NO_MEMORY)
  317.              {
  318.               WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  319.                             (PSZ) "Help Terminated Due to Error",
  320.                             (PSZ) "Help Error",
  321.                             1,
  322.                             MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  323.               WinDestroyHelpInstance(hWndDBDEMOHelp);
  324.              }
  325.             else
  326.              {
  327.               WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
  328.                             (PSZ) "Help Error Occurred",
  329.                             (PSZ) "Help Error",
  330.                             1,
  331.                             MB_OK | MB_APPLMODAL | MB_MOVEABLE);
  332.              }
  333.            break;
  334.  
  335.       case WM_CREATE:
  336.            {
  337.             PVOID         pControlData;
  338.             PCREATESTRUCT pCreateStruct;
  339.  
  340.             pControlData   = (PVOID)PVOIDFROMMP(mp1);
  341.             pCreateStruct  = (PCREATESTRUCT)PVOIDFROMMP(mp2);
  342.            }
  343.            cwCreateClientControls(hWnd);
  344.            cwSetInitDlgStatus(hWnd);
  345.            break; /* End of WM_CREATE */
  346.  
  347.       case WM_MOUSEMOVE:
  348.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  349.            break;
  350.  
  351.       case WM_SIZE:     /* code for sizing client area                     */
  352.            break;       /* End of WM_SIZE                                  */
  353.  
  354.       case WM_PAINT:    /* code for the window's client area               */
  355.            /* Obtain a handle to a cache presentation space                */
  356.            hPS = WinBeginPaint(hWnd, 0, 0);
  357.  
  358.            /* Determine the size of the client area                        */
  359.            WinQueryWindowRect(hWnd, &rClient);
  360.  
  361.            /* Fill the background with the default background color        */
  362.            WinFillRect(hPS, &rClient, CLR_BACKGROUND);
  363.  
  364.            /* return presentation space to state before WinBeginPaint      */
  365.            WinEndPaint(hPS);
  366.            break; /* End of WM_PAINT */
  367.  
  368.       case WM_INITMENU:
  369.            /* Occurs when a menu is being initilaized.                     */
  370.            /* A window message sent when a menu is about to become active, */
  371.            /* allowing the application to modify the menu before it is     */
  372.            /* displayed.                                                   */
  373.            /*                                                              */
  374.            /* Parameters:                                                  */
  375.            /*     MenuID    -  low word of mp1                             */
  376.            /*                  Specifies the menu item identifier.         */
  377.            /*                                                              */
  378.            /*     hMenu     -  low and high word of mp2                    */
  379.            /*                  Identifies the menu.                        */
  380.            /*                                                              */
  381.            /* Return Value:  0 if this message is processed.               */
  382.  
  383.            MenuID = SHORT1FROMMP(mp1);
  384.            hMenu  = (HWND)mp2;
  385.            break;  /* End of case WM_INITMENU                              */
  386.  
  387.  
  388.       case WM_CLOSE:  /* close the window                                  */
  389.            if(hWnd != hWndClient)
  390.              break;
  391.            cwFreeDlgMemory(hWnd);
  392.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  393.            break; /* End of WM_CLOSE */
  394.  
  395.       default:
  396.            /* For any message for which you don't specifically provide a   */
  397.            /* service routine, you should return the message to PM using   */
  398.            /* the WinDefWindowProc function.                               */
  399.            return(WinDefWindowProc(hWnd, message, mp1, mp2));
  400.            break;  /* End of default */
  401.      }
  402.    return(0L);
  403. } /* End of WndProc */
  404.  
  405. /***************************************************************************/
  406. /*                                                                         */
  407. /* Dialog Window Procedure                                                 */
  408. /*                                                                         */
  409. /* This procedure is associated with the dialog box that is included in    */
  410. /* the function name of the procedure. It provides the service routines    */
  411. /* for the events (messages) that occur because the end user operates      */
  412. /* one of the dialog box's buttons, entry fields, or controls.             */
  413. /*                                                                         */
  414. //* /**  INSERT COD  HERE TO EXIT FROM THE PROGRAM, DESTROY WINDOW ETC.   */
  415. /***************************************************************************/
  416.  
  417. MRESULT EXPENTRY INITMsgProc(hWndDlg, message, mp1, mp2)
  418. HWND hWndDlg;
  419. USHORT message;
  420. MPARAM mp1;
  421. MPARAM mp2;
  422. {
  423.  static SHORT sfValidate = TRUE;
  424.  INT    i;
  425.  static INT   iLogoTime;
  426.  static HWND  hWndParent;
  427.  
  428.  switch(message)
  429.    {
  430.     case WM_INITDLG:
  431.          hWndParent = (HWND)mp2;
  432.          cwCenter(hWndDlg, (HWND)hWndParent);
  433.          iLogoTime = WinQueryProfileInt(hAB, "PM_ControlPanel",
  434.                                              "LogoDisplayTime", -1);
  435.          if(iLogoTime == 0)
  436.            {
  437.             WinDismissDlg(hWndDlg, TRUE);
  438.             break;
  439.            }
  440.          if(iLogoTime == -1)
  441.            break;
  442.          WinStartTimer(hAB, hWndDlg, ID_LOGO_TIMER, iLogoTime);
  443.          break; /* End of WM_INITDLG */
  444.  
  445.     case WM_TIMER:
  446.          WinStopTimer(hAB, hWndDlg, ID_LOGO_TIMER);
  447.          WinDismissDlg(hWndDlg, TRUE);
  448.          break;
  449.  
  450.     case WM_CONTROL:
  451.          switch(SHORT1FROMMP(mp1))
  452.            {
  453.            }
  454.          break; /* End of WM_CONTROL */
  455.  
  456.     case WM_COMMAND:
  457.          switch(SHORT1FROMMP(mp1))
  458.            {
  459.             case DID_OK: /* Button text: "ENTER"                           */
  460.                  WinDismissDlg(hWndDlg, TRUE);
  461.                  break;
  462.  
  463.             case DID_CANCEL: /* Button text: "ESC"                         */
  464.                  /* Ignore data values entered into the dialog controls    */
  465.                  /* and dismiss the dialog window                          */
  466.                  WinDismissDlg(hWndDlg, FALSE);
  467.                  break;
  468.  
  469.            }
  470.          break; /* End of WM_COMMAND */
  471.  
  472.     case WM_CLOSE:
  473.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  474.          break; /* End of WM_CLOSE */
  475.  
  476.     case WM_FAILEDVALIDATE:
  477.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  478.          sfValidate = FALSE;
  479.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  480.          sfValidate = TRUE;
  481.          return((MRESULT)TRUE);
  482.          break; /* End of WM_FAILEDVALIDATE */
  483.  
  484.     default:
  485.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  486.          break;
  487.    }
  488.  return FALSE;
  489. } /* End of INITMsgProc */
  490.  
  491.  
  492. /***************************************************************************/
  493. /*                                                                         */
  494. /* Dialog Window Procedure                                                 */
  495. /*                                                                         */
  496. /* This procedure is associated with the dialog box that is included in    */
  497. /* the function name of the procedure. It provides the service routines    */
  498. /* for the events (messages) that occur because the end user operates      */
  499. /* one of the dialog box's buttons, entry fields, or controls.             */
  500. /*                                                                         */
  501. /***************************************************************************/
  502.  
  503. MRESULT EXPENTRY DDOCMENUMsgProc(hWndDlg, message, mp1, mp2)
  504. HWND hWndDlg;
  505. USHORT message;
  506. MPARAM mp1;
  507. MPARAM mp2;
  508. {
  509.  static SHORT sfValidate = TRUE;
  510.  INT    i;
  511.  static HWND  hWndParent;
  512.  USHORT rc;
  513.  switch(message)
  514.    {
  515.     case WM_INITDLG:
  516.          hWndParent = (HWND)mp2;
  517.          break; /* End of WM_INITDLG */
  518.  
  519.     case WM_CONTROL:
  520.          switch(SHORT1FROMMP(mp1))
  521.            {
  522.            }
  523.          break; /* End of WM_CONTROL */
  524.  
  525.     case WM_COMMAND:
  526.          switch(SHORT1FROMMP(mp1))
  527.            {
  528.             case DDOCM_ARI: /* Button text: "A R I    Docs"                */
  529. //mycode b
  530.              /* set up the text string pszDisplayTxt with the    */
  531.              /* corresponding file for later display in edit box */
  532.                  strcpy( temp_ebox_heading1, eboxh_ari1 );
  533.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_ari2, eboxh_ari3);
  534. //                 strcpy( temp_ebox_heading3, eboxh_ari3 );
  535.                  rc = SetDlgText("ari.txt");
  536.                  if(rc)
  537. //mycode e
  538.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  539.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  540.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  541.                  break;
  542.  
  543.             case DDOCM_STATDYN: /* Button text: "Static vs Dynamic"        */
  544. //mycode b
  545.              /* set up the text string pszDisplayTxt with the    */
  546.              /* corresponding file for later display in edit box */
  547.                  strcpy( temp_ebox_heading1, eboxh_statdyn1 );
  548.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_statdyn2, eboxh_statdyn3);
  549. //                 strcpy( temp_ebox_heading3, eboxh_statdyn3 );
  550.                  rc = SetDlgText("stat_dyn.txt");
  551.                  if(rc)
  552. //mycode e
  553.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  554.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  555.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  556.                  break;
  557.  
  558.             case DDOCM_RBLOCK: /* Button text: "Record Blocking "          */
  559. //mycode b
  560.              /* set up the text string pszDisplayTxt with the    */
  561.              /* corresponding file for later display in edit box */
  562.                  strcpy( temp_ebox_heading1, eboxh_rblock1 );
  563.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_rblock2, eboxh_rblock3);
  564. //                 strcpy( temp_ebox_heading3, eboxh_rblock3 );
  565.                  rc = SetDlgText("rblock.txt");
  566.                  if(rc)
  567. //mycode e
  568.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  569.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  570.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  571.                  break;
  572.  
  573.             case DDOCM_INDICES: /* Button text: "INDICES"                  */
  574. //mycode b
  575.              /* set up the text string pszDisplayTxt with the    */
  576.              /* corresponding file for later display in edit box */
  577.                  strcpy( temp_ebox_heading1, eboxh_indices1 );
  578.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_indices2, eboxh_indices3);
  579. //                 strcpy( temp_ebox_heading3, eboxh_indices3 );
  580.                  rc = SetDlgText("indices.txt");
  581.                  if(rc)
  582. //mycode e
  583.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  584.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  585.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  586.                  break;
  587.  
  588.             case DID_CANCEL: /* Button text: "CANCEL"                      */
  589.                  /* Ignore data values entered into the dialog controls    */
  590.                  /* and dismiss the dialog window                          */
  591.                  WinDestroyWindow(hWndDlg);
  592.                  hWndDDOCMENU = 0;
  593.  
  594.                  break;
  595.  
  596.             case DDOCM_HELP: /* Button text: "HELP"                        */
  597.                  break;
  598.  
  599.            }
  600.          break; /* End of WM_COMMAND */
  601.  
  602.     case WM_CLOSE:
  603.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  604.          break; /* End of WM_CLOSE */
  605.  
  606.     case WM_FAILEDVALIDATE:
  607.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  608.          sfValidate = FALSE;
  609.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  610.          sfValidate = TRUE;
  611.          return((MRESULT)TRUE);
  612.          break; /* End of WM_FAILEDVALIDATE */
  613.  
  614.     default:
  615.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  616.          break;
  617.    }
  618.  return FALSE;
  619. } /* End of DDOCMENUMsgProc */
  620.  
  621.  
  622. /***************************************************************************/
  623. /*                                                                         */
  624. /* Dialog Window Procedure                                                 */
  625. /*                                                                         */
  626. /* This procedure is associated with the dialog box that is included in    */
  627. /* the function name of the procedure. It provides the service routines    */
  628. /* for the events (messages) that occur because the end user operates      */
  629. /* one of the dialog box's buttons, entry fields, or controls.             */
  630. /*                                                                         */
  631. /***************************************************************************/
  632.  
  633. MRESULT EXPENTRY SHOWTIMEMsgProc(hWndDlg, message, mp1, mp2)
  634. HWND hWndDlg;
  635. USHORT message;
  636. MPARAM mp1;
  637. MPARAM mp2;
  638. {
  639.  static SHORT sfValidate = TRUE;
  640.  INT    i;
  641.  static CHAR  szWorkBuf[50];
  642.  static HWND  hWndParent;
  643.  SHOWTIMEStruct FAR *Showtime;
  644.  
  645.  switch(message)
  646.    {
  647.     case WM_INITDLG:
  648.          Showtime = (SHOWTIMEStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_SHOWTIME);
  649.          hWndParent = (HWND)mp2;
  650.  
  651.          Showtime->num_of_iterations = DEFAULT_NUM_OF_ITERATIONS ;
  652.     num_runs = (Showtime->num_of_iterations);
  653.  
  654.  
  655.          /* Initialize entry field control: num_of_iterations              */
  656.          itoa(Showtime->num_of_iterations, szWorkBuf, 10);
  657.          WinSetDlgItemText(hWndDlg, STIME_ITERFIELD, szWorkBuf);
  658.          /* Initialize entry field control: stime_time1                    */
  659.          WinSendDlgItemMsg(hWndDlg, STIME_TIME1, EM_SETTEXTLIMIT, MPFROMSHORT(50), 0L);
  660.          if(Showtime->stime_time1[0])
  661.             WinSetDlgItemText(hWndDlg, STIME_TIME1, Showtime->stime_time1);
  662.          /* Initialize entry field control: stime_time2                    */
  663.          WinSendDlgItemMsg(hWndDlg, STIME_TIME2, EM_SETTEXTLIMIT, MPFROMSHORT(50), 0L);
  664.          if(Showtime->stime_time2[0])
  665.             WinSetDlgItemText(hWndDlg, STIME_TIME2, Showtime->stime_time2);
  666.  
  667.          /* Initialize entry field control: stime_htxt1                    */
  668.          WinSendDlgItemMsg(hWndDlg, STIME_HTXT1, EM_SETTEXTLIMIT, MPFROMSHORT(50), 0L);
  669.  
  670.          strcpy(&(Showtime->stime_htxt1[0]), temp_timeh_heading1 );
  671.          if(Showtime->stime_htxt1[0])
  672.             WinSetDlgItemText(hWndDlg, STIME_HTXT1, Showtime->stime_htxt1);
  673.          WinSetDlgItemText(hWndDlg, STIME_HTXT1, temp_timeh_heading1 );
  674.  
  675.          /* Initialize entry field control: stime_htxt2                    */
  676.          WinSendDlgItemMsg(hWndDlg, STIME_HTXT2, EM_SETTEXTLIMIT, MPFROMSHORT(50), 0L);
  677.  
  678.          strcpy(&(Showtime->stime_htxt2[0]), temp_timeh_heading2 );
  679.          if(Showtime->stime_htxt2[0])
  680.             WinSetDlgItemText(hWndDlg, STIME_HTXT2, Showtime->stime_htxt2);
  681.          WinSetDlgItemText(hWndDlg, STIME_HTXT2, temp_timeh_heading2 );
  682.  
  683.          /* Initialize entry field control: stime_htxt3                    */
  684.          WinSendDlgItemMsg(hWndDlg, STIME_HTXT3, EM_SETTEXTLIMIT, MPFROMSHORT(50), 0L);
  685.  
  686.          strcpy(&(Showtime->stime_htxt3[0]), temp_timeh_heading3 );
  687.          if(Showtime->stime_htxt3[0])
  688.             WinSetDlgItemText(hWndDlg, STIME_HTXT3, Showtime->stime_htxt3);
  689.          /* Initialize entry field control: stime_dname1                   */
  690.          WinSendDlgItemMsg(hWndDlg, STIME_DNAME1, EM_SETTEXTLIMIT, MPFROMSHORT(15), 0L);
  691.          if(Showtime->stime_dname1[0])
  692.             WinSetDlgItemText(hWndDlg, STIME_DNAME1, Showtime->stime_dname1);
  693.          /* Initialize entry field control: stime_dname2                   */
  694.          WinSendDlgItemMsg(hWndDlg, STIME_DNAME2, EM_SETTEXTLIMIT, MPFROMSHORT(15), 0L);
  695.          if(Showtime->stime_dname2[0])
  696.             WinSetDlgItemText(hWndDlg, STIME_DNAME2, Showtime->stime_dname2);
  697.          WinSetDlgItemText(hWndDlg, STIME_HTXT3, temp_timeh_heading3 );
  698.          break; /* End of WM_INITDLG */
  699.  
  700.     case WM_CONTROL:
  701.          switch(SHORT1FROMMP(mp1))
  702.            {
  703.             case STIME_ITERFIELD: /* Entry field variable: "num_of_iterations" */
  704.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  705.                    {
  706.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  707.                          break;
  708.  
  709.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  710.                          {
  711.                           /* Validate the field                            */
  712.                           static char buffer[80];
  713.                           WinQueryDlgItemText(hWndDlg, STIME_ITERFIELD,
  714.                                               sizeof(buffer), buffer);
  715.                           if(buffer[0]==0x00)
  716.                             break;
  717.                           if(sfValidate && !cwNumericValidate(buffer))
  718.                             WinPostMsg(hWndDlg, WM_FAILEDVALIDATE, mp1, 0);
  719. //mycode b
  720.                  num_runs = atoi(buffer);
  721. //mycode e
  722.                          }
  723.                          break;
  724.  
  725.                     default: /* Default other messages                     */
  726.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  727.                          break;
  728.                    }
  729.                  break;
  730.  
  731.             case STIME_TIME1: /* Entry field variable: "stime_time1"       */
  732.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  733.                    {
  734.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  735.                          break;
  736.  
  737.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  738.                          break;
  739.  
  740.                     default: /* Default other messages                     */
  741.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  742.                          break;
  743.                    }
  744.                  break;
  745.  
  746.             case STIME_TIME2: /* Entry field variable: "stime_time2"       */
  747.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  748.                    {
  749.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  750.                          break;
  751.  
  752.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  753.                          break;
  754.  
  755.                     default: /* Default other messages                     */
  756.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  757.                          break;
  758.                    }
  759.                  break;
  760.  
  761.             case STIME_HTXT1: /* Entry field variable: "stime_htxt1"       */
  762.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  763.                    {
  764.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  765.                          break;
  766.  
  767.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  768.                          break;
  769.  
  770.                     default: /* Default other messages                     */
  771.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  772.                          break;
  773.                    }
  774.                  break;
  775.  
  776.             case STIME_HTXT2: /* Entry field variable: "stime_htxt2"       */
  777.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  778.                    {
  779.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  780.                          break;
  781.  
  782.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  783.                          break;
  784.  
  785.                     default: /* Default other messages                     */
  786.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  787.                          break;
  788.                    }
  789.                  break;
  790.  
  791.             case STIME_HTXT3: /* Entry field variable: "stime_htxt3"       */
  792.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  793.                    {
  794.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  795.                          break;
  796.  
  797.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  798.                          break;
  799.  
  800.                     default: /* Default other messages                     */
  801.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  802.                          break;
  803.                    }
  804.                  break;
  805.  
  806.             case STIME_DNAME1: /* Entry field variable: "stime_dname1"     */
  807.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  808.                    {
  809.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  810.                          break;
  811.  
  812.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  813.                          break;
  814.  
  815.                     default: /* Default other messages                     */
  816.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  817.                          break;
  818.                    }
  819.                  break;
  820.  
  821.             case STIME_DNAME2: /* Entry field variable: "stime_dname2"     */
  822.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  823.                    {
  824.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  825.                          break;
  826.  
  827.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  828.                          break;
  829.  
  830.                     default: /* Default other messages                     */
  831.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  832.                          break;
  833.                    }
  834.                  break;
  835.  
  836.            }
  837.          break; /* End of WM_CONTROL */
  838.  
  839.     case WM_COMMAND:
  840.          switch(SHORT1FROMMP(mp1))
  841.            {
  842.             case STIME_START: /* Button text: "START"                      */
  843. //                 #include "uthnew.INC"
  844.                      {
  845.                      // Clear DBOX
  846.                      szWorkBuf[0] = '\0';
  847.                      fSuccess = WinSetDlgItemText(hWndDlg, STIME_TIME1, szWorkBuf);
  848.                      fSuccess = WinSetDlgItemText(hWndDlg, STIME_TIME2, szWorkBuf);
  849.                      fSuccess = WinSetDlgItemText(hWndDlg, STIME_DNAME1, szWorkBuf);
  850.                      fSuccess = WinSetDlgItemText(hWndDlg, STIME_DNAME2, szWorkBuf);
  851.                      strcpy(szWorkBuf,"PROCESSING...PLEASE WAIT!!");
  852.                      fSuccess = WinSetDlgItemText(hWndDlg,STIME_TIME1,szWorkBuf);
  853.                      }
  854.  
  855.                  WAITING = TRUE;
  856.                  // Call SQC program
  857.                  if( NULL == (stack = malloc (STACKSIZE)))
  858.                    {
  859.                     WinAlarm(HWND_DESKTOP, WA_ERROR);
  860.                     return(0);
  861.                     }
  862.  
  863.                  if(-1 == (tidSQL = _beginthread(SQLthread, stack,
  864.                                                  STACKSIZE, hWndDlg)))
  865.                    {
  866.                     WinAlarm(HWND_DESKTOP, WA_ERROR);
  867.                     return(0);
  868.                     }
  869.                  break;
  870.  
  871.             case DID_OK: /* Button text: "OK"                              */
  872.                   Showtime = (SHOWTIMEStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_SHOWTIME);
  873.                  /* Query the string value in the entry field control and  */
  874.                  /* move the string value to the dialog structure variable */
  875.                  WinQueryDlgItemText(hWndDlg, STIME_ITERFIELD, 50, szWorkBuf);
  876.                  Showtime->num_of_iterations = atoi(szWorkBuf);
  877.     num_runs = (Showtime->num_of_iterations);
  878.                  /* Query the string value in the entry field control and  */
  879.                  /* move the string value to the dialog structure variable */
  880.                  WinQueryDlgItemText(hWndDlg, STIME_TIME1,
  881.                                      sizeof(Showtime->stime_time1),
  882.                                      Showtime->stime_time1);
  883.                  /* Query the string value in the entry field control and  */
  884.                  /* move the string value to the dialog structure variable */
  885.                  WinQueryDlgItemText(hWndDlg, STIME_TIME2,
  886.                                      sizeof(Showtime->stime_time2),
  887.                                      Showtime->stime_time2);
  888.                  /* Query the string value in the entry field control and  */
  889.                  /* move the string value to the dialog structure variable */
  890.                  WinQueryDlgItemText(hWndDlg, STIME_HTXT1,
  891.                                      sizeof(Showtime->stime_htxt1),
  892.                                      Showtime->stime_htxt1);
  893.                  /* Query the string value in the entry field control and  */
  894.                  /* move the string value to the dialog structure variable */
  895.                  WinQueryDlgItemText(hWndDlg, STIME_HTXT2,
  896.                                      sizeof(Showtime->stime_htxt2),
  897.                                      Showtime->stime_htxt2);
  898.                  /* Query the string value in the entry field control and  */
  899.                  /* move the string value to the dialog structure variable */
  900.                  WinQueryDlgItemText(hWndDlg, STIME_HTXT3,
  901.                                      sizeof(Showtime->stime_htxt3),
  902.                                      Showtime->stime_htxt3);
  903.                  /* Query the string value in the entry field control and  */
  904.                  /* move the string value to the dialog structure variable */
  905.                  WinQueryDlgItemText(hWndDlg, STIME_DNAME1,
  906.                                      sizeof(Showtime->stime_dname1),
  907.                                      Showtime->stime_dname1);
  908.                  /* Query the string value in the entry field control and  */
  909.                  /* move the string value to the dialog structure variable */
  910.                  WinQueryDlgItemText(hWndDlg, STIME_DNAME2,
  911.                                      sizeof(Showtime->stime_dname2),
  912.                                      Showtime->stime_dname2);
  913. //mycode b
  914.                 Showtime->num_of_iterations = DEFAULT_NUM_OF_ITERATIONS ;
  915.                 num_runs = DEFAULT_NUM_OF_ITERATIONS;
  916.                 szWorkBuf[0] = '\0';
  917.                 Showtime->stime_time1[0] = '\0';
  918.                 Showtime->stime_time2[0] = '\0';
  919.                 Showtime->stime_htxt1[0] = '\0';
  920.                 Showtime->stime_htxt2[0] = '\0';
  921.                 Showtime->stime_htxt3[0] = '\0';
  922.                  Showtime->stime_dname1[0] = '\0';
  923.                  Showtime->stime_dname2[0] = '\0';
  924. //mycode e
  925.                  WinDestroyWindow(hWndDlg);
  926.                  hWndSHOWTIME = 0;
  927.  
  928.                  break;
  929.  
  930.             case STIME_HELP: /* Button text: "HELP"                        */
  931.                  break;
  932.  
  933. // This message is received when the database program ends
  934. // The times are displayed
  935.            case DISPLAY_TIME: /* message to display time                  */
  936.                  WAITING = FALSE;
  937.                  WinAlarm(HWND_DESKTOP, WA_NOTE);
  938.                  szWorkBuf[0] = '\0';
  939.  
  940.                  // Display timing data
  941.                  // --- demo time #1
  942.                  sprintf(szWorkBuf, "%14.14s", Timetext[0].demoname);
  943.                  fSuccess = WinSetDlgItemText(hWndDlg,STIME_DNAME1,szWorkBuf);
  944.                  sprintf(szWorkBuf," %5.2f  secs", Timetext[0].demotime);
  945.                  fSuccess = WinSetDlgItemText(hWndDlg,STIME_TIME1,szWorkBuf);
  946.  
  947.                  // --- demo time #2
  948.                  sprintf(szWorkBuf, "%14.14s", Timetext[1].demoname);
  949.                  fSuccess = WinSetDlgItemText(hWndDlg,STIME_DNAME2,szWorkBuf);
  950.                  sprintf(szWorkBuf," %5.2f  secs", Timetext[1].demotime);
  951.                  fSuccess = WinSetDlgItemText(hWndDlg,STIME_TIME2,szWorkBuf);
  952.  
  953.                  break;
  954.  
  955. // unsuccessful completion of demo
  956.  
  957.             case DEMO_DIED: // Process Msg DEMO_DIED
  958.                  sprintf (szWorkBuf, "Demo failed , error code = %ld", error_sql);
  959.                  WinMessageBox ( HWND_DESKTOP,
  960.                  hWndClient,
  961.                  szWorkBuf,
  962.                  "User Message",
  963.                  0,
  964.                  MB_MOVEABLE | MB_OK | MB_CUANOTIFICATION );
  965.                  WinDismissDlg(hWndDlg, TRUE);
  966.            }
  967.          break; /* End of WM_COMMAND */
  968.  
  969.     case WM_CLOSE:
  970.          WinDismissDlg(hWndDlg, FALSE);
  971.          break; /* End of WM_CLOSE */
  972.  
  973.     case WM_FAILEDVALIDATE:
  974.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  975.          sfValidate = FALSE;
  976.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  977.          sfValidate = TRUE;
  978.          return((MRESULT)TRUE);
  979.          break; /* End of WM_FAILEDVALIDATE */
  980.  
  981.     default:
  982.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  983.          break;
  984.    }
  985.  return FALSE;
  986. } /* End of SHOWTIMEMsgProc */
  987.  
  988.  
  989. /***************************************************************************/
  990. /*                                                                         */
  991. /* Dialog Window Procedure                                                 */
  992. /*                                                                         */
  993. /* This procedure is associated with the dialog box that is included in    */
  994. /* the function name of the procedure. It provides the service routines    */
  995. /* for the events (messages) that occur because the end user operates      */
  996. /* one of the dialog box's buttons, entry fields, or controls.             */
  997. /*                                                                         */
  998. /***************************************************************************/
  999.  
  1000. MRESULT EXPENTRY EDITBOXMsgProc(hWndDlg, message, mp1, mp2)
  1001. HWND hWndDlg;
  1002. USHORT message;
  1003. MPARAM mp1;
  1004. MPARAM mp2;
  1005. {
  1006.  static SHORT sfValidate = TRUE;
  1007.  INT    i;
  1008.  static HWND  hWndParent;
  1009.  EDITBOXStruct FAR *Editbox;
  1010.  
  1011. //mycode b
  1012.  const char *pszFont = "8.Courier";
  1013. //mycode e
  1014.  
  1015.  switch(message)
  1016.    {
  1017.     case WM_INITDLG:
  1018.          Editbox = (EDITBOXStruct FAR *)WinQueryWindowULong(hWndClient, OFFSET_EDITBOX);
  1019.          hWndParent = (HWND)mp2;
  1020.          /* Initialize entry field control: ebox_heading1                  */
  1021.          WinSendDlgItemMsg(hWndDlg, EBOX_H, EM_SETTEXTLIMIT, MPFROMSHORT(100), 0L);
  1022.  
  1023. // copy the appropriate headings to the display structure
  1024.          strcpy(Editbox->ebox_heading1 , temp_ebox_heading1);
  1025. //         strcpy(Editbox->ebox_heading2 , temp_ebox_heading2);
  1026. //         strcpy(Editbox->ebox_heading3 , temp_ebox_heading3);
  1027.  
  1028.          if(Editbox->ebox_heading1[0])
  1029.             WinSetDlgItemText(hWndDlg, EBOX_H, Editbox->ebox_heading1);
  1030. //mycode b
  1031.        /* set up the txt for main display window   */
  1032.  
  1033.          WinSetPresParam(hWndDlg, PP_FONTNAMESIZE, strlen(pszFont) +1, pszFont);
  1034.          if(!WinSetDlgItemText(hWndDlg, EBOX_HTEXT1, temp_ebox_heading2))
  1035.               PMErrChk(hAB, HWND_DESKTOP, "WinSetDlgItemText() failed!");
  1036.          if(!WinSetDlgItemText(hWndDlg, EBOX_MLE, pszDisplayTxt))
  1037.               PMErrChk(hAB, HWND_DESKTOP, "WinSetDlgItemText() failed!");
  1038.          if(pszDisplayTxt != NULL)
  1039.             free(pszDisplayTxt);
  1040. //mycode e
  1041.          break; /* End of WM_INITDLG */
  1042.  
  1043.     case WM_CONTROL:
  1044.          switch(SHORT1FROMMP(mp1))
  1045.            {
  1046.             case 256: /* Entry field                                       */
  1047.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1048.                    {
  1049.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1050.                          break;
  1051.  
  1052.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1053.                          break;
  1054.  
  1055.                     default: /* Default other messages                     */
  1056.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1057.                          break;
  1058.                    }
  1059.                  break;
  1060.  
  1061.             case EBOX_MLE: /* Entry field                                  */
  1062.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1063.                    {
  1064.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1065.                          break;
  1066.  
  1067.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1068.                          break;
  1069.  
  1070.                     default: /* Default other messages                     */
  1071.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1072.                          break;
  1073.                    }
  1074.                  break;
  1075.  
  1076.             case EBOX_H: /* Entry field variable: "ebox_heading1"          */
  1077.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1078.                    {
  1079.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1080.                          break;
  1081.  
  1082.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1083.                          break;
  1084.  
  1085.                     default: /* Default other messages                     */
  1086.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1087.                          break;
  1088.                    }
  1089.                  break;
  1090.  
  1091.             case EBOX_HTEXT1: /* Entry field                               */
  1092.                  switch(SHORT2FROMMP(mp1)) /* switch on Notification Code  */
  1093.                    {
  1094.                     case EN_SETFOCUS:/* Entry field is receiving the focus */
  1095.                          break;
  1096.  
  1097.                     case EN_KILLFOCUS: /* Entry field is losing the focus  */
  1098.                          break;
  1099.  
  1100.                     default: /* Default other messages                     */
  1101.                          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1102.                          break;
  1103.                    }
  1104.                  break;
  1105.  
  1106.            }
  1107.          break; /* End of WM_CONTROL */
  1108.  
  1109.     case WM_COMMAND:
  1110.          switch(SHORT1FROMMP(mp1))
  1111.            {
  1112.             case EBOX_PMENU: /* Button text: "Previous menu"               */
  1113.  
  1114.                  WinDestroyWindow(hWndDlg);
  1115.                  hWndEDITBOX = 0;
  1116.                  break;
  1117.  
  1118.             case EBOX_MMENU: /* Button text: "Top level menu"              */
  1119.  
  1120.                  WinDestroyWindow(hWndDlg);
  1121.  
  1122.  
  1123. // send message corresponding calling menu to quit (dismiss
  1124. //         WinSendDlgItemMsg(HWND_DESKTOP, IDLG_DDOCMENU , WM_COMMAND , MPFROMSHORT(DID_CANCEL), 0L);
  1125.            {
  1126.            HWND hWndOwner;
  1127.            hWndOwner = WinQueryWindow(hWndDlg, QW_OWNER, 0);
  1128.            WinSendMsg( hWndOwner, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  1129.            }
  1130. // end mycode
  1131.                  hWndEDITBOX = 0;
  1132.                  break;
  1133.  
  1134.            }
  1135.          break; /* End of WM_COMMAND */
  1136.  
  1137.     case WM_CLOSE:
  1138.          WinDismissDlg(hWndDlg, FALSE);
  1139.          break; /* End of WM_CLOSE */
  1140.  
  1141.     case WM_FAILEDVALIDATE:
  1142.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  1143.          sfValidate = FALSE;
  1144.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  1145.          sfValidate = TRUE;
  1146.          return((MRESULT)TRUE);
  1147.          break; /* End of WM_FAILEDVALIDATE */
  1148.  
  1149.     default:
  1150.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1151.          break;
  1152.    }
  1153.  return FALSE;
  1154. } /* End of EDITBOXMsgProc */
  1155.  
  1156.  
  1157. /***************************************************************************/
  1158. /*                                                                         */
  1159. /* Dialog Window Procedure                                                 */
  1160. /*                                                                         */
  1161. /* This procedure is associated with the dialog box that is included in    */
  1162. /* the function name of the procedure. It provides the service routines    */
  1163. /* for the events (messages) that occur because the end user operates      */
  1164. /* one of the dialog box's buttons, entry fields, or controls.             */
  1165. /*                                                                         */
  1166. /***************************************************************************/
  1167.  
  1168. MRESULT EXPENTRY MMENUMsgProc(hWndDlg, message, mp1, mp2)
  1169. HWND hWndDlg;
  1170. USHORT message;
  1171. MPARAM mp1;
  1172. MPARAM mp2;
  1173. {
  1174.  static SHORT sfValidate = TRUE;
  1175.  INT    i;
  1176.  static HWND  hWndParent;
  1177.  
  1178.  switch(message)
  1179.    {
  1180.     case WM_INITDLG:
  1181.          hWndParent = (HWND)mp2;
  1182.          cwCenter(hWndDlg, (HWND)hWndParent);
  1183.          break; /* End of WM_INITDLG */
  1184.  
  1185.     case WM_CONTROL:
  1186.          switch(SHORT1FROMMP(mp1))
  1187.            {
  1188.            }
  1189.          break; /* End of WM_CONTROL */
  1190.  
  1191.     case WM_COMMAND:
  1192.          switch(SHORT1FROMMP(mp1))
  1193.            {
  1194.             case DOCM_DDOCS: /* Button text: "Demo Docs"                   */
  1195.                  hWndDDOCMENU = WinLoadDlg(HWND_DESKTOP,
  1196.                                                 hWndDlg, (PFNWP)DDOCMENUMsgProc,
  1197.                                                 0, IDLG_DDOCMENU, (PBYTE)hWndParent);
  1198.                  break;
  1199.  
  1200.             case DOCM_PTECH: /* Button text: "Perf Techniques"             */
  1201.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  1202.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  1203.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  1204.                  break;
  1205.  
  1206.             case DOCM_PARMS: /* Button text: "Parameter Tuning"            */
  1207.                  hWndDOCPARMS = WinLoadDlg(HWND_DESKTOP,
  1208.                                                 hWndDlg, (PFNWP)DOCPARMSMsgProc,
  1209.                                                 0, IDLG_DOCPARMS, (PBYTE)hWndParent);
  1210.                  break;
  1211.  
  1212.             case DOCM_RDS: /* Button text: "RDS Docs"                      */
  1213.                  hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
  1214.                                                 hWndDlg, (PFNWP)SHOWTIMEMsgProc,
  1215.                                                 0, IDLG_SHOWTIME, (PBYTE)hWndParent);
  1216.                  break;
  1217.  
  1218.             case DEMOM_ARI: /* Button text: "A R I"                        */
  1219.                  hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
  1220.                                                 hWndDlg, (PFNWP)SHOWTIMEMsgProc,
  1221.                                                 0, IDLG_SHOWTIME, (PBYTE)hWndParent);
  1222.                  break;
  1223.  
  1224.             case DEMOM_RBLOCK: /* Button text: "Record Blocking"           */
  1225.                  hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
  1226.                                                 hWndDlg, (PFNWP)SHOWTIMEMsgProc,
  1227.                                                 0, IDLG_SHOWTIME, (PBYTE)hWndParent);
  1228.                  break;
  1229.  
  1230.             case DEMOM_STATDYN: /* Button text: "Static vs Dynamic"        */
  1231.                  hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
  1232.                                                 hWndDlg, (PFNWP)SHOWTIMEMsgProc,
  1233.                                                 0, IDLG_SHOWTIME, (PBYTE)hWndParent);
  1234.                  break;
  1235.  
  1236.             case DEMOM_INDICES: /* Button text: "I N D I C E S"            */
  1237.                  hWndSHOWTIME = WinLoadDlg(HWND_DESKTOP,
  1238.                                                 hWndDlg, (PFNWP)SHOWTIMEMsgProc,
  1239.                                                 0, IDLG_SHOWTIME, (PBYTE)hWndParent);
  1240.                  break;
  1241.  
  1242.             case MMENU_EXIT: /* Button text: "EXIT"                        */
  1243.                  break;
  1244.  
  1245.             case MMENU_HELP: /* Button text: "HELP"                        */
  1246.                  break;
  1247.  
  1248.            }
  1249.          break; /* End of WM_COMMAND */
  1250.  
  1251.     case WM_CLOSE:
  1252.          WinDismissDlg(hWndDlg, FALSE);
  1253.          break; /* End of WM_CLOSE */
  1254.  
  1255.     case WM_FAILEDVALIDATE:
  1256.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  1257.          sfValidate = FALSE;
  1258.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  1259.          sfValidate = TRUE;
  1260.          return((MRESULT)TRUE);
  1261.          break; /* End of WM_FAILEDVALIDATE */
  1262.  
  1263.     default:
  1264.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1265.          break;
  1266.    }
  1267.  return FALSE;
  1268. } /* End of MMENUMsgProc */
  1269.  
  1270.  
  1271. /***************************************************************************/
  1272. /*                                                                         */
  1273. /* Dialog Window Procedure                                                 */
  1274. /*                                                                         */
  1275. /* This procedure is associated with the dialog box that is included in    */
  1276. /* the function name of the procedure. It provides the service routines    */
  1277. /* for the events (messages) that occur because the end user operates      */
  1278. /* one of the dialog box's buttons, entry fields, or controls.             */
  1279. /*                                                                         */
  1280. /***************************************************************************/
  1281.  
  1282. MRESULT EXPENTRY DOCRDSMsgProc(hWndDlg, message, mp1, mp2)
  1283. HWND hWndDlg;
  1284. USHORT message;
  1285. MPARAM mp1;
  1286. MPARAM mp2;
  1287. {
  1288.  static SHORT sfValidate = TRUE;
  1289.  INT    i;
  1290.  static HWND  hWndParent;
  1291.  USHORT rc;
  1292.  switch(message)
  1293.    {
  1294.     case WM_INITDLG:
  1295.          hWndParent = (HWND)mp2;
  1296.          break; /* End of WM_INITDLG */
  1297.  
  1298.     case WM_CONTROL:
  1299.          switch(SHORT1FROMMP(mp1))
  1300.            {
  1301.            }
  1302.          break; /* End of WM_CONTROL */
  1303.  
  1304.     case WM_COMMAND:
  1305.          switch(SHORT1FROMMP(mp1))
  1306.            {
  1307.             case DRDS_REQ: /* Button text: "REQUESTER"                     */
  1308. //mycode b
  1309.              /* set up the text string pszDisplayTxt with the    */
  1310.              /* corresponding file for later display in edit box */
  1311.                  strcpy( temp_ebox_heading1, eboxh_rdsreq1);
  1312.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_rdsreq2, eboxh_rdsreq3);
  1313. //                 strcpy( temp_ebox_heading3, eboxh_rdsreq3);
  1314.                  rc = SetDlgText("rdsreq.txt");
  1315.                  if(rc)
  1316. //mycode e
  1317.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  1318.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  1319.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  1320.                  break;
  1321.  
  1322.             case DID_CANCEL: /* Button text: "CANCEL"                      */
  1323.                  /* Ignore data values entered into the dialog controls    */
  1324.                  /* and dismiss the dialog window                          */
  1325.                  WinDestroyWindow(hWndDlg);
  1326.                  hWndDOCRDS = 0;
  1327.                  break;
  1328.  
  1329.             case DRDS_HELP: /* Button text: "HELP"                         */
  1330.                  break;
  1331.  
  1332.             case DRDS_SRV: /* Button text: "SERVER"                        */
  1333.  //mycode b
  1334.               /* set up the text string pszDisplayTxt with the    */
  1335.               /* corresponding file for later display in edit box */
  1336.                   strcpy( temp_ebox_heading1, eboxh_rdssrv1 );
  1337.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_rdssrv2, eboxh_rdssrv3);
  1338. //                  strcpy( temp_ebox_heading3, eboxh_rdssrv3 );
  1339.                   rc = SetDlgText("rdssrv.txt");
  1340.                   if(rc)
  1341.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  1342.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  1343.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  1344.  //mycode e
  1345.                  break;
  1346.  
  1347.            }
  1348.          break; /* End of WM_COMMAND */
  1349.  
  1350.     case WM_CLOSE:
  1351.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  1352.          break; /* End of WM_CLOSE */
  1353.  
  1354.     case WM_FAILEDVALIDATE:
  1355.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  1356.          sfValidate = FALSE;
  1357.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  1358.          sfValidate = TRUE;
  1359.          return((MRESULT)TRUE);
  1360.          break; /* End of WM_FAILEDVALIDATE */
  1361.  
  1362.     default:
  1363.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1364.          break;
  1365.    }
  1366.  return FALSE;
  1367. } /* End of DOCRDSMsgProc */
  1368.  
  1369.  
  1370. /***************************************************************************/
  1371. /*                                                                         */
  1372. /* Dialog Window Procedure                                                 */
  1373. /*                                                                         */
  1374. /* This procedure is associated with the dialog box that is included in    */
  1375. /* the function name of the procedure. It provides the service routines    */
  1376. /* for the events (messages) that occur because the end user operates      */
  1377. /* one of the dialog box's buttons, entry fields, or controls.             */
  1378. /*                                                                         */
  1379. /***************************************************************************/
  1380. /* Generates the menu for selecting DBM parameter files                 */
  1381. /************************************************************************/
  1382.  
  1383. MRESULT EXPENTRY DOCPARMSMsgProc(hWndDlg, message, mp1, mp2)
  1384. HWND hWndDlg;
  1385. USHORT message;
  1386. MPARAM mp1;
  1387. MPARAM mp2;
  1388. {
  1389.  static SHORT sfValidate = TRUE;
  1390.  INT    i;
  1391.  static HWND  hWndParent;
  1392.  USHORT rc;
  1393.  
  1394.  switch(message)
  1395.    {
  1396.     case WM_INITDLG:
  1397.          hWndParent = (HWND)mp2;
  1398.          break; /* End of WM_INITDLG */
  1399.  
  1400.     case WM_CONTROL:
  1401.          switch(SHORT1FROMMP(mp1))
  1402.            {
  1403.            }
  1404.          break; /* End of WM_CONTROL */
  1405.  
  1406.     case WM_COMMAND:
  1407.          switch(SHORT1FROMMP(mp1))
  1408.            {
  1409.             case DPARMS_DBMAN: /* Button text: "Database Manager"          */
  1410. //mycode b
  1411.              /* set up the text string pszDisplayTxt with the    */
  1412.              /* corresponding file for later display in edit box */
  1413.                  strcpy( temp_ebox_heading1, eboxh_dbmparms1 );
  1414.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_dbmparms2, eboxh_dbmparms3);
  1415. //                 strcpy( temp_ebox_heading3, eboxh_dbmparms3 );
  1416.                  rc = SetDlgText("dbmparms.txt");
  1417.                  if(rc)
  1418. //mycode e
  1419.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  1420.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  1421.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  1422.                  break;
  1423.  
  1424.             case DPARMS_LOG: /* Button text: "Database Log"                */
  1425. //mycode b
  1426.              /* set up the text string pszDisplayTxt with the    */
  1427.              /* corresponding file for later display in edit box */
  1428.                  strcpy( temp_ebox_heading1, eboxh_dbparmsl1 );
  1429.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_dbparmsl2, eboxh_dbparmsl3);
  1430. //                 strcpy( temp_ebox_heading3, eboxh_dbparmsl3 );
  1431.                  rc = SetDlgText("dbparmsl.txt");
  1432.                  if(rc)
  1433. //mycode e
  1434.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  1435.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  1436.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  1437.                  break;
  1438.  
  1439.             case DPARMS_GENDB: /* Button text: "General Database "         */
  1440. //mycode b
  1441.              /* set up the text string pszDisplayTxt with the    */
  1442.              /* corresponding file for later display in edit box */
  1443.                  strcpy( temp_ebox_heading1, eboxh_dbparmsg1 );
  1444.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_dbparmsg2, eboxh_dbparmsg3);
  1445. //                 strcpy( temp_ebox_heading3, eboxh_dbparmsg3 );
  1446.                  rc = SetDlgText("dbparmsg.txt");
  1447.                  if(rc)
  1448. //mycode e
  1449.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  1450.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  1451.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  1452.                  break;
  1453.  
  1454.             case DPARMS_HEAP: /* Button text: "Database Heap"              */
  1455. //mycode b
  1456.              /* set up the text string pszDisplayTxt with the    */
  1457.              /* corresponding file for later display in edit box */
  1458.                  strcpy( temp_ebox_heading1, eboxh_dbparmsh1 );
  1459.                  sprintf( temp_ebox_heading2,"%s\n%s", eboxh_dbparmsh2, eboxh_dbparmsh3);
  1460. //                 strcpy( temp_ebox_heading3, eboxh_dbparmsh3 );
  1461.                  rc = SetDlgText("dbparmsh.txt");
  1462.                  if(rc)
  1463. //mycode e
  1464.                  hWndEDITBOX = WinLoadDlg(HWND_DESKTOP,
  1465.                                                 hWndDlg, (PFNWP)EDITBOXMsgProc,
  1466.                                                 0, IDLG_EDITBOX, (PBYTE)hWndParent);
  1467.                  break;
  1468.  
  1469.             case DID_CANCEL: /* Button text: "CANCEL"                      */
  1470.                  /* Ignore data values entered into the dialog controls    */
  1471.                  /* and dismiss the dialog window                          */
  1472.                  WinDestroyWindow(hWndDlg);
  1473.                  hWndDOCPARMS = 0;
  1474.                  break;
  1475.  
  1476.             case DPARMS_HELP: /* Button text: "HELP"                       */
  1477.                  break;
  1478.  
  1479.            }
  1480.          break; /* End of WM_COMMAND */
  1481.  
  1482.     case WM_CLOSE:
  1483.          WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DID_CANCEL), 0L);
  1484.          break; /* End of WM_CLOSE */
  1485.  
  1486.     case WM_FAILEDVALIDATE:
  1487.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  1488.          sfValidate = FALSE;
  1489.          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
  1490.          sfValidate = TRUE;
  1491.          return((MRESULT)TRUE);
  1492.          break; /* End of WM_FAILEDVALIDATE */
  1493.  
  1494.     default:
  1495.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
  1496.          break;
  1497.    }
  1498.  return FALSE;
  1499. } /* End of DOCPARMSMsgProc */
  1500.  
  1501.  
  1502.  
  1503.  
  1504. /***************************************************************************/
  1505. /*                                                                         */
  1506. /* cwRegisterClass Function                                                */
  1507. /*                                                                         */
  1508. /* The following function registers all the classes of all the windows     */
  1509. /* associated with this application. The function returns TRUE if it is    */
  1510. /* successful, otherwise it returns FALSE.                                 */
  1511. /*                                                                         */
  1512. /***************************************************************************/
  1513.  
  1514. INT cwRegisterClass()
  1515. {
  1516.  CLASSINFO ci;
  1517.  INT rc;
  1518.  
  1519.  strcpy(szAppName, "DBDEMO");
  1520.  rc = WinRegisterClass(hAB,             /* Anchor block handle             */
  1521.                       (PCH)szAppName,   /* Name of class being registered  */
  1522.                       (PFNWP)WndProc,   /* Window procedure for class      */
  1523.                       CS_SIZEREDRAW ,
  1524.                       2*sizeof(char FAR *));
  1525.  if (rc == FALSE)
  1526.    return(FALSE);
  1527.  
  1528.  WinQueryClassInfo(hAB, WC_ENTRYFIELD, (PCLASSINFO)&ci);
  1529.  pfnEditWndProc = ci.pfnWindowProc;
  1530.  rc = WinRegisterClass(hAB, "UDNumeric", UDNumericWndProc, CS_SIZEREDRAW,
  1531.                         ci.cbWindowData + sizeof(PVOID));
  1532.  if (rc == FALSE)
  1533.    return(FALSE);
  1534.  
  1535.  return(TRUE);
  1536. } /* End of cwRegisterClass */
  1537.  
  1538.  
  1539.  
  1540. /***************************************************************************/
  1541. /*                                                                         */
  1542. /* cwCreateWindow Function                                                 */
  1543. /*                                                                         */
  1544. /* The following function is used to create a window (the main window,     */
  1545. /* a child window, an icon window, etc.) and set it's initial size and     */
  1546. /* position. It returns the handle to the frame window.                    */
  1547. /*                                                                         */
  1548. /***************************************************************************/
  1549.  
  1550. HWND cwCreateWindow(
  1551.    HWND   hWndParent,  /* Handle to the parent of the window to be created */
  1552.    ULONG  ctldata,     /* Frame control flags for the window               */
  1553.    PCH    appname,     /* Class name of the window                         */
  1554.    PCH    title,       /* Title of the window                              */
  1555.    USHORT ResID,       /* Resource id value                                */
  1556.    INT    x,           /* Initial horizontal and vertical location         */
  1557.    INT    y,
  1558.    INT    cx,          /* Initial width and height of the window           */
  1559.    INT    cy,
  1560.    PHWND  hWndClient,  /* Handle to the client area of the window          */
  1561.    ULONG  lfStyle,     /* Frame window style                               */
  1562.    USHORT uSizeStyle)  /* User defined size and location flags             */
  1563. {
  1564.    USHORT rc;            /* accepts return codes from function calls       */
  1565.    HWND   hWndFrame;     /* local handle to created window frame           */
  1566.    USHORT SizeStyle;     /* local window positioning options               */
  1567.    CHAR   MsgBuffer[80]; /* buffer for error messages                      */
  1568.    HPS    hPS;           /* handle to a presentation space                 */
  1569.    int    xmod, ymod;    /* modifiers for sizing                           */
  1570.    #define DLGXMOD  4    /* Dialog units X modulo */
  1571.    #define DLGYMOD  8    /* Dialog units Y modulo */
  1572.    FONTMETRICS fm;       /* structure for determing modifiers              */
  1573.    /* Create the frame window                                              */
  1574.    hWndFrame = WinCreateStdWindow(hWndParent,  /* parent of window         */
  1575.                                   lfStyle,     /* frame window style       */
  1576.                                   &ctldata,    /* frame flags              */
  1577.                                   appname,     /* class name               */
  1578.                                   title,       /* window title             */
  1579.                                   0L,          /* client window style      */
  1580.                                   0,           /* module for resources     */
  1581.                                   ResID,       /* resource id              */
  1582.                                   (HWND FAR *)hWndClient); /* client handle*/
  1583.  
  1584.    /* if hWndFrame is NULL, an error occured when opening the window,      */
  1585.    /*     notify the user and exit this function                           */
  1586.    if(hWndFrame == 0)
  1587.      {
  1588.       WinLoadString(hAB, 0, IDS_ERR_WINDOW_CREATE, 80, MsgBuffer);
  1589.       WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
  1590.                     0, 0, MB_OK|MB_ICONEXCLAMATION);
  1591.       return((HWND)0);
  1592.      }
  1593.  
  1594.    /* set up size options                                                  */
  1595.    SizeStyle = SWP_ACTIVATE | SWP_ZORDER | uSizeStyle;
  1596.  
  1597.    /* if the height, width, intial x or initial y values are non-zero,     */
  1598.    /*     then we will need to set up the modifiers for size and location  */
  1599.    if((cx > 0) || (cy > 0) ||
  1600.       (x > 0)  || (y > 0))
  1601.      {
  1602.       hPS = WinGetPS(HWND_DESKTOP);
  1603.       GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &fm);
  1604.       xmod = (INT)fm.lAveCharWidth;
  1605.       ymod = (INT)fm.lMaxBaselineExt;
  1606.       WinReleasePS(hPS);
  1607.      }
  1608.    /* if either the width or the height are non-zero, then the size of the */
  1609.    /*     created window will be changed, set SizeStyle accordingly        */
  1610.    if((cx > 0) || (cy > 0))
  1611.      SizeStyle |= SWP_SIZE;
  1612.    /* set the size and position of the window and activate it              */
  1613.    rc = WinSetWindowPos(hWndFrame, HWND_TOP, 0, 0,
  1614.                         (USHORT)(cx * xmod)/DLGXMOD,
  1615.                         (USHORT)(cy * ymod)/DLGYMOD, SizeStyle);
  1616.  
  1617.    /* if the either the intial x or y position of the window is non-zero,  */
  1618.    /*    set the window to its new position                                */
  1619.    if((x > 0) || (y > 0))
  1620.      rc = WinSetWindowPos(hWndFrame, HWND_TOP,
  1621.                           (USHORT)(x * xmod)/DLGXMOD,
  1622.                           (USHORT)(y * ymod)/DLGYMOD, 0, 0, SWP_MOVE);
  1623.  
  1624.    /* if rc is not set to TRUE then WinSetWindowPos failed, notify the user*/
  1625.    /*     and exit this function                                           */
  1626.    if(!rc)
  1627.      {
  1628.       WinLoadString(hAB, 0, IDS_ERR_WINDOW_POS, 80, MsgBuffer);
  1629.       WinMessageBox(HWND_DESKTOP, hWndParent, MsgBuffer,
  1630.                     0, 0, MB_OK|MB_ICONEXCLAMATION);
  1631.       return((HWND)0);
  1632.      }
  1633.  
  1634.    /* return the handle to the frame window                                */
  1635.    return(hWndFrame);
  1636. }  /* End of cwCreateWindow */
  1637.  
  1638. int cwCreateClientControls(hWnd)
  1639. HWND hWnd;
  1640. {
  1641.  long  cyscroll;
  1642.  int   xmod, ymod;
  1643.  #define DLGXMOD  4    /* Dialog units X modulo */
  1644.  #define DLGYMOD  8    /* Dialog units Y modulo */
  1645.  HPS hPS;
  1646.  FONTMETRICS fm;
  1647.  
  1648.  hPS = WinGetPS(HWND_DESKTOP);
  1649.  GpiQueryFontMetrics(hPS, (LONG)sizeof(FONTMETRICS), &fm);
  1650.  xmod = (INT)fm.lAveCharWidth;
  1651.  ymod = (INT)fm.lMaxBaselineExt;
  1652.  cyscroll = 0;
  1653.  WinReleasePS(hPS);
  1654.  
  1655.  WinCreateWindow( hWnd,
  1656.                   WC_STATIC,
  1657.                   "RUN DEMO",
  1658.                   SS_GROUPBOX | WS_GROUP | WS_VISIBLE,
  1659.                   (USHORT)(236*xmod)/DLGXMOD, (USHORT)((44*ymod)/DLGYMOD+cyscroll),
  1660.                   (USHORT)(156*xmod)/DLGXMOD, (USHORT)(167*ymod)/DLGYMOD,
  1661.                   hWnd,
  1662.                   HWND_TOP,
  1663.                   257,
  1664.                   0,
  1665.                   0 );
  1666.  WinCreateWindow( hWnd,
  1667.                   WC_BUTTON,
  1668.                   "Demo Docs",
  1669.                   BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
  1670.                   (USHORT)(32*xmod)/DLGXMOD, (USHORT)((180*ymod)/DLGYMOD+cyscroll),
  1671.                   (USHORT)(99*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
  1672.                   hWnd,
  1673.                   HWND_TOP,
  1674.                   DOCM_DDOCS,
  1675.                   0,
  1676.                   0 );
  1677.  WinCreateWindow( hWnd,
  1678.                   WC_BUTTON,
  1679.                   "Perf Techniques",
  1680.                   BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
  1681.                   (USHORT)(32*xmod)/DLGXMOD, (USHORT)((144*ymod)/DLGYMOD+cyscroll),
  1682.                   (USHORT)(98*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
  1683.                   hWnd,
  1684.                   HWND_TOP,
  1685.                   DOCM_PTECH,
  1686.                   0,
  1687.                   0 );
  1688.  WinCreateWindow( hWnd,
  1689.                   WC_BUTTON,
  1690.                   "Parameter Tuning",
  1691.                   BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
  1692.                   (USHORT)(32*xmod)/DLGXMOD, (USHORT)((103*ymod)/DLGYMOD+cyscroll),
  1693.                   (USHORT)(98*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
  1694.                   hWnd,
  1695.                   HWND_TOP,
  1696.                   DOCM_PARMS,
  1697.                   0,
  1698.                   0 );
  1699.  WinCreateWindow( hWnd,
  1700.                   WC_BUTTON,
  1701.                   "RDS Docs",
  1702.                   BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
  1703.                   (USHORT)(32*xmod)/DLGXMOD, (USHORT)((62*ymod)/DLGYMOD+cyscroll),
  1704.                   (USHORT)(98*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
  1705.                   hWnd,
  1706.                   HWND_TOP,
  1707.                   DOCM_RDS,
  1708.                   0,
  1709.                   0 );
  1710.  WinCreateWindow( hWnd,
  1711.                   WC_BUTTON,
  1712.                   "A R I",
  1713.                   BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
  1714.                   (USHORT)(268*xmod)/DLGXMOD, (USHORT)((179*ymod)/DLGYMOD+cyscroll),
  1715.                   (USHORT)(98*xmod)/DLGXMOD, (USHORT)(12*ymod)/DLGYMOD,
  1716.                   hWnd,
  1717.                   HWND_TOP,
  1718.                   DEMOM_ARI,
  1719.                   0,
  1720.                   0 );
  1721.  WinCreateWindow( hWnd,
  1722.                   WC_BUTTON,
  1723.                   "Record Blocking",
  1724.                   BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
  1725.                   (USHORT)(268*xmod)/DLGXMOD, (USHORT)((143*ymod)/DLGYMOD+cyscroll),
  1726.                   (USHORT)(99*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
  1727.                   hWnd,
  1728.                   HWND_TOP,
  1729.                   DEMOM_RBLOCK,
  1730.                   0,
  1731.                   0 );
  1732.  WinCreateWindow( hWnd,
  1733.                   WC_BUTTON,
  1734.                   "Static vs Dynamic",
  1735.                   BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
  1736.                   (USHORT)(267*xmod)/DLGXMOD, (USHORT)((102*ymod)/DLGYMOD+cyscroll),
  1737.                   (USHORT)(99*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
  1738.                   hWnd,
  1739.                   HWND_TOP,
  1740.                   DEMOM_STATDYN,
  1741.                   0,
  1742.                   0 );
  1743.  WinCreateWindow( hWnd,
  1744.                   WC_BUTTON,
  1745.                   "I N D I C E S",
  1746.                   BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
  1747.                   (USHORT)(267*xmod)/DLGXMOD, (USHORT)((61*ymod)/DLGYMOD+cyscroll),
  1748.                   (USHORT)(99*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
  1749.                   hWnd,
  1750.                   HWND_TOP,
  1751.                   DEMOM_INDICES,
  1752.                   0,
  1753.                   0 );
  1754.  WinCreateWindow( hWnd,
  1755.                   WC_BUTTON,
  1756.                   "EXIT",
  1757.                   BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE,
  1758.                   (USHORT)(178*xmod)/DLGXMOD, (USHORT)((111*ymod)/DLGYMOD+cyscroll),
  1759.                   (USHORT)(34*xmod)/DLGXMOD, (USHORT)(13*ymod)/DLGYMOD,
  1760.                   hWnd,
  1761.                   HWND_TOP,
  1762.                   MMENU_EXIT,
  1763.                   0,
  1764.                   0 );
  1765.  WinCreateWindow( hWnd,
  1766.                   WC_BUTTON,
  1767.                   "HELP",
  1768.                   BS_PUSHBUTTON | BS_HELP | WS_TABSTOP | WS_VISIBLE,
  1769.                   (USHORT)(175*xmod)/DLGXMOD, (USHORT)((71*ymod)/DLGYMOD+cyscroll),
  1770.                   (USHORT)(38*xmod)/DLGXMOD, (USHORT)(12*ymod)/DLGYMOD,
  1771.                   hWnd,
  1772.                   HWND_TOP,
  1773.                   MMENU_HELP,
  1774.                   0,
  1775.                   0 );
  1776.  WinCreateWindow( hWnd,
  1777.                   WC_STATIC,
  1778.                   "DISPLAY DOCUMENTS",
  1779.                   SS_GROUPBOX | WS_GROUP | WS_VISIBLE,
  1780.                   (USHORT)(10*xmod)/DLGXMOD, (USHORT)((43*ymod)/DLGYMOD+cyscroll),
  1781.                   (USHORT)(148*xmod)/DLGXMOD, (USHORT)(167*ymod)/DLGYMOD,
  1782.                   hWnd,
  1783.                   HWND_TOP,
  1784.                   INIT_DLG,
  1785.                   0,
  1786.                   0 );
  1787. }
  1788.  
  1789.  
  1790. /***************************************************************************/
  1791. /*  cwNumericValidate Function                                             */
  1792. /*                                                                         */
  1793. /*  Returns TRUE if the string is acceptable, otherwise returns FALSE      */
  1794. /*                                                                         */
  1795. /***************************************************************************/
  1796.  
  1797. INT cwNumericValidate(string)
  1798. CHAR *string;
  1799. {
  1800.  INT count;
  1801.  for(count = 0; count <= (INT)strlen(string)-1; count++)
  1802.     if(isdigit((int)string[count]) ||
  1803.        (string[count] == '-' && count == 0))
  1804.          continue;
  1805.        else
  1806.          return(FALSE);
  1807.  return(TRUE);
  1808. }
  1809.  
  1810. /***************************************************************************/
  1811. /*  UDNumericWndProc                                                       */
  1812. /*                                                                         */
  1813. /*  Is used on subclassing edit fields for numeric validation              */
  1814. /*                                                                         */
  1815. /***************************************************************************/
  1816.  
  1817. MRESULT EXPENTRY UDNumericWndProc(hWnd, message, mp1, mp2)
  1818. HWND hWnd;
  1819. USHORT message;
  1820. MPARAM mp1;
  1821. MPARAM mp2;
  1822. {
  1823.  static CHAR key;
  1824.  ULONG  location;
  1825.  
  1826.  switch(message)
  1827.    {
  1828.     case WM_CHAR:
  1829.          if(SHORT2FROMMP(mp2) == VK_SPACE)
  1830.            return((MRESULT)TRUE);
  1831.          if(SHORT1FROMMP(mp1) & KC_VIRTUALKEY)
  1832.            break;
  1833.          if(SHORT1FROMMP(mp1) & KC_CHAR)
  1834.            {
  1835.             key = (CHAR)SHORT1FROMMP(mp2);
  1836.             if(isdigit((int)key))
  1837.               return(pfnEditWndProc(hWnd, message, mp1, mp2));
  1838.             else if(key == '-')
  1839.              {
  1840.               location = (ULONG)WinSendMsg(hWnd, EM_QUERYSEL, 0L, 0L);
  1841.               if(SHORT1FROMMP(location) != 0)
  1842.                 {
  1843.                  WinAlarm(HWND_DESKTOP, WA_ERROR);
  1844.                  return((MRESULT)TRUE);
  1845.                 }
  1846.                else
  1847.                 return(pfnEditWndProc(hWnd, message, mp1, mp2));
  1848.              }
  1849.             else
  1850.              {
  1851.               WinAlarm(HWND_DESKTOP, WA_ERROR);
  1852.               return((MRESULT)TRUE);
  1853.              }
  1854.            }
  1855.          break;
  1856.  
  1857.     case WM_TRANSLATEACCEL:
  1858.          return((MRESULT)FALSE);
  1859.          break;
  1860.    }
  1861.  return(pfnEditWndProc(hWnd, message, mp1, mp2));
  1862. } /* End of UDNumericWndProc */
  1863.  
  1864. /***************************************************************************/
  1865. /*  cwCenter Function                                                      */
  1866. /*                                                                         */
  1867. /*  Centers a dialog box on the client area of the caller                  */
  1868. /*                                                                         */
  1869. /***************************************************************************/
  1870.  
  1871. INT cwCenter(hWnd, hWndParent)
  1872. HWND hWnd;         /* handle of the window to be centered                  */
  1873. HWND hWndParent;   /* handle of the window to center on                    */
  1874. {
  1875.   ULONG  SrcX, SrcY;                /* Center of parent                    */
  1876.   INT    ix, iy;                    /* Destination points                  */
  1877.   SWP    DlgSwp, ParentSwp;         /* Set window position structures      */
  1878.   ULONG  ScreenWidth, ScreenHeight; /* Dimensions of the DESKTOP           */
  1879.   POINTL pt;                        /* Point                               */
  1880.  
  1881.   /* Determine the width and height of the DESKTOP so the dialog box       */
  1882.   /* will not be positioned to a point off of the screen.                  */
  1883.   ScreenWidth  = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
  1884.   ScreenHeight = (ULONG)WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
  1885.  
  1886.   /* Query width and depth of dialog box                                   */
  1887.   WinQueryWindowPos(hWnd, (PSWP)&DlgSwp);
  1888.  
  1889.   /* Query width and depth of caller                                       */
  1890.   WinQueryWindowPos(hWndParent, (PSWP)&ParentSwp);
  1891.  
  1892.   /* Map the point parent points to the Desktop                            */
  1893.   pt.x = ParentSwp.x;
  1894.   pt.y = ParentSwp.y;
  1895.  
  1896.   /* Convert the point from having our window as the origin to having      */
  1897.   /* the DESKTOP as the origin                                             */
  1898.   WinMapWindowPoints(hWndParent, HWND_DESKTOP, &pt, 1);
  1899.  
  1900.   SrcX = pt.x + (ParentSwp.cx / 2);
  1901.   SrcY = pt.y + (ParentSwp.cy / 2);
  1902.  
  1903.   /* Determine the point to move the dialog box to                         */
  1904.   ix = (INT)(SrcX - (DlgSwp.cx / 2));
  1905.   iy = (INT)(SrcY - (DlgSwp.cy / 2));
  1906.  
  1907.   /* if either point is less than zero, then set that point to zero        */
  1908.   /* so the dialog box will not be positoned off of the window             */
  1909.   ix = (ix < 0) ? 0 : ix;
  1910.   iy = (iy < 0) ? 0 : iy;
  1911.  
  1912.   /* if either point plus the height or width of the dialog box is         */
  1913.   /* greater than the height or width of the screen adjust point           */
  1914.   if(((ULONG)ix + DlgSwp.cx) > ScreenWidth)
  1915.     ix = (INT)(ScreenWidth - DlgSwp.cx);
  1916.   if(((ULONG)iy + DlgSwp.cy) > ScreenHeight)
  1917.     iy = (INT)(ScreenHeight - DlgSwp.cy);
  1918.  
  1919.   /* move the dialog box                                                   */
  1920.   return(WinSetWindowPos(hWnd, HWND_TOP, ix, iy, 0, 0, SWP_MOVE));
  1921. }
  1922.  
  1923.  
  1924.  
  1925. /* This function initializes the states of all dialog box radio buttons    */
  1926. /* and check boxes that have had their initial status set to true          */
  1927. INT cwSetInitDlgStatus(hWnd)
  1928. HWND hWnd;
  1929. {
  1930.   SHOWTIMEStruct FAR *Showtime;
  1931.   EDITBOXStruct FAR *Editbox;
  1932.  
  1933.   OFFSETOF(Showtime) = 0;
  1934.   DosAllocSeg(sizeof(SHOWTIMEStruct), (PSEL)&SELECTOROF(Showtime), 0);
  1935.   lmemset(Showtime, 0x00, sizeof(SHOWTIMEStruct));
  1936.   WinSetWindowULong(hWnd, OFFSET_SHOWTIME, (ULONG)Showtime);
  1937.  
  1938.   OFFSETOF(Editbox) = 0;
  1939.   DosAllocSeg(sizeof(EDITBOXStruct), (PSEL)&SELECTOROF(Editbox), 0);
  1940.   lmemset(Editbox, 0x00, sizeof(EDITBOXStruct));
  1941.   WinSetWindowULong(hWnd, OFFSET_EDITBOX, (ULONG)Editbox);
  1942.  
  1943. }
  1944.  
  1945. INT cwFreeDlgMemory(hWnd)
  1946. HWND hWnd;
  1947. {
  1948.   SHOWTIMEStruct FAR *Showtime;
  1949.   EDITBOXStruct FAR *Editbox;
  1950.  
  1951.   Showtime = (SHOWTIMEStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_SHOWTIME);
  1952.   DosFreeSeg(SELECTOROF(Showtime));
  1953.   Editbox = (EDITBOXStruct FAR *)WinQueryWindowULong(hWnd, OFFSET_EDITBOX);
  1954.   DosFreeSeg(SELECTOROF(Editbox));
  1955. }
  1956.  
  1957. void lmemset(memptr, value, size)
  1958. void FAR *memptr;
  1959. char     value;
  1960. int      size;
  1961. {
  1962.    char FAR *chrptr = memptr;
  1963.  
  1964.    while (size--)
  1965.       *chrptr++ = value;
  1966. }
  1967.  
  1968. /* LONGSTRCPY - is a functional equivalent to the C library routine        */
  1969. /*              strcpy, with the exception that it takes far pointers to   */
  1970. /*              to character strings as it's parameters.                   */
  1971. PSZ longstrcpy(target, source)
  1972. PSZ target;
  1973. PSZ source;
  1974. {
  1975.  PSZ z = target;
  1976.  while(*target++ = *source++);
  1977.  return(z);
  1978. }
  1979.  
  1980.  
  1981.  
  1982. INT SetDlgText(Filename)
  1983. unsigned char *Filename;
  1984. //unsigned char Filename[FILENAME_LENGTH];
  1985. {
  1986.  INT rc;
  1987.  FILE *fileh;
  1988.  long length;
  1989.  USHORT num_char = 0, num_read = 0;
  1990.  
  1991.          rc = TRUE;
  1992.          if ((fileh = fopen(Filename,"r+")) == NULL)
  1993.                   {
  1994.                   num_char = sprintf(szMessage,"RC for FILE_OPEN = %ld.\n",fileh);
  1995.                   WinMessageBox ( HWND_DESKTOP,
  1996.                   hWndClient,
  1997.                   szMessage,
  1998.                   "FILE ERRORS",
  1999.                   0,
  2000.                   MB_MOVEABLE | MB_OK | MB_CUANOTIFICATION );
  2001.                   rc = FALSE;
  2002.                   }
  2003.          if(rc)
  2004.            {
  2005.             if ((length = filelength(fileno(fileh))) == -1L)
  2006.                   {
  2007.                   num_char = sprintf(szMessage,"RC for FILE_LENGTH = %ld.\n",length);
  2008.                   WinMessageBox ( HWND_DESKTOP,
  2009.                   hWndClient,
  2010.                   szMessage,
  2011.                   "FILE ERRORS",
  2012.                   0,
  2013.                   MB_MOVEABLE | MB_OK | MB_CUANOTIFICATION );
  2014.                   rc = FALSE;
  2015.                   }
  2016.             if(rc)
  2017.                if ((pszDisplayTxt = (char *)malloc(length+1)) == NULL)
  2018.                   {
  2019.                   num_char = sprintf(szMessage,"MALLOC.\n");
  2020.                   WinMessageBox ( HWND_DESKTOP,
  2021.                   hWndClient,
  2022.                   szMessage,
  2023.                   "FILE ERRORS",
  2024.                   0,
  2025.                   MB_MOVEABLE | MB_OK | MB_CUANOTIFICATION );
  2026.                   rc = FALSE;
  2027.                   }
  2028.             if(rc)
  2029.                if ((num_read = fread((void *)pszDisplayTxt,sizeof(char),length,fileh)) != length)
  2030.                   {
  2031.                   // Next lines commented out because the number of bytes
  2032.                   // read is always different than filelength due to CR/LF.
  2033.          /***
  2034.                   num_char = sprintf(szMessage,
  2035.                   "FILE_READ ERROR.  Bytes read = %d. File size = %ld.\n",
  2036.                   num_read,length);
  2037.                   WinMessageBox ( HWND_DESKTOP,
  2038.                   hWndClient,
  2039.                   szMessage,
  2040.                   "FILE ERRORS",
  2041.                   0,
  2042.                   MB_MOVEABLE | MB_OK | MB_CUANOTIFICATION );
  2043.                   rc = FALSE;
  2044.          **/
  2045.                   }
  2046.             pszDisplayTxt[num_read] = '\0';
  2047.             pszDisplayTxt[length] = '\0';
  2048.             fclose(fileh);
  2049.             }
  2050.  
  2051. //         if(pszDisplayTxt != NULL)
  2052. //            free(pszDisplayTxt);
  2053.  
  2054.  return(rc);
  2055. } /* End of SetDlgText */
  2056. /***************************************************************************/
  2057. /* FUNCTION PMErrChk                                                       */
  2058. /*   puts up a message box in case of errors                               */
  2059. /***************************************************************************/
  2060. BOOL PMErrChk(hAB, hWnd, usermsg)
  2061. HAB  hAB;
  2062. HWND hWnd;
  2063. PSZ  usermsg;
  2064. {
  2065.   PERRINFO    perriBlk;
  2066.   PSZ         pszErrMsg;
  2067.   PUSHORT     pusTemp;
  2068.  
  2069.   if((perriBlk = WinGetErrorInfo(hAB)) == NULL)
  2070.       return(FALSE);
  2071.  
  2072.   SELECTOROF(pszErrMsg) = SELECTOROF(perriBlk);
  2073.   SELECTOROF(pusTemp) = SELECTOROF(perriBlk);
  2074.   OFFSETOF(pusTemp) = perriBlk->offaoffszMsg;
  2075.   OFFSETOF(pszErrMsg) = *pusTemp;
  2076.   if(ERRORIDSEV(perriBlk->idError) != SEVERITY_WARNING)
  2077.       WinMessageBox(HWND_DESKTOP, hWnd,
  2078.                      pszErrMsg, usermsg, 0, MB_CUACRITICAL | MB_OK);
  2079.   WinFreeErrorInfo(perriBlk);
  2080.   return(TRUE);
  2081. }
  2082. /***************************************************************************/
  2083. /* FUNCTION SQLthread                                                      */
  2084. /***************************************************************************/
  2085.     VOID _CDECL FAR SQLthread(hWndDlg)
  2086.     HWND hWndDlg;
  2087.     {
  2088.     USHORT rc=0;
  2089.    switch(demo_num)
  2090.      {
  2091.       case DEMO_INDICES:
  2092.         rc = indices();
  2093.         break;
  2094.       case DEMO_ARI:
  2095.         rc = ari();
  2096.         break;
  2097.       case DEMO_RBLOCK:
  2098.         rc = rblock();
  2099.         break;
  2100.       case DEMO_STATDYN:
  2101.         rc = stat_dyn();
  2102.         break;
  2103.       default:
  2104.          rc = DB_DEMO_NOT_AVAIL;
  2105.          break;
  2106.     }
  2107.     switch(rc)
  2108.      {
  2109.       case DB_RETURN_OK:
  2110.       if(!WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DISPLAY_TIME), 0L))
  2111.           PMErrChk(hAB, HWND_DESKTOP, "WinPostMsg() failed!");
  2112.         break;
  2113.       case DB_RETURN_BAD:
  2114.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  2115.          if(!WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DEMO_DIED), 0L))
  2116.              PMErrChk(hAB, HWND_DESKTOP, "WinPostMsg() failed!");
  2117.         break;
  2118.       case DB_DEMO_NOT_AVAIL:
  2119.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  2120.          if(!WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DEMO_NOT_AVAIL), 0L))
  2121.              PMErrChk(hAB, HWND_DESKTOP, "WinPostMsg() failed!");
  2122.         break;
  2123.       default:
  2124.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  2125.          if(!WinPostMsg(hWndDlg, WM_COMMAND, MPFROMSHORT(DEMO_NOT_AVAIL), 0L))
  2126.              PMErrChk(hAB, HWND_DESKTOP, "WinPostMsg() failed!");
  2127.         break;
  2128.      }
  2129.     _endthread();
  2130.    }
  2131.  
  2132.     VOID FAR StartDB(sqlca)
  2133.     struct sqlca *sqlca;
  2134.     {
  2135.     unsigned char label[23];                   /* store db api CALL   */
  2136.     strcpy(label,"start_db");
  2137.     sqlestrd("bank",'S',sqlca);
  2138.     if(sqlca->sqlcode != 0)
  2139.        {
  2140.        WinAlarm(HWND_DESKTOP, WA_ERROR);
  2141.        }
  2142.  
  2143.     }/* end StartDB */
  2144.  
  2145.     VOID FAR StopDB(sqlca)
  2146.     struct sqlca *sqlca;
  2147.     {
  2148.         sqlestpd(sqlca);
  2149.     }
  2150.