home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / MSJV5-6.ZIP / FORM2.ZIP / FORM2.C < prev    next >
C/C++ Source or Header  |  1990-11-01  |  20KB  |  735 lines

  1. /*
  2.  * FORM LIBRARY - EDIT FORM MODULE
  3.  *
  4.  * LANGUAGE      : Microsoft C 5.1
  5.  * MODEL         : medium
  6.  * ENVIRONMENT   : Microsoft Windows 3.0 SDK
  7.  * STATUS        : operational
  8.  *
  9.  *    Eikon Systems, Inc.
  10.  *    989 East Hillsdale Blvd, Suite 260
  11.  *    Foster City, California 94404
  12.  *    415-349-4664
  13.  *
  14.  * 07/12/90 1.00 - Kevin P. Welch - initial creation.
  15.  *
  16.  */
  17.  
  18. #define  NOCOMM
  19.  
  20. #include <windows.h>
  21. #include <control.h>
  22.  
  23. #include "page.h"
  24.  
  25. #include "form.h"
  26. #include "form.d"
  27.  
  28. /* local macro definitions */
  29. #define  xRCtoDEV(x,y)        (((x)*LOWORD(y))/4)
  30. #define  yRCtoDEV(x,y)        (((x)*HIWORD(y))/8)
  31. #define  xDEVtoRC(x,y)        (((x)*4)/LOWORD(y))
  32. #define  yDEVtoRC(x,y)        (((x)*8)/HIWORD(y))
  33.  
  34. /* local function definitions */
  35. VOID FAR PASCAL   EditDisplay( HWND, WORD );
  36. BOOL FAR PASCAL   EditInit( HWND, WORD, LONG );
  37. BOOL FAR PASCAL   EditControl( HWND, WORD, LONG );
  38. BOOL FAR PASCAL   EditCommand( HWND, WORD, LONG );
  39. BOOL FAR PASCAL   EditDestroy( HWND, WORD, LONG );
  40.  
  41. /* */
  42.  
  43. /*
  44.  * FormEdit( hWndParent, hData ) : HANDLE
  45.  *
  46.  *    hWndParent     handle to parent window
  47.  *    hData          handle to form data block
  48.  *
  49.  * This function displays a dialog box, enabling the user to enter
  50.  * data using a series of linked dialog boxes.  The value returned by
  51.  * this function is a global handle with the new data block.  If a NULL
  52.  * handle is returned then it can be assumed that the data entry was
  53.  * cancelled.
  54.  *
  55.  */
  56.  
  57. HANDLE FAR PASCAL FormEdit(
  58.    HWND           hWndParent,
  59.    HANDLE         hData )
  60. {
  61.    DLGBOX         DlgBox;
  62.    HANDLE         hResult;
  63.    HANDLE         hResInfo;
  64.    HANDLE         hResData;
  65.    HANDLE         hDlgData;
  66.    LPSTR          lpResData;
  67.    LPDLGBOX       lpDlgData;
  68.  
  69.    /* initialization */
  70.    hResult = NULL;
  71.    FormInfo.hTempData = hData;
  72.  
  73.    /* find first dialog box */
  74.    hResInfo = FindResource( FormInfo.hInstance, "Page1", RT_DIALOG );
  75.    if ( hResInfo ) {
  76.  
  77.       /* load first dialog box */
  78.       hResData = LoadResource( FormInfo.hInstance, hResInfo );
  79.       if ( hResData ) {
  80.  
  81.          /* access first dialog box */
  82.          lpResData = LockResource( hResData );
  83.          if ( lpResData ) {
  84.             
  85.             /* retrieve dialog box */
  86.             GetDlg( lpResData, &DlgBox );
  87.             UnlockResource( hResData );
  88.       
  89.             /* allocate dialog template */
  90.             hDlgData = GlobalAlloc( GMEM_MOVEABLE|GMEM_ZEROINIT, (DWORD)sizeof(DLGBOX) );
  91.             if ( hDlgData ) {
  92.  
  93.                /* define the contents */
  94.                lpDlgData = (LPDLGBOX)GlobalLock( hDlgData );
  95.                if ( lpDlgData ) {
  96.  
  97.                   lpDlgData->lStyle = WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | WS_POPUP;
  98.                   lpDlgData->wControls = 0;
  99.                   lpDlgData->wX = 0;
  100.                   lpDlgData->wY = 0;
  101.                   lpDlgData->wCX = DlgBox.wCX + 48;
  102.                   lpDlgData->wCY = DlgBox.wCY + 20;
  103.  
  104.                   lpDlgData->szMenu[0] = 0;
  105.                   lpDlgData->szClass[0] = 0;
  106.  
  107.                   StringCopy( 
  108.                      lpDlgData->szCaption, 
  109.                      FormInfo.szTitle,
  110.                      sizeof(lpDlgData->szCaption)
  111.                   );
  112.  
  113.                   /* unlock template */
  114.                   GlobalUnlock( hDlgData );
  115.  
  116.                   /* install keyboard hook & edit form */
  117.                   FormInfo.fnOldMsgHook = SetWindowsHook( WH_MSGFILTER, FormMsgHookFn );
  118.                   hResult = DialogBoxIndirect( FormInfo.hInstance, hDlgData, hWndParent, FormEditDlgFn );
  119.                   UnhookWindowsHook( WH_MSGFILTER, FormMsgHookFn );
  120.  
  121.                   /* remove keyboard hook */
  122.                   FormInfo.fnOldMsgHook = NULL;
  123.    
  124.                }
  125.  
  126.                /* free template */
  127.                GlobalFree( hDlgData );
  128.  
  129.             }
  130.  
  131.          }
  132.  
  133.          FreeResource( hResData );
  134.  
  135.       }
  136.    }
  137.  
  138.    /* return final result */
  139.    return( hResult );
  140.  
  141. }
  142.  
  143. /* */
  144.  
  145. /*
  146.  * FormEditDlgFn( hDlg, wMessage, wParam, lParam ) : BOOL;
  147.  *
  148.  *    hDlg           dialog box window handle
  149.  *    wMessage       dialog box message
  150.  *    wParam         word parameter
  151.  *    lParam         long parameter
  152.  *
  153.  * This function is responsible for processsing all the messages relating
  154.  * to the edit form dialog box.
  155.  *
  156.  */
  157.  
  158. BOOL FAR PASCAL FormEditDlgFn(
  159.    HWND     hDlg,
  160.    WORD     wMessage,
  161.    WORD     wParam,
  162.    LONG     lParam )
  163. {
  164.    BOOL     bResult;
  165.  
  166.    /* process message */
  167.    switch ( wMessage )
  168.       {
  169.    case WM_INITDIALOG : /* initialize dialog box */
  170.       bResult = EditInit( hDlg, wParam, lParam );
  171.       break;
  172.    case WM_CTLCOLOR : /* window control color */
  173.       bResult = EditControl( hDlg, wParam, lParam );
  174.       break;
  175.    case WM_USER : /* user defined message */
  176.       bResult = EditControl( hDlg, 0, MAKELONG(GetFocus(),0) );
  177.       break;
  178.    case WM_COMMAND: /* dialog command */
  179.       bResult = EditCommand( hDlg, wParam, lParam );
  180.       break;
  181.    case WM_DESTROY : /* destroy dialog box */
  182.       bResult = EditDestroy( hDlg, wParam, lParam );
  183.       break;
  184.    default : /* some other message */
  185.       bResult = FALSE;
  186.       break;
  187.    }
  188.  
  189.    /* return final result */
  190.    return bResult;
  191.  
  192. }
  193.  
  194. /* */
  195.  
  196. /*
  197.  * EditInit( hDlg, wParam, lParam ) : BOOL;
  198.  *
  199.  *    hDlg           handle to dialog box
  200.  *    wParam         word parameter
  201.  *    lParam         long parameter
  202.  *
  203.  * The function defines each of the control pages and initializes the
  204.  * dialog box.  A value of TRUE is returned if the process was successful
  205.  * and the dialog box manager is to set the window with the initial
  206.  * input focus.  A value of FALSE is returned if the process was
  207.  * successful and the dialog box manager is not to set the window with
  208.  * the initial input focus.
  209.  *
  210.  */
  211.  
  212. BOOL FAR PASCAL EditInit(
  213.    HWND        hDlg,
  214.    WORD        wParam,
  215.    LONG        lParam )
  216. {
  217.    WORD        wPage;
  218.    WORD        wWidth;
  219.    WORD        wHeight;
  220.    WORD        wControl;
  221.    LONG        lDlgUnits;
  222.    HWND        hWndCtl;
  223.    HANDLE      hDlgInfo;
  224.    HANDLE      hDlgData;
  225.    HANDLE      hCtlList;
  226.    RECT        rcClient;
  227.    LPSTR       lpDlgData;
  228.    HWND FAR *  lpCtlList;
  229.  
  230.    char        szCtlName[MAX_NAME];
  231.    char        szDlgName[MAX_NAME];
  232.    char        szCtlData[MAX_DATA];
  233.  
  234.    DLGBOX      DlgBox;
  235.    DLGCTL      DlgCtl;
  236.  
  237.    /* warning level 3 compatibility */
  238.    wParam;
  239.    lParam;
  240.    
  241.    /* define property lists */
  242.    SET_COMMENT( hDlg, NULL );
  243.    SET_CRNTPAGE( hDlg, NULL );
  244.    SET_DATA( hDlg, FormInfo.hTempData );
  245.    
  246.    /* retrieve dialog base units */
  247.    lDlgUnits = GetDialogBaseUnits();
  248.  
  249.    /* calculate dialog box dimensions in RC coordinates */
  250.    GetClientRect( hDlg, &rcClient );
  251.    
  252.    wWidth = xDEVtoRC( rcClient.right - rcClient.left, lDlgUnits );
  253.    wHeight = yDEVtoRC( rcClient.bottom - rcClient.top, lDlgUnits );
  254.    
  255.    /* create all controls associated with the base page */
  256.    CreateWindow(
  257.       "button",
  258.       "&Save",
  259.       BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP | WS_CHILD | WS_VISIBLE,
  260.       xRCtoDEV(wWidth-36,lDlgUnits),
  261.       yRCtoDEV(4,lDlgUnits),
  262.       xRCtoDEV(32,lDlgUnits),
  263.       yRCtoDEV(12,lDlgUnits),
  264.       hDlg,
  265.       ID0_SAVE,
  266.       INSTANCE(PARENT(hDlg)),
  267.       NULL
  268.    );
  269.      
  270.    CreateWindow(
  271.       "button",
  272.       "&Print",
  273.       BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE,
  274.       xRCtoDEV(wWidth-36,lDlgUnits),
  275.       yRCtoDEV(18,lDlgUnits),
  276.       xRCtoDEV(32,lDlgUnits),
  277.       yRCtoDEV(12,lDlgUnits),
  278.       hDlg,
  279.       ID0_PRINT,
  280.       INSTANCE(PARENT(hDlg)),
  281.       NULL
  282.    );
  283.  
  284.    CreateWindow(
  285.       "button",
  286.       "Cancel",
  287.       BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 
  288.       xRCtoDEV(wWidth-36,lDlgUnits), 
  289.       yRCtoDEV(32,lDlgUnits), 
  290.       xRCtoDEV(32,lDlgUnits), 
  291.       yRCtoDEV(12,lDlgUnits),
  292.       hDlg,
  293.       ID0_CANCEL,
  294.       INSTANCE(PARENT(hDlg)),
  295.       NULL
  296.    );
  297.  
  298.    CreateWindow(
  299.       "page",
  300.       "",
  301.       WS_GROUP | WS_TABSTOP | WS_CHILD | WS_VISIBLE,
  302.       xRCtoDEV(wWidth-36,lDlgUnits),
  303.       yRCtoDEV(48,lDlgUnits),
  304.       xRCtoDEV(32,lDlgUnits),
  305.       yRCtoDEV(wHeight-52,lDlgUnits),
  306.       hDlg,
  307.       ID0_PAGE,
  308.       INSTANCE(PARENT(hDlg)),
  309.       NULL
  310.    );
  311.    
  312.    CreateWindow(
  313.       "static",
  314.       "Help text associated with control.",
  315.       SS_LEFT | WS_GROUP | WS_CHILD | WS_VISIBLE,
  316.       xRCtoDEV(4,lDlgUnits),
  317.       yRCtoDEV(wHeight-12,lDlgUnits),
  318.       xRCtoDEV(wWidth-48,lDlgUnits),
  319.       yRCtoDEV(8,lDlgUnits),
  320.       hDlg,
  321.       ID0_COMMENT,
  322.       INSTANCE(PARENT(hDlg)),
  323.       NULL
  324.    ); 
  325.  
  326.    CreateWindow(
  327.       "static",
  328.       "",
  329.       SS_BLACKFRAME | WS_CHILD | WS_VISIBLE,
  330.       xRCtoDEV(wWidth-40,lDlgUnits),
  331.       yRCtoDEV(0,lDlgUnits),
  332.       xRCtoDEV(1,lDlgUnits),
  333.       yRCtoDEV(wHeight,lDlgUnits),
  334.       hDlg,
  335.       (WORD)-1,
  336.       INSTANCE(PARENT(hDlg)),
  337.       NULL
  338.    );
  339.    
  340.    /* create all controls associated with each page */
  341.    for ( wPage=1; wPage<=FormInfo.wPages; wPage++ ) {
  342.  
  343.       /* define dialog box name */
  344.       wsprintf( szDlgName, "Page%u", wPage );
  345.  
  346.       /* load dialog page */
  347.       hDlgInfo = FindResource( FormInfo.hInstance, szDlgName, RT_DIALOG );
  348.       if ( hDlgInfo ) {
  349.  
  350.          /* load resource information */
  351.          hDlgData = LoadResource( FormInfo.hInstance, hDlgInfo );
  352.          if ( hDlgData ) {
  353.  
  354.             /* lock resource data */
  355.             lpDlgData = LockResource( hDlgData );
  356.             if ( lpDlgData ) {
  357.  
  358.                /* extract dialog box */
  359.                GetDlg( lpDlgData, &DlgBox );
  360.  
  361.                /* allocate space for window handle list */
  362.                hCtlList = GlobalAlloc( GMEM_MOVEABLE|GMEM_ZEROINIT, (DWORD)((DlgBox.wControls+4)*sizeof(HWND)) );
  363.                if ( hCtlList ) {
  364.                   
  365.                   /* lock the data down */
  366.                   lpCtlList = (HWND FAR *)GlobalLock( hCtlList );
  367.                   if ( lpCtlList ) {
  368.  
  369.                      lpCtlList[0] = (HWND)DlgBox.wControls;
  370.  
  371.                      /* extract each control */
  372.                      for ( wControl=0; wControl<DlgBox.wControls; wControl++ ) {
  373.  
  374.                         /* extract control (albeit inefficiently) */
  375.                         GetCtl( lpDlgData, wControl, &DlgCtl );
  376.                         
  377.                         /* create window */
  378.                         hWndCtl = CreateWindow (
  379.                                        DlgCtl.szClass,
  380.                                        DlgCtl.szText,
  381.                                        DlgCtl.lStyle,
  382.                                        xRCtoDEV(DlgCtl.wX+4,lDlgUnits),
  383.                                        yRCtoDEV(DlgCtl.wY+4,lDlgUnits),
  384.                                        xRCtoDEV(DlgCtl.wCX,lDlgUnits),
  385.                                        yRCtoDEV(DlgCtl.wCY,lDlgUnits),
  386.                                        hDlg,
  387.                                        DlgCtl.wID,
  388.                                        INSTANCE(PARENT(hDlg)),
  389.                                        NULL
  390.                                     );  
  391.  
  392.                         /* continue if successful */
  393.                         if ( hWndCtl ) {
  394.  
  395.                            /* hide window & save window handle */
  396.                            ShowWindow( hWndCtl, SW_HIDE );
  397.                            lpCtlList[wControl+1] = hWndCtl;
  398.  
  399.                            /* define control data */
  400.                            if ( GetCtlName(FormInfo.hInstance,DlgCtl.wID,szCtlName,sizeof(szCtlName)) ) 
  401.                               if ( GetCtlData(GET_DATA(hDlg),szCtlName,szCtlData,sizeof(szCtlData)) ) 
  402.                                  SetCtlData( hDlg, hWndCtl, &DlgCtl, szCtlData );
  403.  
  404.                         } else {
  405.                            lpCtlList[wControl+1] = NULL;
  406.                            WARNING( NULL, "Unable to create control!" );
  407.                         }
  408.                
  409.                      }
  410.  
  411.                      /* unlock the data & store */
  412.                      GlobalUnlock( hCtlList );
  413.                      SET_CTLLIST( hDlg, wPage, hCtlList );
  414.  
  415.                   } else
  416.                      WARNING( NULL, "Unable to lock control list!" );
  417.                
  418.                } else
  419.                   WARNING( NULL, "Unable to allocate control list!" );
  420.  
  421.                /* unlock resource */
  422.                UnlockResource( hDlgData );
  423.  
  424.             } else
  425.                WARNING( NULL, "Unable to lock page information!" );
  426.  
  427.             /* free resource */
  428.             FreeResource( hDlgData );
  429.  
  430.          } else
  431.             WARNING( NULL, "Unable to load page information!" );
  432.  
  433.       } else
  434.          WARNING( NULL, "Unable to find page information!" );
  435.  
  436.    }
  437.  
  438.    /* center dialog box within parent window */
  439.    CenterPopup( hDlg, GetParent(hDlg) );
  440.  
  441.    /* define page selector range */
  442.    SendMessage( 
  443.       GetDlgItem(hDlg,ID0_PAGE), 
  444.       PM_SETRANGE, 
  445.       FormInfo.wPages, 
  446.       0L
  447.    );
  448.  
  449.    /* display first page */
  450.    EditDisplay( hDlg, 1 );
  451.  
  452.    /* return result */
  453.    return( FALSE );
  454.  
  455. }
  456.  
  457. /* */
  458.  
  459. /*
  460.  * EditControl( hDlg, wParam, lParam ) : BOOL;
  461.  *
  462.  *    hDlg           handle to dialog box
  463.  *    wParam         word parameter
  464.  *    lParam         long parameter
  465.  *
  466.  * The function is responsible for handling the WM_CTLCOLOR message
  467.  * and displaying the related help text in the comment field.  A value
  468.  * of TRUE is returned if the WM_CTLCOLOR message was processed.
  469.  *
  470.  */
  471.  
  472. BOOL FAR PASCAL EditControl(
  473.    HWND        hDlg,
  474.    WORD        wParam,
  475.    LONG        lParam )
  476. {
  477.    char        szComment[256];
  478.  
  479.    /* warning level 3 compatibility */
  480.    wParam;
  481.    
  482.    /* display appropriate help text comment */
  483.    if ( (LOWORD(lParam)!=GET_COMMENT(hDlg))&&(IsWindowEnabled(hDlg))&&(LOWORD(lParam)==GetFocus()) ) {
  484.  
  485.       /* update instance variable */
  486.       SET_COMMENT( hDlg, LOWORD(lParam) );
  487.    
  488.       /* define new comment */
  489.       switch( ID(LOWORD(lParam)) )
  490.          {
  491.       case ID0_SAVE :
  492.          SetWindowText(
  493.             GetDlgItem(hDlg,ID0_COMMENT), 
  494.             "Save data entry form contents."
  495.          );
  496.          break;
  497.       case ID0_PRINT :
  498.          SetWindowText( 
  499.             GetDlgItem(hDlg,ID0_COMMENT), 
  500.             "Print data entry form contents."
  501.          );
  502.          break;
  503.       case ID0_CANCEL :
  504.          SetWindowText( 
  505.             GetDlgItem(hDlg,ID0_COMMENT), 
  506.             "Close data entry form without saving."
  507.          );
  508.          break;
  509.       case ID0_PAGE :
  510.          SetWindowText( 
  511.             GetDlgItem(hDlg,ID0_COMMENT), 
  512.             "Data entry form page selector."
  513.          );
  514.          break;
  515.       default :
  516.          GetCtlComment( INSTANCE(hDlg), ID(LOWORD(lParam)), szComment, sizeof(szComment) );
  517.          SetWindowText( GetDlgItem(hDlg,ID0_COMMENT), szComment );
  518.          break;
  519.       }
  520.  
  521.    }
  522.  
  523.    /* return result */
  524.    return( FALSE );
  525.  
  526. }
  527.  
  528. /* */
  529.  
  530. /*
  531.  * EditCommand( hDlg, wParam, lParam ) : BOOL;
  532.  *
  533.  *    hDlg           handle to dialog box
  534.  *    wParam         word parameter
  535.  *    lParam         long parameter
  536.  *
  537.  * The function is responsible for handling the WM_COMMAND messages
  538.  * received by the main dialog box window function.  A value of TRUE
  539.  * is returned if the process was successful.
  540.  *
  541.  */
  542.  
  543. BOOL FAR PASCAL EditCommand(
  544.    HWND        hDlg,
  545.    WORD        wParam,
  546.    LONG        lParam )
  547. {
  548.    
  549.    /* make sure control description field is updated */
  550.    EditControl( hDlg, 0, MAKELONG(GetFocus(),0) );
  551.  
  552.    /* process commands */
  553.    switch( wParam )
  554.       {
  555.    case ID0_SAVE : /* save updated form */
  556.    case IDOK :
  557.       {
  558.          HANDLE      hData;
  559.  
  560.          hData = GetDlgData( hDlg );
  561.          if ( hData )
  562.             EndDialog( hDlg, hData );
  563.          else
  564.             WARNING( hDlg, "Unable to save form!" );
  565.  
  566.       }
  567.       break;
  568.    case ID0_PRINT : /* print current form */
  569.       {
  570.          HANDLE      hData;
  571.  
  572.          hData = GetDlgData( hDlg );
  573.          if ( hData ) {
  574.             FormPrint( hDlg, hData );
  575.             GlobalFree( hData );
  576.          } else
  577.             WARNING( hDlg, "Unable to print form!" );
  578.  
  579.       }
  580.       break;
  581.    case ID0_CANCEL : /* cancel data entry */
  582.    case IDCANCEL :
  583.       
  584.       /* verify user intentions */
  585.       if ( MessageBox(hDlg,"Close form without saving changes?",FormInfo.szTitle,MB_YESNO|MB_ICONQUESTION) == IDYES )
  586.          EndDialog( hDlg, NULL );
  587.  
  588.       break;
  589.    case ID0_PAGE : /* new dialog page selected */
  590.  
  591.       /* display appropriate page */
  592.       if ( HIWORD(lParam) == PN_SELCHANGE ) 
  593.          EditDisplay( hDlg, (WORD)SendMessage(LOWORD(lParam),PM_GETSELECT,0,0L)+1 );
  594.  
  595.       break;
  596.    default : /* something else - ignore */
  597.       break;
  598.    }
  599.  
  600.    /* return result */
  601.    return( TRUE );
  602.  
  603. }
  604.  
  605. /* */
  606.  
  607. /*
  608.  * EditDisplay( hDlg, wNewPage ) : VOID;
  609.  *
  610.  *    hDlg           handle to a dialog box
  611.  *    wNewPage       number of page to display
  612.  *
  613.  * This function hides the controls relating to the old dialog box
  614.  * page and displays those associated with the new one.  If a NULL
  615.  * page number is specified then it is assumed not to be present.
  616.  *
  617.  */
  618.  
  619. VOID FAR PASCAL EditDisplay(
  620.    HWND        hDlg,
  621.    WORD        wNewPage )
  622. {
  623.    WORD        wOldPage;
  624.    WORD        wControl;
  625.    WORD        wControls;
  626.    HWND FAR *  lpCtlList;
  627.  
  628.    /* retrieve old page */
  629.    wOldPage = GET_CRNTPAGE(hDlg);
  630.  
  631.    /* hide old page */
  632.    if ( wOldPage && GET_CTLLIST(hDlg,wOldPage) ) {
  633.  
  634.       /* access controls associated with old page */
  635.       lpCtlList = (HWND FAR *)GlobalLock( GET_CTLLIST(hDlg,wOldPage) );
  636.       if ( lpCtlList ) {
  637.  
  638.          /* retrieve number of controls */
  639.          wControls = (WORD)lpCtlList[0];
  640.  
  641.          /* hide each control */
  642.          for ( wControl=1; wControl<=wControls; wControl++ ) {
  643.             ShowWindow( lpCtlList[wControl], SW_HIDE );
  644.             UpdateWindow( lpCtlList[wControl] );
  645.          }
  646.  
  647.          /* unlock list */
  648.          GlobalUnlock( GET_CTLLIST(hDlg,wOldPage) );
  649.  
  650.       } else
  651.          WARNING( NULL, "Unable to lock control list!" );
  652.  
  653.    }
  654.  
  655.    /* display new page */
  656.    if ( wNewPage && GET_CTLLIST(hDlg,wNewPage) ) {
  657.  
  658.       /* access controls associated with new page */
  659.       lpCtlList = (HWND FAR *)GlobalLock( GET_CTLLIST(hDlg,wNewPage) );
  660.       if ( lpCtlList ) {
  661.  
  662.          /* retrieve number of controls */
  663.          wControls = (WORD)lpCtlList[0];
  664.  
  665.          /* display each control (in reverse order) */
  666.          for ( wControl=wControls; wControl>0; wControl-- ) {
  667.             ShowWindow( lpCtlList[wControl], SW_SHOW );
  668.             UpdateWindow( lpCtlList[wControl] );
  669.          } 
  670.  
  671.          /* set focus to first in list (if desired) */
  672.          if ( GetFocus() != GetDlgItem(hDlg,ID0_PAGE) )
  673.             SetFocus( lpCtlList[1] );
  674.          
  675.          /* unlock list */
  676.          GlobalUnlock( GET_CTLLIST(hDlg,wNewPage) );
  677.  
  678.       } else
  679.          WARNING( NULL, "Unable to lock control list!" );
  680.  
  681.    }
  682.  
  683.    /* update property list */
  684.    SET_CRNTPAGE( hDlg, wNewPage );
  685.  
  686. }
  687.  
  688. /* */
  689.  
  690. /*
  691.  * EditDestroy( hDlg, wParam, lParam ) : BOOL;
  692.  *
  693.  *    hDlg           handle to dialog box
  694.  *    wParam         word parameter
  695.  *    lParam         long parameter
  696.  *
  697.  * The function is responsible for handling the case when the
  698.  * WM_DESTROY message is received by the main dialog box window
  699.  * function.  A value of TRUE is returned if the cleanup process
  700.  * was successful.
  701.  *
  702.  */
  703.  
  704. BOOL FAR PASCAL EditDestroy(
  705.    HWND        hDlg,
  706.    WORD        wParam,
  707.    LONG        lParam )
  708. {
  709.    WORD        wPage;
  710.    HANDLE      hCtlList;
  711.  
  712.    /* warning level 3 compatibility */
  713.    wParam;
  714.    lParam;
  715.    
  716.    /* remove property lists */
  717.    REM_DATA( hDlg );
  718.    REM_COMMENT( hDlg );
  719.    REM_CRNTPAGE( hDlg );
  720.  
  721.    for ( wPage=1; wPage<=FormInfo.wPages; wPage++ ) {
  722.       hCtlList = REM_CTLLIST(hDlg,wPage);
  723.       if ( hCtlList )
  724.          GlobalFree( hCtlList );
  725.    }
  726.    
  727.    /* return result */
  728.    return( TRUE );
  729.  
  730. }
  731.  
  732.  
  733.  
  734.  
  735.