home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pendem.zip / BOOK.C < prev    next >
C/C++ Source or Header  |  1994-07-21  |  121KB  |  3,277 lines

  1. /* =========================================================================
  2.  *   Sarka Martinez (407) 982- 5580, Pen Developer Magazine July/August '94 page 73
  3.  *
  4.  *          Copyright.
  5.  *
  6.  *                      OCO Source Materials
  7.  *
  8.  *                      5706-110 (C) Copyright IBM Corp. 1993
  9.  *
  10.  * ======================================================================== */
  11.  
  12. /* ======================================================================
  13.  *                            IBM CONFIDENTIAL
  14.  * ======================================================================
  15.  *
  16.  *  product name.
  17.  *
  18.  *  Filespec.                 BOOK.C
  19.  *
  20.  *  Author.                   Sarka Martinez
  21.  *
  22.  *  Date-Written.             05-04-1993
  23.  *
  24.  *  Copyright.                Copyright (C) IBM Corporation 1993
  25.  *                            LICENSED MATERIAL-PROGRAM PROPERTY OF IBM
  26.  *
  27.  *  Change History.
  28.  *
  29.  *    Rel  Programmer      Date      Description
  30.  *   ----- -------------   -------    --------------------------------
  31.  *    1.00 Sarka Martinez   050493    Demo Stage
  32.  *
  33.  * =================================================================== */
  34.  
  35. #define INCL_WIN                        // Window support
  36. #define INCL_DOS                        // Dos Module Support
  37. #define INCL_GPI                        // for drawing shadeing
  38. #include <os2.h>
  39.  
  40. #include <string.h>                     // C-runtime String routines
  41. #include <stdio.h>                      // C-Standard I/O functions
  42. #include <stdlib.h>
  43. #include <io.h>
  44. #include <fcntl.h>
  45. #include <penpm.h>
  46. #include <hwxentry.h>
  47.  
  48. #include "book.h"
  49.  
  50.  
  51. HAB   hab;
  52. HWND  hwndFrame, hwndClient, hwndNB, hwndIndex, hwndWelcome;
  53. LONG  Ypixel, Xpixel, WelcomeCardId, IndexCardId;
  54. USHORT numRecs;  // number of cards
  55. CHAR *BookPath;
  56. PFNWP NBSubProc, WelcomeSubProc[17], CardSubProc[14], TwoCardSubProc[28], IndexSubProc[7];
  57.  
  58. extern CARDINFO *Names;
  59.  
  60. // Main Routine
  61. VOID main( int argc,char *argv[])
  62. {
  63.     HMQ   hmq;          // Message Queue
  64.     QMSG  qmsg;
  65.  
  66.     ULONG  flCreate1;
  67.     CHAR   szFontName[20];
  68.     RECTL  rectl;
  69.  
  70.   BookPath = getenv("BOOK");
  71.   if (BookPath == NULL) {
  72.     DosBeep(500,100);
  73.     return;
  74.   }
  75.  
  76.   hab = WinInitialize(0);             // Initialize the Application
  77.   hmq = WinCreateMsgQueue(hab, 0);    // Create a message Queue
  78.  
  79.  
  80.   WinRegisterClass(hab,"BookDemoSystem1", NoteBClientProc,
  81.                    CS_SIZEREDRAW | CS_HITTEST, 0);
  82.  
  83.   Ypixel = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
  84.   Xpixel = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
  85.  
  86.   /* Create new standard window */
  87.   flCreate1 = (FCF_TITLEBAR | FCF_SYSMENU | FCF_MINBUTTON | FCF_ICON | FCF_TASKLIST | FCF_BORDER );
  88.  
  89.   hwndFrame = (HWND)WinCreateStdWindow(HWND_DESKTOP,
  90.                                        WS_PARENTCLIP,
  91.                                        (PULONG)&flCreate1,
  92.                                        (PSZ)"BookDemoSystem1",
  93.                                        (PSZ)"Contact/2",
  94.                                        WS_CLIPCHILDREN,
  95.                                        (HMODULE)NULLHANDLE,
  96.                                        (ULONG)ID_BOOKWIN,
  97.                                        (PHWND)&hwndClient);
  98.  
  99.   if (hwndFrame != NULLHANDLE) {
  100.     RedRegisterRecoCommand (ID_BOOK_EXE, ID_PENPM_BOOK, hwndClient);
  101.  
  102.     // set the font for title bar
  103.     strcpy( szFontName, "10.Helv Bold Italic");
  104.     WinSetPresParam(hwndFrame, PP_FONTNAMESIZE,
  105.                     (LONG)strlen( szFontName ) + 1L,
  106.                     (PVOID)szFontName );
  107.  
  108.     WinQueryWindowRect(hwndNB, &rectl);
  109.     WinSetWindowPos(hwndFrame, HWND_TOP, (SHORT)10, (SHORT)5,
  110.                     (SHORT)rectl.xRight+14, (SHORT)rectl.yTop+33,
  111.                     SWP_ACTIVATE | SWP_SIZE | SWP_MOVE | SWP_SHOW);
  112.  
  113.     while ( WinGetMsg(hab,(PQMSG)&qmsg, (HWND)NULL,0,0))
  114.       WinDispatchMsg(hab, (PQMSG)&qmsg );
  115.  
  116.     WinDestroyWindow(hwndFrame);
  117.   }
  118.  
  119.         // Clean Up
  120.     WinDestroyMsgQueue(hmq);    // Destroy the message Queue
  121.     WinTerminate(hab);          // Terminate the Application
  122.     DosExit ( EXIT_PROCESS, 1L);
  123. //    return;
  124. }
  125.  
  126.  
  127. MRESULT APIENTRY NoteBClientProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  128. {
  129.       HPS     hps;
  130.       RECTL   rcl;
  131.       USHORT  i;
  132.       static HBITMAP hbmp, hbmp1;
  133.  
  134.   switch ( msg )
  135.   {
  136.     case WM_CREATE:
  137.     {
  138.       HWND  hwndPage;
  139.       ULONG ulNBStyles, BCardId, indx=CLR_DARKRED;
  140.       SWP   actCoords;
  141.       LONG  letter='*', x=0;
  142.       BOOL  NewIndex;
  143.       CHAR  status_text[15];
  144.       CHAR  strletter[2];
  145.       HPS     hps;
  146.       POINTL  points;
  147.       RECTL   rectl;
  148.       ERRORID rc;
  149.  
  150.  
  151.       ulNBStyles = BKS_SPIRALBIND | BKS_POLYGONTABS | BKS_STATUSTEXTRIGHT;
  152.  
  153.       hwndNB = WinCreateWindow(hwnd, WC_NOTEBOOK, (PSZ)NULL,
  154.                                ulNBStyles, 5, 1, 470, 605, hwnd,
  155.                                HWND_TOP, (USHORT)ID_BOOK, (PVOID)NULL,
  156.                                (PVOID)NULL);
  157.      if (hwndNB == NULLHANDLE)
  158.        return (MRESULT) TRUE;
  159.  
  160.      // subclass the note book so that you can see if any gesture were done
  161.      // on it...
  162.      NBSubProc = WinSubclassWindow(hwndNB, (PFNWP) NoteBookSubWndProc);
  163.  
  164.       WinSendMsg (hwndNB, BKM_SETDIMENSIONS, MPFROM2SHORT(30,45),
  165.                   MPFROMSHORT(BKA_MAJORTAB));
  166.  
  167.       // Welcome Page
  168.       WelcomeCardId = (LONG)WinSendMsg(hwndNB, BKM_INSERTPAGE, (MPARAM)NULL,
  169.                                  MPFROM2SHORT(BKA_MAJOR, BKA_FIRST));
  170.       hwndWelcome = WinLoadDlg(hwndNB, (HWND)NULLHANDLE, (PFNWP)WelcomeDlgProc,
  171.                             (HMODULE)NULLHANDLE, (ULONG)ID_WELCOME, 0L);
  172.       WinSendMsg(hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMP(WelcomeCardId),
  173.                  MPFROMLONG(hwndWelcome));
  174.       // put the bitmap on the tab
  175.       hps = WinGetPS (hwndNB);
  176.       hbmp = GpiLoadBitmap(hps, (USHORT)NULL, IDB_WELCOME, 0L, 0L);
  177.       WinSendMsg(hwndNB, BKM_SETTABBITMAP, (MPARAM)WelcomeCardId, (MPARAM)hbmp);
  178.       WinReleasePS (hps);
  179.       BCardId = WelcomeCardId;
  180.  
  181.       // set the size of the notebook relative to the size of the DLGs
  182.       // by doing this you do not have to calculate the diff sizes
  183.       // for all the diff resolutions...
  184.       WinQueryWindowRect(hwndWelcome, &rectl);
  185.       points.x = rectl.xRight+48;
  186.       points.y = rectl.yTop+3;
  187.       WinMapWindowPoints(hwndWelcome, HWND_DESKTOP, &points, (LONG)1);
  188.       WinSetWindowPos(hwndNB, NULLHANDLE, 0, 0,
  189.                       points.x, points.y, SWP_SIZE | SWP_SHOW);
  190.  
  191.       // set position of the welcome dlg
  192.       WinSetWindowPos(hwndWelcome, NULLHANDLE, (ULONG) 1, (ULONG) 1,
  193.                       0, 0, SWP_MOVE);
  194.  
  195.      // get Data Base ...
  196.      GetAllRecords(hwnd, &numRecs);
  197.  
  198.      // look at entry, add page, and tab page each time you find a new last name
  199.      while (x < numRecs) {
  200.        // see if a new letter index tab is required
  201.        if ((Names[x].LName != NULL) && (Names[x].LName[0] != letter)) {
  202.          NewIndex = TRUE;
  203.          letter = Names[x].LName[0];
  204.        }
  205.  
  206.        // add tab page and entries
  207.        if (NewIndex)
  208.          BCardId = (LONG)WinSendMsg(hwndNB, BKM_INSERTPAGE, (MPARAM)BCardId,
  209.                                     MPFROM2SHORT(BKA_MAJOR | BKA_STATUSTEXTON, BKA_NEXT));
  210.        else
  211.          // add named entry
  212.          BCardId = (LONG)WinSendMsg(hwndNB, BKM_INSERTPAGE, (MPARAM)BCardId,
  213.                                     MPFROM2SHORT(BKA_STATUSTEXTON, BKA_NEXT));
  214.  
  215.        // 2 cards per page... & still on same letter of alphabet
  216.        if ((x+1 < MAXNAMES) && (Names[x+1].LName[0] == letter)) {
  217.          Names[x].CardId = BCardId;
  218.          Names[x+1].CardId = BCardId;
  219.          hwndPage = WinLoadDlg(hwndNB, (HWND)NULLHANDLE, (PFNWP)TwoCardDlgProc,
  220.                                (HMODULE)NULL, (ULONG)ID_BCARD2, (PVOID)&x);
  221.          rc = WinGetLastError(hab);
  222.          WinSendMsg(hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMP(BCardId),
  223.                     MPFROMLONG(hwndPage));
  224.          x++;
  225.        } else { // only one card
  226.          Names[x].CardId = BCardId;
  227.          hwndPage = WinLoadDlg(hwndNB, (HWND)NULLHANDLE, (PFNWP)CardDlgProc,
  228.                                (HMODULE)NULL, (ULONG)ID_BCARD, &Names[x]);
  229.          WinSendMsg(hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMP(BCardId),
  230.                     MPFROMLONG(hwndPage));
  231.        }
  232.        WinSetWindowPos(hwndPage, NULLHANDLE, (ULONG) 10, (ULONG) 10,
  233.                        0, 0, SWP_MOVE);
  234.  
  235.        if (NewIndex) {
  236.          sprintf(strletter, "%c", letter);
  237.          WinSendMsg(hwndNB, BKM_SETTABTEXT, (MPARAM)BCardId,
  238.                     (MPARAM)strletter);
  239.          NewIndex=FALSE;
  240.        }
  241.        x++;  // go to next name
  242.        //put info on staus line if more entries exsist under that letter
  243.        if ((Names[x].LName != NULL) && (Names[x].LName[0] == letter)) {
  244.          /* set the status line color to red */
  245.          WinSetPresParam(hwndNB, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  246.          sprintf(status_text, "More %c's ...  ", letter);
  247.          WinSendMsg(hwndNB, BKM_SETSTATUSLINETEXT, MPFROMP(BCardId),
  248.                     MPFROMP(status_text));
  249.        }
  250.  
  251.      }  // end while
  252.  
  253.       // Index Page
  254.       IndexCardId = (LONG)WinSendMsg(hwndNB, BKM_INSERTPAGE, (MPARAM)NULL,
  255.                                  MPFROM2SHORT(BKA_MAJOR, BKA_LAST));
  256.       hwndIndex = WinLoadDlg(hwndNB, NULLHANDLE, IndexDlgProc, (HMODULE)NULL, ID_INDEX, 0L);
  257.       WinSetWindowPos(hwndIndex, NULLHANDLE, (ULONG) 5, (ULONG) 1,
  258.                       0, 0, SWP_MOVE);
  259.       WinSendMsg(hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMP(IndexCardId),
  260.                  MPFROMLONG(hwndIndex));
  261.       // put the bitmap on the tab
  262.       hps = WinGetPS (hwndNB);
  263.       hbmp1 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_INDEX, 0L, 0L);
  264.       WinSendMsg(hwndNB, BKM_SETTABBITMAP, (MPARAM)IndexCardId, (MPARAM)hbmp1);
  265.       WinReleasePS (hps);
  266.  
  267.     }
  268.     return (FALSE);
  269.  
  270.     case WM_PAINT:
  271.       hps = WinBeginPaint (hwnd, (HPS)NULL, &rcl);
  272.       WinFillRect (hps, &rcl, (LONG)CLR_PALEGRAY);
  273.       WinEndPaint (hps);
  274.     return 0;
  275.  
  276.     // look at gesture done ontop of the window
  277.     case WM_MY_RECO:
  278.       ProcessReco(mp1, mp2);
  279.     break;
  280.  
  281.     case WM_RECO:
  282.       WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
  283.     return (MRESULT)TRUE;
  284.  
  285.     case WM_COMMAND:
  286.     {
  287.       switch ( SHORT1FROMMP(mp1) )
  288.       {
  289.          default:
  290.          break;
  291.       }
  292.     }
  293.  
  294.     case WM_CLOSE:
  295.       for (i=0; i < numRecs; i++) {
  296.         GpiDeleteBitmap(Names[i].hbmBitmap);
  297.         free(&Names[i]);
  298.       }
  299.       GpiDeleteBitmap(hbmp);
  300.       GpiDeleteBitmap(hbmp1);
  301.     return(WinDefWindowProc(hwnd, msg, mp1, mp2));
  302.  
  303.     default:
  304.       return( WinDefWindowProc( hwnd, msg, mp1, mp2 ) );
  305.   }
  306.   return(0L);
  307. }
  308.  
  309. MRESULT EXPENTRY WelcomeDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
  310. {
  311.   CHAR  szFontName[13];
  312.   LONG  indx = CLR_BLACK, i;
  313.  
  314.   switch (message)
  315.   {
  316.     case WM_INITDLG:
  317.       // set the Gesture helps to black text
  318.       WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  319.       // set dialog box background to be white
  320.       indx = CLR_WHITE;
  321.       WinSetPresParam(hwnd, PP_BACKGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  322.  
  323.       // set the font
  324.       strcpy( szFontName, "10.Helv Bold");
  325.       WinSetPresParam( hwnd, PP_FONTNAMESIZE,
  326.                       (LONG)strlen( szFontName ) + 1L,
  327.                       (PVOID)szFontName );
  328.  
  329.       // set the Gesture help text to Gray
  330.       indx = CLR_DARKGRAY;
  331.       WinSetPresParam( WinWindowFromID(hwnd, ID_GES_PAGEHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  332.       WinSetPresParam( WinWindowFromID(hwnd, ID_GES_MAILHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  333.       WinSetPresParam( WinWindowFromID(hwnd, ID_GES_ADDHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  334.       WinSetPresParam( WinWindowFromID(hwnd, ID_GES_REMOVEHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  335.       WinSetPresParam( WinWindowFromID(hwnd, ID_GES_UPDATEHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  336.       WinSetPresParam( WinWindowFromID(hwnd, ID_GES_HLPHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  337.       WinSetPresParam( WinWindowFromID(hwnd, ID_GES_VOICEHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  338.       WinSetPresParam( WinWindowFromID(hwnd, ID_GES_CLIPBHLP_TXT), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  339.  
  340.      // subclass all windows so that you can see if any gesture were done
  341.      // on it...
  342.      for (i = ID_IBMBMP; i <= ID_GES_HLPHLP_TXT; i++)
  343.        WelcomeSubProc[i-ID_IBMBMP] = WinSubclassWindow(WinWindowFromID(hwnd, i),
  344.                                           (PFNWP) NoteBookSubWndProc);
  345.  
  346.     return (MRESULT)TRUE ;
  347.  
  348.     // look at gesture done ontop of the window
  349.     case WM_RECO:
  350.       WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
  351.     return (MRESULT)TRUE;
  352.  
  353.    case  WM_CONTROL:
  354.     switch (HIUSHORT(mp1))
  355.     {
  356.         default:
  357.         break;
  358.     }
  359.     return (MRESULT)TRUE ;
  360.  
  361.    case WM_COMMAND:
  362.     switch (LOUSHORT(mp1))
  363.     {
  364.  
  365.        default:
  366.        return WinDefWindowProc(hwnd, message, mp1, mp2);
  367.     }
  368.     break;
  369.  
  370.     case WM_CLOSE:
  371.       WinDestroyWindow(hwnd);
  372.     return(WinDefWindowProc(hwnd, message, mp1, mp2));
  373.  
  374.     default:
  375.       return(WinDefDlgProc(hwnd,message,mp1,mp2));
  376.   }
  377.   return(0L);
  378. }
  379.  
  380. MRESULT EXPENTRY CardDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
  381. {
  382.   CARDINFO *NameInfo;
  383.   CHAR    *szFontName, *name, *Addr, *MailID;
  384.   LONG    indx = CLR_BLACK, i;
  385.  
  386.   switch (message)
  387.   {
  388.     case WM_INITDLG:
  389.  
  390.       NameInfo = (CARDINFO *)mp2;
  391.  
  392.       szFontName = (CHAR *)malloc(25);
  393.       name = (CHAR *)malloc(64);
  394.       MailID = (CHAR *)malloc(19);
  395.       Addr = (CHAR *)malloc(246);
  396.  
  397.       // create a window word for this handle that carries the NameInfo struct
  398.       WinSetWindowULong(hwnd, 0, (ULONG) NameInfo);
  399.  
  400.       // set to black text
  401.       WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  402.       // set dialog box background to be white
  403.       indx = CLR_WHITE;
  404.       WinSetPresParam(hwnd, PP_BACKGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  405.  
  406.       // quickly change fonts on all text in this dlg
  407.       strcpy( szFontName, "8.Helv");
  408.       WinSetPresParam(hwnd, PP_FONTNAMESIZE,
  409.                       (LONG)strlen( szFontName ) + 1L,
  410.                       (PVOID)szFontName );
  411.  
  412.       //show all info and update fonts for top part of card
  413.       strcpy( szFontName, "14.Tms Rmn Bold Italic");
  414.       WinSetPresParam( WinWindowFromID(hwnd, ID_NAME), PP_FONTNAMESIZE,
  415.                       (LONG)strlen( szFontName ) + 1L,
  416.                       (PVOID)szFontName );
  417.       if (NameInfo->Initial != NULL && NameInfo->Initial[0] != 0)
  418.         sprintf(name,"%s %s. %s", NameInfo->FName, NameInfo->Initial,
  419.                 NameInfo->LName);
  420.      else
  421.         sprintf(name,"%s %s", NameInfo->FName, NameInfo->LName);
  422.       WinSetDlgItemText(hwnd, ID_NAME, name);
  423.  
  424.       strcpy( szFontName, "10.Helv");
  425.       WinSetPresParam( WinWindowFromID(hwnd, ID_COMPANY), PP_FONTNAMESIZE,
  426.                       (LONG)strlen( szFontName ) + 1L,
  427.                       (PVOID)szFontName );
  428.       // set company text to be blue
  429.       indx = CLR_DARKBLUE;
  430.       WinSetPresParam(WinWindowFromID(hwnd, ID_COMPANY), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  431.       WinSetDlgItemText(hwnd, ID_COMPANY, NameInfo->Company);
  432.  
  433.       WinSetPresParam( WinWindowFromID(hwnd, ID_DEPT), PP_FONTNAMESIZE,
  434.                       (LONG)strlen( szFontName ) + 1L,
  435.                       (PVOID)szFontName );
  436.       WinSetDlgItemText(hwnd, ID_DEPT, NameInfo->Division);
  437.  
  438.       WinSetPresParam( WinWindowFromID(hwnd, ID_ADDR), PP_FONTNAMESIZE,
  439.                       (LONG)strlen( szFontName ) + 1L,
  440.                       (PVOID)szFontName );
  441.       sprintf(Addr, "%s\n%s\n%s %s", NameInfo->StrAddr, NameInfo->City,
  442.               NameInfo->State, NameInfo->Zip);
  443.       WinSetDlgItemText(hwnd, ID_ADDR, Addr);
  444.  
  445.       if (NameInfo->Phone != NULL && NameInfo->Phone[0] != 0)
  446.         WinSetDlgItemText(hwnd, ID_PHONE, NameInfo->Phone);
  447.       else
  448.         WinShowWindow(WinWindowFromID(hwnd, ID_INF_PHONE), FALSE);
  449.  
  450.       if (NameInfo->Fax != NULL && NameInfo->Fax[0] != 0)
  451.         WinSetDlgItemText(hwnd, ID_FAX, NameInfo->Fax);
  452.       else
  453.         WinShowWindow(WinWindowFromID(hwnd, ID_INF_FAX), FALSE);
  454.  
  455.       if (NameInfo->PagerID != NULL && NameInfo->PagerID[0] != 0)
  456.         WinSetDlgItemText(hwnd, ID_PAGER, NameInfo->PagerID);
  457.       else
  458.         WinShowWindow(WinWindowFromID(hwnd, ID_INF_PAGERID), FALSE);
  459.  
  460.       sprintf(MailID, "%s@%s", NameInfo->MailUserId, NameInfo->MailNodeId);
  461.       WinSetDlgItemText(hwnd, ID_MAILID, MailID);
  462.  
  463.      // subclass all windows so that you can see if any gesture were done
  464.      // on it...
  465.      for (i = ID_LOGO; i <= ID_INF_PAGERID; i++)
  466.        CardSubProc[i-ID_LOGO] = WinSubclassWindow(WinWindowFromID(hwnd, i),
  467.                                           (PFNWP) NoteBookSubWndProc);
  468.  
  469.      free(Addr);
  470.      free(MailID);
  471.      free(name);
  472.      free(szFontName);
  473.     return (MRESULT)TRUE ;
  474.  
  475.    case WM_PAINT:
  476.    {
  477.       HPS  hps;
  478.       RECTL  rect;
  479.       CARDINFO  *CInfo;
  480.  
  481.       /* paint main(all of) dialog box */
  482.       hps = WinBeginPaint(hwnd, (HPS)NULL, NULL);
  483.       GpiErase(hps);
  484.       WinEndPaint(hps);
  485.  
  486.       CInfo = (CARDINFO *) WinQueryWindowULong(hwnd, 0);
  487.  
  488.       /* paint in the User Bitmap */
  489.       if (CInfo->hbmBitmap != NULLHANDLE) {
  490.         hps = WinBeginPaint(WinWindowFromID(hwnd, ID_LOGO), (HPS)NULL, NULL);
  491.         WinQueryWindowRect(WinWindowFromID(hwnd, ID_LOGO), &rect);
  492.         WinDrawBitmap(hps, CInfo->hbmBitmap, NULL, (PPOINTL)&rect,
  493.                       CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH);
  494.         WinEndPaint(hps);
  495.       }
  496.  
  497.       hps = WinGetPS(WinWindowFromID(hwnd, ID_CARDFRM));
  498.       // paint the shadow around the card
  499.       WinQueryWindowRect(WinWindowFromID(hwnd, ID_CARDFRM), &rect);
  500.       Paint3dLines(hps, &rect);
  501.       WinReleasePS(hps);
  502.  
  503.    }
  504.    return 0;
  505.  
  506.    // look at gesture done ontop of the window
  507.    case WM_RECO:
  508.       WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
  509.    return (MRESULT)TRUE;
  510.  
  511.    case  WM_CONTROL:
  512.     switch (HIUSHORT(mp1))
  513.     {
  514.         default:
  515.         break;
  516.     }
  517.     return (MRESULT)TRUE ;
  518.  
  519.    case WM_COMMAND:
  520.     switch (LOUSHORT(mp1))
  521.     {
  522.        case ID_SKETCHBTN:
  523.        {
  524.          CARDINFO  *CInfo;
  525.  
  526.          CInfo = (CARDINFO *) WinQueryWindowULong(hwnd, 0);
  527.          WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)SketchDlgProc,
  528.                    (HMODULE)NULL, ID_SKETCHPAD, CInfo);
  529.        }
  530.        break;
  531.  
  532.        default:
  533.        return WinDefWindowProc(hwnd, message, mp1, mp2);
  534.     }
  535.     break;
  536.  
  537.     case WM_CLOSE:
  538.       WinDestroyWindow(hwnd);
  539.     return(WinDefWindowProc(hwnd, message, mp1, mp2));
  540.  
  541.     default:
  542.       return(WinDefDlgProc(hwnd,message,mp1,mp2));
  543.   }
  544.   return(0L);
  545. }
  546.  
  547. MRESULT EXPENTRY TwoCardDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
  548. {
  549.   LONG    *indx, Index;
  550.   LONG    clrindx = CLR_BLACK, i;
  551.   CHAR    *szFontName, *name, *Addr, *MailID;
  552.  
  553.   switch (message)
  554.   {
  555.     case WM_INITDLG:
  556.       indx = (LONG *)mp2;
  557.       Index = *indx;
  558.  
  559.       szFontName = (CHAR *)malloc(25);
  560.       name = (CHAR *)malloc(64);
  561.       MailID = (CHAR *)malloc(19);
  562.       Addr = (CHAR *)malloc(246);
  563.  
  564.       // create a window word for this handle that carries the NameInfo struct
  565.       WinSetWindowULong(hwnd, 0, (ULONG) Index);
  566.  
  567.       // set to black text
  568.       WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &clrindx);
  569.       // set dialog box background to be white
  570.       clrindx = CLR_WHITE;
  571.       WinSetPresParam(hwnd, PP_BACKGROUNDCOLORINDEX, 4L, (PVOID) &clrindx);
  572.  
  573.       // quickly change fonts on all text in this dlg
  574.       strcpy( szFontName, "8.Helv");
  575.       WinSetPresParam(hwnd, PP_FONTNAMESIZE,
  576.                       (LONG)strlen( szFontName ) + 1L,
  577.                       (PVOID)szFontName );
  578.  
  579.       // set up info and fonts
  580.       // top card
  581.       strcpy( szFontName, "14.Tms Rmn Bold Italic");
  582.       WinSetPresParam( WinWindowFromID(hwnd, ID_NAME2), PP_FONTNAMESIZE,
  583.                       (LONG)strlen( szFontName ) + 1L,
  584.                       (PVOID)szFontName );
  585.       if (Names[Index].Initial != NULL && Names[Index].Initial[0] != 0)
  586.         sprintf(name,"%s %s. %s", Names[Index].FName, Names[Index].Initial,
  587.                  Names[Index].LName);
  588.      else
  589.         sprintf(name,"%s %s", Names[Index].FName, Names[Index].LName);
  590.       WinSetDlgItemText(hwnd, ID_NAME2, name);
  591.  
  592.       strcpy( szFontName, "10.Helv");
  593.       WinSetPresParam( WinWindowFromID(hwnd, ID_COMPANY2), PP_FONTNAMESIZE,
  594.                       (LONG)strlen( szFontName ) + 1L,
  595.                       (PVOID)szFontName );
  596.       // set company text to be blue
  597.       clrindx = CLR_DARKBLUE;
  598.       WinSetPresParam(WinWindowFromID(hwnd, ID_COMPANY2), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &clrindx);
  599.       WinSetDlgItemText(hwnd, ID_COMPANY2, Names[Index].Company);
  600.  
  601.       WinSetPresParam( WinWindowFromID(hwnd, ID_DEPT2), PP_FONTNAMESIZE,
  602.                       (LONG)strlen( szFontName ) + 1L,
  603.                       (PVOID)szFontName );
  604.       WinSetDlgItemText(hwnd, ID_DEPT2, Names[Index].Division);
  605.  
  606.       WinSetPresParam( WinWindowFromID(hwnd, ID_ADDR2), PP_FONTNAMESIZE,
  607.                       (LONG)strlen( szFontName ) + 1L,
  608.                       (PVOID)szFontName );
  609.       sprintf(Addr, "%s\n%s\n%s %s", Names[Index].StrAddr, Names[Index].City,
  610.               Names[Index].State, Names[Index].Zip);
  611.       WinSetDlgItemText(hwnd, ID_ADDR2, Addr);
  612.  
  613.       if (Names[Index].Phone != NULL && Names[Index].Phone[0] != 0)
  614.         WinSetDlgItemText(hwnd, ID_PHONE2, Names[Index].Phone);
  615.       else
  616.         WinShowWindow(WinWindowFromID(hwnd, ID_INF_PHONE2), FALSE);
  617.  
  618.       if (Names[Index].Fax != NULL && Names[Index].Fax[0] != 0)
  619.         WinSetDlgItemText(hwnd, ID_FAX2, Names[Index].Fax);
  620.       else
  621.         WinShowWindow(WinWindowFromID(hwnd, ID_INF_FAX2), FALSE);
  622.  
  623.      if (Names[Index].PagerID != NULL && Names[Index].PagerID[0] != 0)
  624.        WinSetDlgItemText(hwnd, ID_PAGER2, Names[Index].PagerID);
  625.       else
  626.         WinShowWindow(WinWindowFromID(hwnd, ID_INF_PAGERID2), FALSE);
  627.  
  628.       sprintf(MailID, "%s@%s", Names[Index].MailUserId, Names[Index].MailNodeId);
  629.       WinSetDlgItemText(hwnd, ID_MAILID2, MailID);
  630.       // now Load the BMP
  631.  
  632.  
  633.       // bottom Card
  634.       strcpy( szFontName, "14.Tms Rmn Bold Italic");
  635.       WinSetPresParam( WinWindowFromID(hwnd, ID_NAME1), PP_FONTNAMESIZE,
  636.                       (LONG)strlen( szFontName ) + 1L,
  637.                       (PVOID)szFontName );
  638.       if (Names[Index+1].Initial != NULL && Names[Index+1].Initial[0] != 0)
  639.         sprintf(name,"%s %s. %s", Names[Index+1].FName, Names[Index+1].Initial,
  640.                 Names[Index+1].LName);
  641.      else
  642.         sprintf(name,"%s %s", Names[Index+1].FName, Names[Index+1].LName);
  643.       WinSetDlgItemText(hwnd, ID_NAME1, name);
  644.  
  645.       strcpy( szFontName, "10.Helv");
  646.       WinSetPresParam( WinWindowFromID(hwnd, ID_COMPANY1), PP_FONTNAMESIZE,
  647.                       (LONG)strlen( szFontName ) + 1L,
  648.                       (PVOID)szFontName );
  649.       // set company text to be blue
  650.       clrindx = CLR_DARKBLUE;
  651.       WinSetPresParam(WinWindowFromID(hwnd, ID_COMPANY1), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &clrindx);
  652.       WinSetDlgItemText(hwnd, ID_COMPANY1, Names[Index+1].Company);
  653.  
  654.       WinSetPresParam( WinWindowFromID(hwnd, ID_DEPT1), PP_FONTNAMESIZE,
  655.                       (LONG)strlen( szFontName ) + 1L,
  656.                       (PVOID)szFontName );
  657.       WinSetDlgItemText(hwnd, ID_DEPT1, Names[Index+1].Division);
  658.  
  659.       WinSetPresParam( WinWindowFromID(hwnd, ID_ADDR1), PP_FONTNAMESIZE,
  660.                       (LONG)strlen( szFontName ) + 1L,
  661.                       (PVOID)szFontName );
  662.       sprintf(Addr, "%s\n%s\n%s %s", Names[Index+1].StrAddr, Names[Index+1].City,
  663.               Names[Index+1].State, Names[Index+1].Zip);
  664.       WinSetDlgItemText(hwnd, ID_ADDR1, Addr);
  665.  
  666.       if (Names[Index+1].Phone != NULL && Names[Index+1].Phone[0] != 0)
  667.         WinSetDlgItemText(hwnd, ID_PHONE1, Names[Index+1].Phone);
  668.       else
  669.         WinShowWindow(WinWindowFromID(hwnd, ID_INF_PHONE1), FALSE);
  670.  
  671.       if (Names[Index+1].Fax != NULL && Names[Index+1].Fax[0] != 0)
  672.         WinSetDlgItemText(hwnd, ID_FAX1, Names[Index+1].Fax);
  673.       else
  674.         WinShowWindow(WinWindowFromID(hwnd, ID_INF_FAX1), FALSE);
  675.  
  676.       if (Names[Index+1].PagerID != NULL && Names[Index+1].PagerID[0] != 0)
  677.         WinSetDlgItemText(hwnd, ID_PAGER1, Names[Index+1].PagerID);
  678.       else
  679.         WinShowWindow(WinWindowFromID(hwnd, ID_INF_PAGERID1), FALSE);
  680.  
  681.       sprintf(MailID, "%s@%s", Names[Index+1].MailUserId, Names[Index+1].MailNodeId);
  682.       WinSetDlgItemText(hwnd, ID_MAILID1, MailID);
  683.  
  684.      // subclass all windows so that you can see if any gestures were done
  685.      // on it...
  686.      for (i = ID_LOGO1; i <= ID_INF_PAGERID2; i++)
  687.        TwoCardSubProc[i-ID_LOGO1] = WinSubclassWindow(WinWindowFromID(hwnd, i),
  688.                                           (PFNWP) NoteBookSubWndProc);
  689.  
  690.       free(szFontName);
  691.       free(name);
  692.       free(MailID);
  693.       free(Addr);
  694.     return (MRESULT)TRUE ;
  695.  
  696.    case WM_PAINT:
  697.    {
  698.       HPS  hps;
  699.       RECTL  rect;
  700.       ULONG  index;
  701.  
  702.  
  703.       /* paint main(all of) dialog box */
  704.       hps = WinBeginPaint(hwnd, (HPS)NULL, NULL);
  705.       GpiErase(hps);
  706.       WinEndPaint(hps);
  707.  
  708.       index = (ULONG) WinQueryWindowULong(hwnd, 0);
  709.  
  710.       /* paint in the User Bitmap */
  711.       if (Names[index].hbmBitmap != NULLHANDLE) {
  712.         hps = WinBeginPaint(WinWindowFromID(hwnd, ID_LOGO2), (HPS)NULL, NULL);
  713.         WinQueryWindowRect(WinWindowFromID(hwnd, ID_LOGO2), &rect);
  714.         WinDrawBitmap(hps, Names[index].hbmBitmap, NULL, (PPOINTL)&rect,
  715.                       CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH);
  716.         WinEndPaint(hps);
  717.       }
  718.       /* paint in the User Bitmap */
  719.       if (Names[index+1].hbmBitmap != NULLHANDLE) {
  720.         hps = WinBeginPaint(WinWindowFromID(hwnd, ID_LOGO1), (HPS)NULL, NULL);
  721.         WinQueryWindowRect(WinWindowFromID(hwnd, ID_LOGO1), &rect);
  722.         WinDrawBitmap(hps, Names[index+1].hbmBitmap, NULL, (PPOINTL)&rect,
  723.                       CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH);
  724.         WinEndPaint(hps);
  725.       }
  726.  
  727.       hps = WinGetPS(WinWindowFromID(hwnd, ID_CARDFRM1));
  728.       // paint the shadows around the cards
  729.       WinQueryWindowRect(WinWindowFromID(hwnd, ID_CARDFRM1), &rect);
  730.       Paint3dLines(hps, &rect);
  731.       WinReleasePS(hps);
  732.  
  733.       hps = WinGetPS(WinWindowFromID(hwnd, ID_CARDFRM2));
  734.       WinQueryWindowRect(WinWindowFromID(hwnd, ID_CARDFRM2), &rect);
  735.       Paint3dLines(hps, &rect);
  736.       WinReleasePS(hps);
  737.    }
  738.    return 0;
  739.  
  740.    // look at gesture done ontop of the window
  741.    case WM_RECO:
  742.      WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
  743.    return (MRESULT)TRUE;
  744.  
  745.    case  WM_CONTROL:
  746.     switch (HIUSHORT(mp1))
  747.     {
  748.         default:
  749.         break;
  750.     }
  751.     return (MRESULT)TRUE ;
  752.  
  753.    case WM_COMMAND:
  754.     switch (LOUSHORT(mp1))
  755.     {
  756.        case ID_SKETCHBTN1:
  757.        {
  758.          ULONG index;
  759.  
  760.          index = (ULONG) WinQueryWindowULong(hwnd, 0);
  761.          WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)SketchDlgProc,
  762.                    (HMODULE)NULL, ID_SKETCHPAD, (PVOID)&Names[index]);
  763.        }
  764.        break;
  765.  
  766.        case ID_SKETCHBTN2:
  767.        {
  768.          ULONG index;
  769.  
  770.          index = (ULONG) WinQueryWindowULong(hwnd, 0);
  771.          WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)SketchDlgProc,
  772.                    (HMODULE)NULL, ID_SKETCHPAD, (PVOID)&Names[index+1]);
  773.        }
  774.        break;
  775.  
  776.        default:
  777.        return WinDefWindowProc(hwnd, message, mp1, mp2);
  778.     }
  779.     break;
  780.  
  781.     case WM_CLOSE:
  782.       WinDestroyWindow(hwnd);
  783.     return(WinDefWindowProc(hwnd, message, mp1, mp2));
  784.  
  785.     default:
  786.       return(WinDefDlgProc(hwnd,message,mp1,mp2));
  787.   }
  788.   return(0L);
  789. }
  790.  
  791.  
  792. HBITMAP  hbmp0000, hbmp0001, hbmp0010, hbmp0011, hbmp0100, hbmp0101, hbmp0110,
  793.          hbmp0111, hbmp1000, hbmp1001, hbmp1010, hbmp1011, hbmp1100, hbmp1101,
  794.          hbmp1110, hbmp1111;
  795. MRESULT EXPENTRY IndexDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
  796. {
  797.   LONG       indx=CLR_WHITE;
  798.   CNRINFO    ccinfo;          /* Pointer to Container Control Info   */
  799.   PFIELDINFO pFI;
  800.   CHAR       szFontName[12];
  801.   POINTL     points;
  802.   SHORT      y, i;
  803.   HPS        hps;
  804.   ULONG      ulWindowStyle=WS_GROUP | WS_TABSTOP | WS_VISIBLE;
  805. static  HWND hwndHWX;
  806. static  CHAR oldfilttxt[11];
  807.  
  808.   switch (message)
  809.   {
  810.     case WM_INITDLG:
  811.       // hide the text string in the Filter group box til someone wants to filter
  812.       WinShowWindow(WinWindowFromID(hwnd, ID_FILT_TEXT), FALSE);
  813.       // hide the Ok pushbutton in the Filter group box til someone wants to filter
  814.       WinShowWindow(WinWindowFromID(hwnd, ID_FILT_OK), FALSE);
  815.  
  816.       // set to black text
  817.       indx = CLR_BLACK;
  818.       WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  819.  
  820.       // set the font for the container
  821.       strcpy( szFontName, "10.Helv");
  822.       WinSetPresParam( WinWindowFromID(hwnd, ID_CONTAINER), PP_FONTNAMESIZE,
  823.                       (LONG)strlen( szFontName ) + 1L,
  824.                       (PVOID)szFontName );
  825.  
  826.       // set the font for the rest of the dialog box
  827.       strcpy( szFontName, "10.Helv");
  828.       WinSetPresParam(hwnd, PP_FONTNAMESIZE,
  829.                       (LONG)strlen( szFontName ) + 1L,
  830.                       (PVOID)szFontName );
  831.  
  832.       // set up the container
  833.       pFI = AllocIndexFields(WinWindowFromID(hwnd, ID_CONTAINER));
  834.       ccinfo.pFieldInfoLast = pFI;
  835.       ccinfo.cb = sizeof(CNRINFO);        /* structure size              */
  836.       ccinfo.xVertSplitbar = 93;
  837.       ccinfo.cFields = 4;
  838.       ccinfo.flWindowAttr = CV_DETAIL | CA_DRAWBITMAP;
  839.       ccinfo.slBitmapOrIcon.cx = 75;
  840.       ccinfo.slBitmapOrIcon.cy = 20;
  841.       ccinfo.cyLineSpacing = 7;
  842.  
  843.       WinSendMsg (WinWindowFromID(hwnd, ID_CONTAINER), CM_SETCNRINFO,
  844.                   MPFROMP(&ccinfo),
  845.                   MPFROMLONG(CMA_SLBITMAPORICON | CMA_FLWINDOWATTR | CMA_LINESPACING |
  846.                              CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR));
  847.  
  848.       // subclass all windows so that you can see if any gesture were done
  849.       // on it...
  850.       for (i = ID_CONTAINER; i <= ID_FILT_OK; i++)
  851.         IndexSubProc[i-ID_CONTAINER] = WinSubclassWindow(WinWindowFromID(hwnd, i),
  852.                                           (PFNWP) NoteBookSubWndProc);
  853.       oldfilttxt[0] = '\0';
  854.  
  855.     return (MRESULT)TRUE ;
  856.  
  857.    // look at gesture done ontop of the window
  858.    case WM_RECO:
  859.      WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
  860.    return (MRESULT)TRUE;
  861.  
  862.    case  WM_CONTROL:
  863.     switch (HIUSHORT(mp1))
  864.     {
  865.         // double clicked on a name, now open to that page
  866.         case CN_ENTER:
  867.         {
  868.           PNOTIFYRECORDENTER pRecordinfo;
  869.           CARDREC           *pCardRec;
  870.  
  871.           pRecordinfo = (PNOTIFYRECORDENTER)mp2;
  872.           // look past recordinfo to get the user data...
  873.           pCardRec = (CARDREC *)pRecordinfo->pRecord;
  874.           // turn to the page
  875.           WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(pCardRec->CardId), 0L);
  876.         }
  877.         break;
  878.  
  879.         case HXN_CONTENTS_CHANGED:
  880.         {
  881.           CHAR filttxt[11];
  882.  
  883.           WinQueryWindowText(hwndHWX, sizeof(filttxt), filttxt);
  884.           // now cause the container to filter out the items that don't match
  885.           // get all items from list, and set filtered attribute on any that
  886.           // dont match what was hand written...
  887.           if ((filttxt != NULL) && (filttxt[0] != 0)) {
  888.             // if user wrote over a letter that was reco'd earlier, unfilter it.
  889.             if (strlen(oldfilttxt) == strlen(filttxt)) {
  890.               if (strcmp(oldfilttxt, filttxt) != 0)
  891.                  WinSendMsg (WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER, NULL, NULL);
  892.             }
  893.             strcpy(oldfilttxt, filttxt);
  894.  
  895.             if (LOUSHORT(mp1) == ID_HWX_NAME)
  896.               WinSendMsg(WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER,
  897.                          MPFROMP(pfnfilterName), filttxt);
  898.             else if (LOUSHORT(mp1) == ID_HWX_COMP)
  899.               WinSendMsg(WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER,
  900.                          MPFROMP(pfnfilterComp), filttxt);
  901.             else
  902.               WinSendMsg(WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER,
  903.                          MPFROMP(pfnfilterState), filttxt);
  904.  
  905.           }
  906.           else
  907.             // unfilter the list
  908.             WinPostMsg (WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER, NULL, NULL);
  909.         }
  910.         break;
  911.  
  912.         default:
  913.           return(WinDefDlgProc(hwnd,message,mp1,mp2));
  914.     }
  915.     return (MRESULT)TRUE ;
  916.  
  917.    case WM_COMMAND:
  918.     switch (LOUSHORT(mp1))
  919.     {
  920.        case ID_FILT_NAME:
  921.        {
  922.          SHORT Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX;
  923.  
  924.          // make sure the user does not hit the button again
  925.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_NAME),FALSE);
  926.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_COMP),FALSE);
  927.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_STATE),FALSE);
  928.          WinSetDlgItemText(hwnd, ID_FILT_TEXT, "Name:");
  929.  
  930.          points.y = 157;
  931.          points.x = 10;
  932.          WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  933.  
  934.         // find optimal size for handwriting comb
  935.          Cols = 9;
  936.          CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
  937.          CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
  938.          BaseLineDY = CharBoxDY / 3;
  939.          ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  940.          ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  941.  
  942.          hwndHWX =  WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  943.                                       points.x, points.y, ControlDX, ControlDY,
  944.                                       hwnd, HWND_TOP, ID_HWX_NAME,
  945.                                       NULL, NULL );
  946.  
  947.          // show the text string in the Filter group box cause someone wants to filter
  948.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_TEXT), TRUE);
  949.          // show the Ok pushbutton in the Filter group box cause someone wants to filter
  950.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_OK), TRUE);
  951.  
  952.        }
  953.        break;
  954.  
  955.        case ID_FILT_COMP:
  956.        {
  957.          SHORT  Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX;
  958.  
  959.          // make sure the user does not hit the button again
  960.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_NAME),FALSE);
  961.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_COMP),FALSE);
  962.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_STATE),FALSE);
  963.          WinSetDlgItemText(hwnd, ID_FILT_TEXT, "Company:");
  964.  
  965.          points.y = 157;
  966.          points.x = 10;
  967.          WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  968.  
  969.          // find optimal size for handwriting comb
  970.          Cols = 9;
  971.          CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
  972.          CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
  973.          BaseLineDY = CharBoxDY / 3;
  974.          ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  975.          ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  976.  
  977.          hwndHWX =  WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  978.                                       points.x, points.y, ControlDX, ControlDY,
  979.                                       hwnd, HWND_TOP, ID_HWX_COMP,
  980.                                       NULL, NULL );
  981.  
  982.          // show the text string in the Filter group box cause someone wants to filter
  983.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_TEXT), TRUE);
  984.          // show the Ok pushbutton in the Filter group box cause someone wants to filter
  985.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_OK), TRUE);
  986.        }
  987.        break;
  988.  
  989.        case ID_FILT_STATE:
  990.        {
  991.          SHORT Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX;
  992.  
  993.          // make sure the user does not hit the button again
  994.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_NAME),FALSE);
  995.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_COMP),FALSE);
  996.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_STATE),FALSE);
  997.          WinSetDlgItemText(hwnd, ID_FILT_TEXT, "State:");
  998.  
  999.          points.y = 157;
  1000.          points.x = 8;
  1001.          WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1002.  
  1003.          // find optimal size for handwriting comb
  1004.          Cols = 2;
  1005.          CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
  1006.          CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
  1007.          BaseLineDY = CharBoxDY / 3;
  1008.          ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1009.          ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1010.  
  1011.          hwndHWX =  WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1012.                                       points.x, points.y, ControlDX, ControlDY,
  1013.                                       hwnd, HWND_TOP, ID_HWX_STATE,
  1014.                                       NULL, NULL );
  1015.  
  1016.          // show the text string in the Filter group box til someone wants to filter
  1017.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_TEXT), TRUE);
  1018.          // show the Ok pushbutton in the Filter group box cause someone wants to filter
  1019.          WinShowWindow(WinWindowFromID(hwnd, ID_FILT_OK), TRUE);
  1020.        }
  1021.        break;
  1022.  
  1023.        case ID_FILT_OK:
  1024.         // hide the text string in the Filter group box til someone wants to filter
  1025.         WinShowWindow(WinWindowFromID(hwnd, ID_FILT_TEXT), FALSE);
  1026.         // hide the Ok pushbutton in the Filter group box til someone wants to filter
  1027.         WinShowWindow(WinWindowFromID(hwnd, ID_FILT_OK), FALSE);
  1028.  
  1029.         WinShowWindow(WinWindowFromID(hwnd, ID_FILT_NAME),TRUE);
  1030.         WinShowWindow(WinWindowFromID(hwnd, ID_FILT_COMP),TRUE);
  1031.         WinShowWindow(WinWindowFromID(hwnd, ID_FILT_STATE),TRUE);
  1032.  
  1033.         // unfilter the list
  1034.         WinPostMsg (WinWindowFromID(hwnd, ID_CONTAINER), CM_FILTER, NULL, NULL);
  1035.  
  1036.         WinDestroyWindow(hwndHWX);
  1037.  
  1038.        break;
  1039.  
  1040.        default:
  1041.        return WinDefWindowProc(hwnd, message, mp1, mp2);
  1042.     }
  1043.     break;
  1044.  
  1045.     // FYI: WM_CLOSE is not being called when the notebook is closed
  1046.     case WM_CLOSE:
  1047.       GpiDeleteBitmap(hbmp0000);
  1048.       GpiDeleteBitmap(hbmp0001);
  1049.       GpiDeleteBitmap(hbmp0010);
  1050.       GpiDeleteBitmap(hbmp0011);
  1051.       GpiDeleteBitmap(hbmp0100);
  1052.       GpiDeleteBitmap(hbmp0110);
  1053.       GpiDeleteBitmap(hbmp0101);
  1054.       GpiDeleteBitmap(hbmp0111);
  1055.       GpiDeleteBitmap(hbmp1100);
  1056.       GpiDeleteBitmap(hbmp1101);
  1057.       GpiDeleteBitmap(hbmp1110);
  1058.       GpiDeleteBitmap(hbmp1111);
  1059.       GpiDeleteBitmap(hbmp1000);
  1060.       GpiDeleteBitmap(hbmp1001);
  1061.       GpiDeleteBitmap(hbmp1010);
  1062.       GpiDeleteBitmap(hbmp1011);
  1063.     return(WinDefDlgProc(hwnd,message,mp1,mp2));
  1064.  
  1065.     default:
  1066.       return(WinDefDlgProc(hwnd,message,mp1,mp2));
  1067.   }
  1068.   return(0L);
  1069. }
  1070.  
  1071. PFIELDINFO AllocIndexFields (HWND hwndCnr)
  1072. {
  1073.  
  1074.  PFIELDINFO       pFieldInfo, FirstFI, SplitbarFI;
  1075.  ULONG            NumFIs, Index=0;
  1076.  FIELDINFOINSERT  FieldInfoInsert;
  1077.  CHAR             Name[64];
  1078.  CARDREC          *pCardRec;
  1079.  PRECORDCORE      publicRecord;
  1080.  RECORDINSERT     RecordInsert;
  1081.  HPS              hps;
  1082.  
  1083.  if (numRecs > 0) {
  1084.  
  1085.   hps = WinGetPS (hwndCnr);
  1086.   hbmp0000 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0000, 0L, 0L);
  1087.   hbmp0001 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0001, 0L, 0L);
  1088.   hbmp0010 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0010, 0L, 0L);
  1089.   hbmp0011 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0011, 0L, 0L);
  1090.   hbmp0100 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0100, 0L, 0L);
  1091.   hbmp0101 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0101, 0L, 0L);
  1092.   hbmp0110 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0110, 0L, 0L);
  1093.   hbmp0111 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_0111, 0L, 0L);
  1094.   hbmp1000 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1000, 0L, 0L);
  1095.   hbmp1001 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1001, 0L, 0L);
  1096.   hbmp1010 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1010, 0L, 0L);
  1097.   hbmp1011 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1011, 0L, 0L);
  1098.   hbmp1100 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1100, 0L, 0L);
  1099.   hbmp1101 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1101, 0L, 0L);
  1100.   hbmp1110 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1110, 0L, 0L);
  1101.   hbmp1111 = GpiLoadBitmap(hps, (USHORT)NULL, IDB_1111, 0L, 0L);
  1102.   WinReleasePS (hps);
  1103.  
  1104.    while (Index < numRecs) {
  1105.      // allocate space for user info
  1106.      pCardRec = (CARDREC *)WinSendMsg(hwndCnr, CM_ALLOCRECORD,
  1107.                                       MPFROMLONG(sizeof(CARDREC)-sizeof(RECORDCORE)),
  1108.                                       MPFROMSHORT(1));
  1109.  
  1110.      // need to add an extra space at the end of the following strings
  1111.      // this is beacuse the width of a column is calculated incorrectly when
  1112.      // using the Helvetica 10 font.
  1113.  
  1114.      if (Names[Index].Initial != NULL && Names[Index].Initial[0] != 0)
  1115.        sprintf(Name,"%s, %s %s. ", Names[Index].LName, Names[Index].FName,
  1116.                Names[Index].Initial);
  1117.      else
  1118.        sprintf(Name,"%s, %s ", Names[Index].LName, Names[Index].FName);
  1119.      pCardRec->name = malloc(65);
  1120.      strcpy(pCardRec->name, Name);
  1121.  
  1122.      pCardRec->company = malloc(102);
  1123.      sprintf(pCardRec->company, "%s ", Names[Index].Company);
  1124.  
  1125.      pCardRec->state = malloc(4);
  1126.      sprintf(pCardRec->state, "%s ", Names[Index].State);
  1127.  
  1128.      pCardRec->CardId = Names[Index].CardId;
  1129.  
  1130.      FindBmp(&Names[Index], pCardRec);
  1131.  
  1132.      publicRecord = (PRECORDCORE)pCardRec;
  1133.      publicRecord->cb = sizeof(RECORDCORE);           /* structure size   */
  1134.      RecordInsert.pRecordOrder = (PRECORDCORE)CMA_END;
  1135.      RecordInsert.zOrder = (USHORT)CMA_TOP;
  1136.      RecordInsert.cRecordsInsert = (USHORT)1;
  1137.      RecordInsert.fInvalidateRecord = TRUE;
  1138.      RecordInsert.cb = sizeof(RECORDINSERT);
  1139.      RecordInsert.pRecordParent = NULL;
  1140.  
  1141.      WinSendMsg (hwndCnr,
  1142.                  CM_INSERTRECORD,
  1143.                  MPFROMP(publicRecord),
  1144.                  MPFROMP(&RecordInsert));
  1145.      Index++;
  1146.    }
  1147.    // 1 bmp, name, company, state
  1148.    pFieldInfo = (PFIELDINFO)WinSendMsg (hwndCnr,
  1149.                                         CM_ALLOCDETAILFIELDINFO,
  1150.                                         MPFROMSHORT(4),
  1151.                                         NULL);
  1152.  
  1153.   FirstFI = pFieldInfo;
  1154.  
  1155.    // set up the columns for details view
  1156.  
  1157.   pFieldInfo->flData = CFA_BITMAPORICON | CFA_TOP | CFA_CENTER;
  1158.   pFieldInfo->offStruct = FIELDOFFSET(CARDREC, bitmap);
  1159.   pFieldInfo->cb = sizeof(FIELDINFO);          /* size of structure */
  1160.   pFieldInfo = pFieldInfo->pNextFieldInfo;
  1161.  
  1162.    pFieldInfo->flData = (CFA_STRING | CFA_TOP | CFA_LEFT);
  1163.    pFieldInfo->pUserData = pCardRec;
  1164.    pFieldInfo->offStruct = FIELDOFFSET(CARDREC, name);
  1165.    pFieldInfo->cb = sizeof(FIELDINFO);          /* size of structure */
  1166.    pFieldInfo = pFieldInfo->pNextFieldInfo;
  1167.  
  1168.    pFieldInfo->flData = (CFA_STRING | CFA_TOP | CFA_LEFT | CFA_SEPARATOR );
  1169.    pFieldInfo->pUserData = pCardRec;
  1170.    pFieldInfo->offStruct = FIELDOFFSET(CARDREC, company);
  1171.    pFieldInfo->cb = sizeof(FIELDINFO);          /* size of structure */
  1172.    pFieldInfo = pFieldInfo->pNextFieldInfo;
  1173.  
  1174.    pFieldInfo->flData = (CFA_STRING | CFA_TOP | CFA_LEFT);
  1175.    pFieldInfo->pUserData = pCardRec;
  1176.    pFieldInfo->offStruct = FIELDOFFSET(CARDREC, state);
  1177.    pFieldInfo->cb = sizeof(FIELDINFO);          /* size of structure */
  1178.  
  1179.    /**********************************************/
  1180.    /* Insert the FieldInfo's into the container. */
  1181.    /**********************************************/
  1182.    FieldInfoInsert.pFieldInfoOrder = (PFIELDINFO)CMA_END;
  1183.    FieldInfoInsert.cFieldInfoInsert = (USHORT)4;
  1184.    FieldInfoInsert.cb = sizeof(FIELDINFOINSERT);
  1185.    FieldInfoInsert.fInvalidateFieldInfo = TRUE;
  1186.  
  1187.    NumFIs = (ULONG)WinSendMsg (hwndCnr,
  1188.                         CM_INSERTDETAILFIELDINFO,
  1189.                         MPFROMP(FirstFI),
  1190.                         MPFROMP(&FieldInfoInsert));
  1191.  
  1192.  
  1193.  
  1194.    return (FirstFI);
  1195.  }
  1196.  return (NULL);
  1197. }
  1198.  
  1199. // used to filter the index list by name
  1200. BOOL EXPENTRY pfnfilterName(PRECORDCORE p, PVOID pStorage)
  1201. {
  1202.      CARDREC  *pCardRec;
  1203.      USHORT   i=0, j=0, tot;
  1204.      CHAR     *txt, test, targetchar;
  1205.  
  1206.      pCardRec = (CARDREC *)p;
  1207.      txt = (CHAR *)pStorage;
  1208.  
  1209.      tot = strlen(txt);
  1210.      while (i < tot) {
  1211.        if (txt[i] == ',') {
  1212.          // get to the comma
  1213.          while ((pCardRec->name[j] != '\0') && (pCardRec->name[j] != ',')) {
  1214.            j++;
  1215.          }
  1216.          if (pCardRec->name[j] == '\0')
  1217.            return TRUE;
  1218.          j++; // get past the comma
  1219.          i++; // get past the comma
  1220.          continue;  // skip this one, commas
  1221.        }
  1222.        if (txt[i] == ' ') {
  1223.          i++;
  1224.          continue;  // skip blanks
  1225.        }
  1226.  
  1227.        if (pCardRec->name[j] == ' ') {
  1228.          j++;
  1229.          continue;  // skip blanks
  1230.        }
  1231.  
  1232.        // need to be case insenstitive
  1233.        test = tolower(txt[i]);
  1234.        targetchar = tolower(pCardRec->name[j]);
  1235.        if (test != targetchar)
  1236.          return FALSE;  // failed the test, throw it out
  1237.        else {
  1238.          j++;
  1239.          i++;
  1240.        }
  1241.      }
  1242.      return TRUE; // passed all tests, keep it
  1243. }
  1244.  
  1245. // used to filter the index list by company
  1246. BOOL EXPENTRY pfnfilterComp(PRECORDCORE p, PVOID pStorage)
  1247. {
  1248.      CARDREC  *pCardRec;
  1249.      USHORT   i=0, j=0, tot;
  1250.      CHAR     *txt, test, targetchar;
  1251.  
  1252.      pCardRec = (CARDREC *)p;
  1253.      txt = (CHAR *)pStorage;
  1254.  
  1255.      tot = strlen(txt);
  1256.      while (i < tot) {
  1257.        if (txt[i] == ' ') {
  1258.          i++;
  1259.          continue;  // skip blanks
  1260.        }
  1261.  
  1262.        if (pCardRec->company[j] == ' ') {
  1263.          j++;
  1264.          continue;  // skip blanks
  1265.        }
  1266.  
  1267.        // need to be case insenstitive
  1268.        test = tolower(txt[i]);
  1269.        targetchar = tolower(pCardRec->company[j]);
  1270.        if (test != targetchar)
  1271.          return FALSE;  // failed the test, throw it out
  1272.        else {
  1273.          j++;
  1274.          i++;
  1275.        }
  1276.      }
  1277.      return TRUE; // passed all tests, keep it
  1278. }
  1279.  
  1280. // used to filter the index list by state
  1281. BOOL EXPENTRY pfnfilterState(PRECORDCORE p, PVOID pStorage)
  1282. {
  1283.      CARDREC  *pCardRec;
  1284.      USHORT   i=0, j=0, tot;
  1285.      CHAR     *txt, test, targetchar;
  1286.  
  1287.      pCardRec = (CARDREC *)p;
  1288.      txt = (CHAR *)pStorage;
  1289.  
  1290.      tot = strlen(txt);
  1291.      while (i < tot) {
  1292.        if (txt[i] == ' ') {
  1293.          i++;
  1294.          continue;  // skip blanks
  1295.        }
  1296.  
  1297.        if (pCardRec->state[j] == ' ') {
  1298.          j++;
  1299.          continue;  // skip blanks
  1300.        }
  1301.  
  1302.        // need to be case insenstitive
  1303.        test = tolower(txt[i]);
  1304.        targetchar = tolower(pCardRec->state[j]);
  1305.        if (test != targetchar)
  1306.          return FALSE;  // failed the test, throw it out
  1307.        else {
  1308.          j++;
  1309.          i++;
  1310.        }
  1311.      }
  1312.      return TRUE; // passed all tests, keep it
  1313. }
  1314.  
  1315. MRESULT EXPENTRY EditBCardDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
  1316. {
  1317.   CHAR   szFontName[13], bmp_file[16], MailID[19], Addr[70], name[32];
  1318.   LONG   indx = CLR_BLACK;
  1319.   POINTL points;
  1320.   SHORT  Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX, ID;
  1321.   USHORT bmp_length=0;
  1322.   INT    hf;
  1323.   ULONG  ulWindowStyle=WS_GROUP | WS_TABSTOP | WS_VISIBLE, Index;
  1324.   HWND   hwndDlg, hwndHWX;
  1325. static  HWND hwnd2;
  1326. static  CARDINFO *CardInfo=NULL;
  1327.  
  1328.   switch (message)
  1329.   {
  1330.     case WM_INITDLG:
  1331.       // set the to black text
  1332.       WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  1333.  
  1334.       // set the font
  1335.       strcpy( szFontName, "10.Helv");
  1336.       WinSetPresParam( hwnd, PP_FONTNAMESIZE,
  1337.                       (LONG)strlen( szFontName ) + 1L,
  1338.                       (PVOID)szFontName );
  1339.       // set the font
  1340.       strcpy( szFontName, "8.Helv");
  1341.       WinSetPresParam(WinWindowFromID(hwnd, ID_MORE), PP_FONTNAMESIZE,
  1342.                       (LONG)strlen( szFontName ) + 1L,
  1343.                       (PVOID)szFontName );
  1344.  
  1345.       // create hwnadwriting controls
  1346.       CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
  1347.       CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
  1348.       BaseLineDY = CharBoxDY / 3;
  1349.  
  1350.       // x and y pos from dlg coords to win coords
  1351.       points.x = 45;
  1352.       points.y = 207;
  1353.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1354.  
  1355.       // find optimal size for handwriting comb
  1356.       Cols = 10;
  1357.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1358.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1359.  
  1360.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1361.                        points.x, points.y, ControlDX, ControlDY,
  1362.                        hwnd, HWND_TOP, ID_HWX_FNAME, NULL, NULL );
  1363.  
  1364.       // x and y pos from dlg coords to win coords
  1365.       points.x = 45;
  1366.       points.y = 187;
  1367.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1368.  
  1369.       // find optimal size for handwriting comb
  1370.       Cols = 10;
  1371.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1372.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1373.  
  1374.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1375.                        points.x, points.y, ControlDX, ControlDY,
  1376.                        hwnd, HWND_TOP, ID_HWX_LNAME, NULL, NULL );
  1377.  
  1378.       // x and y pos from dlg coords to win coords
  1379.       points.x = 45;
  1380.       points.y = 167;
  1381.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1382.  
  1383.       // find optimal size for handwriting comb
  1384.       Cols = 1;
  1385.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1386.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1387.  
  1388.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1389.                        points.x, points.y, ControlDX, ControlDY,
  1390.                        hwnd, HWND_TOP, ID_HWX_INIT, NULL, NULL );
  1391.  
  1392.       // x and y pos from dlg coords to win coords
  1393.       points.x = 45;
  1394.       points.y = 127;
  1395.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1396.  
  1397.       // find optimal size for handwriting comb
  1398.       Cols = 15;
  1399.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1400.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1401.  
  1402.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1403.                        points.x, points.y, ControlDX, ControlDY,
  1404.                        hwnd, HWND_TOP, ID_HWX_DIV, NULL, NULL );
  1405.  
  1406.       // x and y pos from dlg coords to win coords
  1407.       points.x = 45;
  1408.       points.y = 147;
  1409.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1410.  
  1411.       // find optimal size for handwriting comb
  1412.       Cols = 15;
  1413.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1414.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1415.  
  1416.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1417.                        points.x, points.y, ControlDX, ControlDY,
  1418.                        hwnd, HWND_TOP, ID_HWX_COMP, NULL, NULL );
  1419.  
  1420.       // x and y pos from dlg coords to win coords
  1421.       points.x = 25;
  1422.       points.y = 87;
  1423.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1424.  
  1425.       // find optimal size for handwriting comb
  1426.       Cols = 15;
  1427.       ControlDY = (2*(CharBoxDY + BaseLineDY)) + BaseLineDY;
  1428.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1429.  
  1430.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1431.                        points.x, points.y, ControlDX, ControlDY,
  1432.                        hwnd, HWND_TOP, ID_HWX_STREET, NULL, NULL );
  1433.  
  1434.       // x and y pos from dlg coords to win coords
  1435.       points.x = 25;
  1436.       points.y = 67;
  1437.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1438.  
  1439.       // find optimal size for handwriting comb
  1440.       Cols = 15;
  1441.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1442.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1443.  
  1444.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1445.                        points.x, points.y, ControlDX, ControlDY,
  1446.                        hwnd, HWND_TOP, ID_HWX_CITY, NULL, NULL );
  1447.  
  1448.       // x and y pos from dlg coords to win coords
  1449.       points.x = 25;
  1450.       points.y = 47;
  1451.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1452.  
  1453.       // find optimal size for handwriting comb
  1454.       Cols = 2;
  1455.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1456.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1457.  
  1458.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1459.                        points.x, points.y, ControlDX, ControlDY,
  1460.                        hwnd, HWND_TOP, ID_HWX_STATE, NULL, NULL );
  1461.  
  1462.       // x and y pos from dlg coords to win coords
  1463.       points.x = 25;
  1464.       points.y = 27;
  1465.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1466.  
  1467.       // find optimal size for handwriting comb
  1468.       Cols = 10;
  1469.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1470.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1471.  
  1472.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1473.                        points.x, points.y, ControlDX, ControlDY,
  1474.                        hwnd, HWND_TOP, ID_HWX_ZIP, NULL, NULL );
  1475.  
  1476.  
  1477.       // if empty then its an update
  1478.       if (mp2 != 0L) {
  1479.         CardInfo = (CARDINFO *)mp2;
  1480.         // show the info already stored
  1481.         WinSetDlgItemText(hwnd, ID_HWX_FNAME, CardInfo->FName);
  1482.         WinSetDlgItemText(hwnd, ID_HWX_LNAME, CardInfo->LName);
  1483.         WinSetDlgItemText(hwnd, ID_HWX_INIT, CardInfo->Initial);
  1484.         WinSetDlgItemText(hwnd, ID_HWX_COMP, CardInfo->Company);
  1485.         WinSetDlgItemText(hwnd, ID_HWX_DIV, CardInfo->Division);
  1486.         WinSetDlgItemText(hwnd, ID_HWX_STREET, CardInfo->StrAddr);
  1487.         WinSetDlgItemText(hwnd, ID_HWX_CITY, CardInfo->City);
  1488.         WinSetDlgItemText(hwnd, ID_HWX_ZIP, CardInfo->Zip);
  1489.         WinSetDlgItemText(hwnd, ID_HWX_STATE, CardInfo->State);
  1490.         // create page2
  1491.         hwnd2 = WinLoadDlg(HWND_DESKTOP, hwnd, (PFNWP)EditBCard2DlgProc, (HMODULE)NULL, ID_BEDIT2, CardInfo);
  1492.       }
  1493.       else
  1494.         // create page2
  1495.         hwnd2 = WinLoadDlg(HWND_DESKTOP, hwnd, (PFNWP)EditBCard2DlgProc, (HMODULE)NULL, ID_BEDIT2, 0L);
  1496.       WinSetFocus(HWND_DESKTOP, hwnd);
  1497.  
  1498.    return (MRESULT)TRUE ;
  1499.  
  1500.    case  WM_CONTROL:
  1501.     switch (HIUSHORT(mp1))
  1502.     {
  1503.         default:
  1504.         return WinDefWindowProc(hwnd, message, mp1, mp2);
  1505.     }
  1506.     return (MRESULT)TRUE ;
  1507.  
  1508.    case WM_COMMAND:
  1509.     switch (LOUSHORT(mp1))
  1510.     {
  1511.        case ID_MORE:
  1512.          WinSetWindowPos(hwnd, HWND_TOP, 0, 0, (SHORT)0, (SHORT)0, SWP_SIZE);
  1513.          WinSetWindowPos(hwnd2, HWND_TOP, 15, 10, (SHORT)0,
  1514.                          (SHORT)0, SWP_MOVE | SWP_ACTIVATE | SWP_SHOW);
  1515.        break;
  1516.  
  1517.        case DID_CANCEL:
  1518.          WinSendMsg(hwnd2, WM_CLOSE, 0L, 0L);
  1519.          WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  1520.        break;
  1521.  
  1522.        case DID_OK:
  1523.          // allocate memory for the new card
  1524. //        if (CardInfo == NULL)
  1525. //          CardInfo = (CARDINFO *)malloc(sizeof(CARDINFO);
  1526.          // save the info
  1527.         WinQueryDlgItemText(hwnd, ID_HWX_FNAME, 10, CardInfo->FName);
  1528.         WinQueryDlgItemText(hwnd, ID_HWX_LNAME, 10, CardInfo->LName);
  1529.         WinQueryDlgItemText(hwnd, ID_HWX_INIT, 1, CardInfo->Initial);
  1530.         WinQueryDlgItemText(hwnd, ID_HWX_COMP, 15, CardInfo->Company);
  1531.         WinQueryDlgItemText(hwnd, ID_HWX_DIV, 15, CardInfo->Division);
  1532.         WinQueryDlgItemText(hwnd, ID_HWX_STREET, 30, CardInfo->StrAddr);
  1533.         WinQueryDlgItemText(hwnd, ID_HWX_CITY, 15, CardInfo->City);
  1534.         WinQueryDlgItemText(hwnd, ID_HWX_ZIP, 10, CardInfo->Zip);
  1535.         WinQueryDlgItemText(hwnd, ID_HWX_STATE, 2, CardInfo->State);
  1536.  
  1537.         // call page 2 and see what info was set ...
  1538.         WinSendMsg(hwnd2, WM_COMMAND, MPFROMSHORT(DID_OKPAGE2), (MPARAM)CardInfo);
  1539.         WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  1540.        break;
  1541.  
  1542.        default:
  1543.        return WinDefWindowProc(hwnd, message, mp1, mp2);
  1544.     }
  1545.     break;
  1546.  
  1547.     case WM_CLOSE:
  1548.       WinDismissDlg(hwnd, TRUE);
  1549.     return (MRESULT) TRUE;
  1550.  
  1551.     default:
  1552.       return(WinDefDlgProc(hwnd,message,mp1,mp2));
  1553.   }
  1554.   return(0L);
  1555. }
  1556.  
  1557. MRESULT EXPENTRY EditBCard2DlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
  1558. {
  1559.   CHAR   szFontName[13], bmp_file[16], MailID[19], Addr[70], name[32];
  1560.   LONG   indx = CLR_BLACK;
  1561.   POINTL points;
  1562.   SHORT  Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX, ID;
  1563.   USHORT bmp_length=0;
  1564.   INT    hf;
  1565.   ULONG  ulWindowStyle=WS_GROUP | WS_TABSTOP | WS_VISIBLE, Index;
  1566.   HWND   hwndDlg, hwndHWX;
  1567.   PRECORDCORE    pRecord;    /* Pointer to RECORDCORE structure     */
  1568.   CARDREC        *pCardRec;
  1569.   BOOL           Found = FALSE;
  1570. static  CARDINFO *CardInfo=NULL;
  1571.  
  1572.   switch (message)
  1573.   {
  1574.     case WM_INITDLG:
  1575.       // set the to black text
  1576.       WinSetPresParam(hwnd, PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  1577.  
  1578.       // set the font
  1579.       strcpy( szFontName, "10.Helv");
  1580.       WinSetPresParam( hwnd, PP_FONTNAMESIZE,
  1581.                       (LONG)strlen( szFontName ) + 1L,
  1582.                       (PVOID)szFontName );
  1583.       // set the font
  1584.       strcpy( szFontName, "8.Helv");
  1585.       WinSetPresParam(WinWindowFromID(hwnd, ID_MORE), PP_FONTNAMESIZE,
  1586.                       (LONG)strlen( szFontName ) + 1L,
  1587.                       (PVOID)szFontName );
  1588.  
  1589.       // create hwnadwriting controls
  1590.       CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
  1591.       CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
  1592.       BaseLineDY = CharBoxDY / 3;
  1593.  
  1594.  
  1595.       // x and y pos from dlg coords to win coords
  1596.       points.x = 40;
  1597.       points.y = 127;
  1598.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1599.  
  1600.       // find optimal size for handwriting comb
  1601.       Cols = 15;
  1602.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1603.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1604.  
  1605.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1606.                        points.x, points.y, ControlDX, ControlDY,
  1607.                        hwnd, HWND_TOP, ID_HWX_PHONE, NULL, NULL );
  1608.  
  1609.       // x and y pos from dlg coords to win coords
  1610.       points.x = 40;
  1611.       points.y = 107;
  1612.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1613.  
  1614.       // find optimal size for handwriting comb
  1615.       Cols = 15;
  1616.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1617.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1618.  
  1619.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1620.                        points.x, points.y, ControlDX, ControlDY,
  1621.                        hwnd, HWND_TOP, ID_HWX_FAX, NULL, NULL );
  1622.  
  1623.       // x and y pos from dlg coords to win coords
  1624.       points.x = 40;
  1625.       points.y = 87;
  1626.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1627.  
  1628.       // find optimal size for handwriting comb
  1629.       Cols = 8;
  1630.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1631.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1632.  
  1633.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1634.                        points.x, points.y, ControlDX, ControlDY,
  1635.                        hwnd, HWND_TOP, ID_HWX_PAGER, NULL, NULL );
  1636.  
  1637.       // x and y pos from dlg coords to win coords
  1638.       points.x = 40;
  1639.       points.y = 67;
  1640.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1641.  
  1642.       // find optimal size for handwriting comb
  1643.       Cols = 8;
  1644.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1645.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1646.  
  1647.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1648.                        points.x, points.y, ControlDX, ControlDY,
  1649.                        hwnd, HWND_TOP, ID_HWX_USERID, NULL, NULL );
  1650.  
  1651.       // x and y pos from dlg coords to win coords
  1652.       points.x = 40;
  1653.       points.y = 47;
  1654.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1655.  
  1656.       // find optimal size for handwriting comb
  1657.       Cols = 8;
  1658.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1659.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1660.  
  1661.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1662.                        points.x, points.y, ControlDX, ControlDY,
  1663.                        hwnd, HWND_TOP, ID_HWX_NODEID, NULL, NULL );
  1664.  
  1665.       // x and y pos from dlg coords to win coords
  1666.       points.x = 40;
  1667.       points.y = 27;
  1668.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  1669.  
  1670.       // find optimal size for handwriting comb
  1671.       Cols = 15;
  1672.       ControlDY = (CharBoxDY + BaseLineDY) + BaseLineDY;
  1673.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  1674.  
  1675.       hwndHWX = WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  1676.                        points.x, points.y, ControlDX, ControlDY,
  1677.                        hwnd, HWND_TOP, ID_HWX_BITMAP, NULL, NULL );
  1678.  
  1679.       // if empty then its an update
  1680.       if (mp2 != 0L) {
  1681.         CardInfo = (CARDINFO *)mp2;
  1682.         // show the info already stored
  1683.         WinSetDlgItemText(hwnd, ID_HWX_PHONE, CardInfo->Phone);
  1684.         WinSetDlgItemText(hwnd, ID_HWX_FAX, CardInfo->Fax);
  1685.         WinSetDlgItemText(hwnd, ID_HWX_PAGER, CardInfo->PagerID);
  1686.         WinSetDlgItemText(hwnd, ID_HWX_USERID, CardInfo->MailUserId);
  1687.         WinSetDlgItemText(hwnd, ID_HWX_NODEID, CardInfo->MailNodeId);
  1688.       }
  1689.  
  1690.    return (MRESULT)TRUE ;
  1691.  
  1692.    case  WM_CONTROL:
  1693.     switch (HIUSHORT(mp1))
  1694.     {
  1695.         default:
  1696.         return WinDefWindowProc(hwnd, message, mp1, mp2);
  1697.     }
  1698.     return (MRESULT)TRUE ;
  1699.  
  1700.    case WM_COMMAND:
  1701.     switch (LOUSHORT(mp1))
  1702.     {
  1703.        case ID_MORE:
  1704.          WinShowWindow(hwnd, FALSE);
  1705.          // x and y pos from dlg coords to win coords
  1706.          points.x = 310;
  1707.          points.y = 245;
  1708.          WinMapDlgPoints(WinQueryWindow( hwnd, QW_OWNER), &points, 1L, TRUE);
  1709.          WinSetWindowPos(WinQueryWindow( hwnd, QW_OWNER), HWND_TOP, 0, 0,
  1710.                          (SHORT)points.x, (SHORT)points.y, SWP_ACTIVATE | SWP_SIZE);
  1711.        break;
  1712.  
  1713.        case DID_CANCEL:
  1714.          WinSendMsg(WinQueryWindow( hwnd, QW_OWNER), WM_CLOSE, 0L, 0L);
  1715.          WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  1716.        break;
  1717.  
  1718.        case DID_OK:
  1719.          WinSendMsg(WinQueryWindow( hwnd, QW_OWNER), WM_COMMAND,
  1720.                     (MPARAM)DID_OK, 0L);
  1721.        break;
  1722.  
  1723.        case DID_OKPAGE2:
  1724.         CardInfo = (CARDINFO *)mp2;
  1725.         // save the info
  1726.         WinQueryDlgItemText(hwnd, ID_HWX_PHONE, 15, CardInfo->Phone);
  1727.         WinQueryDlgItemText(hwnd, ID_HWX_FAX, 15, CardInfo->Fax);
  1728.         WinQueryDlgItemText(hwnd, ID_HWX_PAGER, 8, CardInfo->PagerID);
  1729.         WinQueryDlgItemText(hwnd, ID_HWX_USERID, 8, CardInfo->MailUserId);
  1730.         WinQueryDlgItemText(hwnd, ID_HWX_NODEID, 8, CardInfo->MailNodeId);
  1731.  
  1732.         WinQueryDlgItemText(hwnd, ID_HWX_BITMAP, 15, bmp_file);
  1733.  
  1734.         /* read the bitmap file  */
  1735.         if (bmp_file[0] != 0) {
  1736.           hf = open(bmp_file, O_RDONLY | O_BINARY);
  1737.           if (hf != -1 && hf != 0) {
  1738.             bmp_length = read(hf, bmp_file, FILE_MAXSIZE);
  1739.             close(hf);
  1740.           }
  1741.         }
  1742.         if (CardInfo != NULL) {
  1743.           // update the data Base
  1744. //          PrepUpdRec(CardInfo, bmp_file, bmp_length);
  1745.           // find out which card to update
  1746.           hwndDlg = (HWND)WinSendMsg(hwndNB, BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(CardInfo->CardId), 0L);
  1747.           ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
  1748.           // on a single card page
  1749.           if (ID == ID_BCARD) {
  1750.             // update the data on the Business Card
  1751.             if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
  1752.               sprintf(name,"%s %s. %s", CardInfo->FName, CardInfo->Initial,
  1753.                       CardInfo->LName);
  1754.             else
  1755.                sprintf(name,"%s %s", CardInfo->FName, CardInfo->LName);
  1756.             WinSetDlgItemText(hwndDlg, ID_NAME, name);
  1757.             WinSetDlgItemText(hwndDlg, ID_COMPANY, CardInfo->Company);
  1758.             WinSetDlgItemText(hwndDlg, ID_DEPT, CardInfo->Division);
  1759.             sprintf(Addr, "%s\n%s\n%s %s", CardInfo->StrAddr, CardInfo->City,
  1760.                     CardInfo->State, CardInfo->Zip);
  1761.             WinSetDlgItemText(hwndDlg, ID_ADDR, Addr);
  1762.             WinSetDlgItemText(hwndDlg, ID_PHONE, CardInfo->Phone);
  1763.             WinSetDlgItemText(hwndDlg, ID_FAX, CardInfo->Fax);
  1764.             WinSetDlgItemText(hwndDlg, ID_PAGER, CardInfo->PagerID);
  1765.             sprintf(MailID, "%s@%s", CardInfo->MailUserId, CardInfo->MailNodeId);
  1766.             WinSetDlgItemText(hwndDlg, ID_MAILID, MailID);
  1767.           }
  1768.           // on a double card page
  1769.           else {
  1770.             Index = (ULONG)WinQueryWindowULong(hwndDlg, 0);
  1771.             // find out which card
  1772.             if (CardInfo->RecId == Names[Index].RecId) {
  1773.               // update the data on the Business Card
  1774.               if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
  1775.                 sprintf(name,"%s %s. %s", CardInfo->FName, CardInfo->Initial,
  1776.                         CardInfo->LName);
  1777.               else
  1778.                  sprintf(name,"%s %s", CardInfo->FName, CardInfo->LName);
  1779.               WinSetDlgItemText(hwndDlg, ID_NAME2, name);
  1780.               WinSetDlgItemText(hwndDlg, ID_COMPANY2, CardInfo->Company);
  1781.               WinSetDlgItemText(hwndDlg, ID_DEPT2, CardInfo->Division);
  1782.               sprintf(Addr, "%s\n%s\n%s %s", CardInfo->StrAddr, CardInfo->City,
  1783.                       CardInfo->State, CardInfo->Zip);
  1784.               WinSetDlgItemText(hwndDlg, ID_ADDR2, Addr);
  1785.               WinSetDlgItemText(hwndDlg, ID_PHONE2, CardInfo->Phone);
  1786.               WinSetDlgItemText(hwndDlg, ID_FAX2, CardInfo->Fax);
  1787.               WinSetDlgItemText(hwndDlg, ID_PAGER2, CardInfo->PagerID);
  1788.               sprintf(MailID, "%s@%s", CardInfo->MailUserId, CardInfo->MailNodeId);
  1789.               WinSetDlgItemText(hwndDlg, ID_MAILID2, MailID);
  1790.             }
  1791.             else {
  1792.               // update the data on the Business Card
  1793.               if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
  1794.                 sprintf(name,"%s %s. %s", CardInfo->FName, CardInfo->Initial,
  1795.                         CardInfo->LName);
  1796.               else
  1797.                  sprintf(name,"%s %s", CardInfo->FName, CardInfo->LName);
  1798.               WinSetDlgItemText(hwndDlg, ID_NAME1, name);
  1799.               WinSetDlgItemText(hwndDlg, ID_COMPANY1, CardInfo->Company);
  1800.               WinSetDlgItemText(hwndDlg, ID_DEPT1, CardInfo->Division);
  1801.               sprintf(Addr, "%s\n%s\n%s %s", CardInfo->StrAddr, CardInfo->City,
  1802.                       CardInfo->State, CardInfo->Zip);
  1803.               WinSetDlgItemText(hwndDlg, ID_ADDR1, Addr);
  1804.               WinSetDlgItemText(hwndDlg, ID_PHONE1, CardInfo->Phone);
  1805.               WinSetDlgItemText(hwndDlg, ID_FAX1, CardInfo->Fax);
  1806.               WinSetDlgItemText(hwndDlg, ID_PAGER1, CardInfo->PagerID);
  1807.               sprintf(MailID, "%s@%s", CardInfo->MailUserId, CardInfo->MailNodeId);
  1808.               WinSetDlgItemText(hwndDlg, ID_MAILID1, MailID);
  1809.             }
  1810.           }
  1811.           // Update the Index page container info
  1812.           pRecord = WinSendMsg (WinWindowFromID(hwndIndex, ID_CONTAINER),
  1813.                                 CM_QUERYRECORD, 0L,
  1814.                                 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
  1815.           while ((pRecord != NULL) && (Found == FALSE)) {
  1816.              pCardRec = (CARDREC *) pRecord;
  1817.              if (pCardRec->CardId == CardInfo->CardId) {
  1818.                strcpy(pCardRec->name, name);
  1819.                strcpy(pCardRec->company, CardInfo->Company);
  1820.                strcpy(pCardRec->state, CardInfo->State);
  1821.                FindBmp(CardInfo, pCardRec);
  1822.                WinSendMsg(WinWindowFromID(hwndIndex, ID_CONTAINER),
  1823.                           CM_INVALIDATEDETAILFIELDINFO, 0L, 0L);
  1824.                Found = TRUE; // jump out of while loop;
  1825.              }
  1826.              else
  1827.                pRecord = WinSendMsg (WinWindowFromID(hwndIndex, ID_CONTAINER),
  1828.                                      CM_QUERYRECORD, MPFROMP(pRecord),
  1829.                                      MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
  1830.           }
  1831.  
  1832.         }
  1833.         // add a new entry
  1834. //        else {
  1835. //          PrepAddToRec(CardInfo, bmp_file, bmp_length)
  1836.           // Add a page
  1837. //          BCardId = (LONG)WinSendMsg(hwndNB, BKM_INSERTPAGE, (MPARAM)BCardId,
  1838. //                                     MPFROM2SHORT(BKA_STATUSTEXTON, BKA_NEXT));
  1839. //          Names[x].CardId = BCardId;
  1840. //          hwndPage = WinLoadDlg(hwndNB, (HWND)NULLHANDLE, (PFNWP)CardDlgProc,
  1841. //                                (HMODULE)NULL, (ULONG)ID_BCARD, &Names[x]);
  1842. //          WinSendMsg(hwndNB, BKM_SETPAGEWINDOWHWND, MPFROMP(BCardId),
  1843. //                     MPFROMLONG(hwndPage));
  1844. //          WinSetWindowPos(hwndPage, NULLHANDLE, (ULONG) 10, (ULONG) 10,
  1845. //                          0, 0, SWP_MOVE);
  1846. //        }
  1847.  
  1848.          WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  1849.        break;
  1850.  
  1851.        default:
  1852.        return WinDefWindowProc(hwnd, message, mp1, mp2);
  1853.     }
  1854.     break;
  1855.  
  1856.     case WM_CLOSE:
  1857.       WinDestroyWindow(hwnd);
  1858.     return (MRESULT) TRUE;
  1859.  
  1860.     default:
  1861.       return(WinDefDlgProc(hwnd,message,mp1,mp2));
  1862.   }
  1863.   return(0L);
  1864. }
  1865.  
  1866. VOID  ProcessReco(MPARAM mp1, MPARAM mp2)
  1867. {
  1868.         RECODATA *recodata;
  1869.         HWND     hwnd, hwndDlg;
  1870.         CARDINFO *CardInfo;
  1871.         CHAR     txt[140], tmpBuff[606];
  1872.         PVOID    buff;
  1873.         ULONG    ID, index, PageID, i, rc;
  1874.         RECTL    rect;
  1875.         CHAR     ProgName[9];
  1876.         RESULTCODES rcs;
  1877.         RESULTCODES far *rcsptr = &rcs;
  1878.         CHAR        buffer[200], string1[45];
  1879.         char far    *Argptr = string1;
  1880.  
  1881.         recodata = (RECODATA *) mp2;
  1882.         hwnd = (HWND) mp1;
  1883.  
  1884.         // some one drew a letter gesture
  1885.         if (recodata->virtual_id == VE_LETTERGESTURE) {
  1886.           // user wants to play back a greeting
  1887.           if (recodata->char_code == 'V') {
  1888.             // find file name, == recid
  1889.             ID = WinQueryWindowUShort(hwnd, QWS_ID);
  1890.             // if it is the top level window (DLGBOX)
  1891.             if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
  1892.                 (ID == ID_BCARD) || (ID == ID_BCARD2))
  1893.               hwndDlg = hwnd;
  1894.             else  {
  1895.               hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
  1896.               ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
  1897.             }
  1898.  
  1899.             // do dos exec to play back the sound
  1900.             strcpy( ProgName, "MPPM.EXE");
  1901.  
  1902.             if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
  1903.               if (ID == ID_BCARD) {
  1904.                 CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
  1905. //                WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)VoiceDlgProc, (HMODULE)NULL, ID_VOICE, 0L);
  1906.                 // call API to playback the sound
  1907.                 sprintf(string1, "%s  %s\\%s.WAV /SC ", ProgName, BookPath, CardInfo->RecId);
  1908.               }
  1909.               else  {
  1910.                 index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
  1911.  
  1912.                 // find out which card the gesture was done on
  1913.                 WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
  1914.                 WinQueryWindowRect(hwndDlg, &rect);
  1915.                 if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y)
  1916. //                  WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)VoiceDlgProc, (HMODULE)NULL, ID_VOICE, 0L);
  1917.                   // call API to playback the sound
  1918.                   sprintf(string1, "%s  %s\\%s.WAV /SC ", ProgName, BookPath, Names[index+1].RecId);
  1919.                 else
  1920. //                  WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)VoiceDlgProc, (HMODULE)NULL, ID_VOICE, 0L);
  1921.                   // call API to playback the sound
  1922.                   sprintf(string1, "%s  %s\\%s.WAV /SC ", ProgName, BookPath, Names[index].RecId);
  1923.               }
  1924.             }
  1925.             else {  // Welcome sounds
  1926.               // call API to playback the sound
  1927.               sprintf(string1,"%s ", ProgName);
  1928.               sprintf(string1, "%s %s\\welcome.WAV /SC", string1, BookPath);
  1929.             }
  1930.  
  1931.            for (i = strlen(string1); i--; )
  1932.              if (string1[i] == ' ')
  1933.                string1[i] = 0;
  1934.             rc = DosExecPgm( buffer, sizeof(buffer), 1, Argptr, 0, rcsptr, ProgName);
  1935.             if (rc) {
  1936.               DosBeep(500,500);
  1937.               DosBeep(800,500);
  1938.             }
  1939.           }
  1940.           // user wants to send a Pager transmittion
  1941.           else if (recodata->char_code == 'P') {
  1942.             ID = WinQueryWindowUShort(hwnd, QWS_ID);
  1943.             // if it is the top level window (DLGBOX)
  1944.             if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
  1945.                 (ID == ID_BCARD) || (ID == ID_BCARD2))
  1946.               hwndDlg = hwnd;
  1947.             else  {
  1948.               hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
  1949.               ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
  1950.             }
  1951.  
  1952.             if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
  1953.               if (ID == ID_BCARD) {
  1954.                 CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
  1955.                 WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)PagerDlgProc, (HMODULE)NULL, ID_PAGERPAD, CardInfo);
  1956.               }
  1957.               else  {
  1958.                 index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
  1959.  
  1960.                 // find out which card the gesture was done on
  1961.                 WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
  1962.                 WinQueryWindowRect(hwndDlg, &rect);
  1963.                 if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y)
  1964.                   WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)PagerDlgProc, (HMODULE)NULL, ID_PAGERPAD, (PVOID)&Names[index+1]);
  1965.                 else
  1966.                   WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)PagerDlgProc, (HMODULE)NULL, ID_PAGERPAD, (PVOID)&Names[index]);
  1967.               }
  1968.             }
  1969.           }
  1970.           // user wants to send Mail
  1971.           else if (recodata->char_code == 'M') {
  1972.             ID = WinQueryWindowUShort(hwnd, QWS_ID);
  1973.             // if it is the top level window (DLGBOX)
  1974.             if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
  1975.                 (ID == ID_BCARD) || (ID == ID_BCARD2))
  1976.               hwndDlg = hwnd;
  1977.             else  {
  1978.               hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
  1979.               ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
  1980.             }
  1981.  
  1982.             if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
  1983.               if (ID == ID_BCARD) {
  1984.                 CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
  1985.                 WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)MailDlgProc, (HMODULE)NULL, ID_MAILPAD, CardInfo);
  1986.               }
  1987.               else  {
  1988.                 index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
  1989.  
  1990.                 // find out which card the gesture was done on
  1991.                 WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
  1992.                 WinQueryWindowRect(hwndDlg, &rect);
  1993.                 if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y)
  1994.                   WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)MailDlgProc, (HMODULE)NULL, ID_MAILPAD, (PVOID)&Names[index+1]);
  1995.                 else
  1996.                   WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)MailDlgProc, (HMODULE)NULL, ID_MAILPAD, (PVOID)&Names[index]);
  1997.               }
  1998.             }
  1999.           }
  2000.           // user wants Add to the book
  2001.           else if (recodata->char_code == 'A') {
  2002.             WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)EditBCardDlgProc, (HMODULE)NULL, ID_BEDIT, 0L);
  2003.           }
  2004.  
  2005.           // user wants Remove an entry from the book
  2006.           else if (recodata->char_code == 'R') {
  2007.             ID = WinQueryWindowUShort(hwnd, QWS_ID);
  2008.             // if it is the top level window (DLGBOX)
  2009.             if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
  2010.                 (ID == ID_BCARD) || (ID == ID_BCARD2))
  2011.               hwndDlg = hwnd;
  2012.             else  {
  2013.               hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
  2014.               ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
  2015.             }
  2016.  
  2017.             if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
  2018.               if (ID == ID_BCARD) {
  2019.                 CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
  2020.                 sprintf(txt, "Are you sure that you want to delete the %s %s card?",
  2021.                       CardInfo->FName, CardInfo->LName);
  2022.               }
  2023.               else  {
  2024.                 index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
  2025.  
  2026.                 // find out which card the gesture was done on
  2027.                 WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
  2028.                 WinQueryWindowRect(hwndDlg, &rect);
  2029.                 if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y)
  2030.                   sprintf(txt, "Are you sure that you want to delete the %s %s card?",
  2031.                         Names[index+1].FName, Names[index+1].LName);
  2032.                 else
  2033.                   sprintf(txt, "Are you sure that you want to delete the %s %s card?",
  2034.                         Names[index].FName, Names[index].LName);
  2035.               }
  2036.               WinMessageBox ( HWND_DESKTOP, hwndNB,
  2037.                               txt, "Contact/2", 0,
  2038.                               MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL | MB_MOVEABLE);
  2039.             }
  2040.           }
  2041.  
  2042.           // user wants to Update an entry in the book
  2043.           else if (recodata->char_code == 'U') {
  2044.             ID = WinQueryWindowUShort(hwnd, QWS_ID);
  2045.             // if it is the top level window (DLGBOX)
  2046.             if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
  2047.                 (ID == ID_BCARD) || (ID == ID_BCARD2))
  2048.               hwndDlg = hwnd;
  2049.             else  {
  2050.               hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
  2051.               ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
  2052.             }
  2053.  
  2054.             if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
  2055.               if (ID == ID_BCARD) {
  2056.                 CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
  2057.                 WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)EditBCardDlgProc, (HMODULE)NULL, ID_BEDIT, CardInfo);
  2058.               }
  2059.               else  {
  2060.                 index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
  2061.  
  2062.                 // find out which card the gesture was done on
  2063.                 WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
  2064.                 WinQueryWindowRect(hwndDlg, &rect);
  2065.                 if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y)
  2066.                   WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)EditBCardDlgProc, (HMODULE)NULL, ID_BEDIT, (PVOID)&Names[index+1]);
  2067.                 else
  2068.                   WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)EditBCardDlgProc, (HMODULE)NULL, ID_BEDIT, (PVOID)&Names[index]);
  2069.               }
  2070.             }
  2071.           }
  2072.           // user wants to Add an entry in the book to the clipboard
  2073.           else if (recodata->char_code == 'C') {
  2074.             ID = WinQueryWindowUShort(hwnd, QWS_ID);
  2075.             // if it is the top level window (DLGBOX)
  2076.             if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
  2077.                 (ID == ID_BCARD) || (ID == ID_BCARD2))
  2078.               hwndDlg = hwnd;
  2079.             else  {
  2080.               hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
  2081.               ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
  2082.             }
  2083.  
  2084.             if ((hwndDlg != hwndIndex) && (hwndDlg != hwndWelcome)) {
  2085.               if (ID == ID_BCARD) {
  2086.                 CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
  2087.                 sprintf(txt, "The card named %s %s has been copied to the clipboard.",
  2088.                       CardInfo->FName, CardInfo->LName);
  2089.                 sprintf(tmpBuff, "%s %s %s\n%s\n%s\n%s\n%s, %s %s\nPhone: %s\nFAX: %s\nPager ID: %s\n%s@%s\n",
  2090.                         CardInfo->FName, CardInfo->Initial, CardInfo->LName,
  2091.                         CardInfo->Company, CardInfo->Division, CardInfo->StrAddr,
  2092.                         CardInfo->City, CardInfo->State, CardInfo->Zip,
  2093.                         CardInfo->Phone, CardInfo->Fax, CardInfo->PagerID,
  2094.                         CardInfo->MailUserId, CardInfo->MailNodeId);
  2095.               }
  2096.               else  {
  2097.                 index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
  2098.  
  2099.                 // find out which card the gesture was done on
  2100.                 WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
  2101.                 WinQueryWindowRect(hwndDlg, &rect);
  2102.                 if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y) {
  2103.                   sprintf(txt, "The card named %s %s has been copied to the clipboard.",
  2104.                           Names[index+1].FName, Names[index+1].LName);
  2105.                 sprintf(tmpBuff, "%s %s %s\n%s\n%s\n%s\n%s, %s %s\nPhone: %s\nFAX: %s\nPager ID: %s\n%s@%s\n",
  2106.                         Names[index+1].FName, Names[index+1].Initial, Names[index+1].LName,
  2107.                         Names[index+1].Company, Names[index+1].Division, Names[index+1].StrAddr,
  2108.                         Names[index+1].City, Names[index+1].State, Names[index+1].Zip,
  2109.                         Names[index+1].Phone, Names[index+1].Fax, Names[index+1].PagerID,
  2110.                         Names[index+1].MailUserId, Names[index+1].MailNodeId);
  2111.                 }
  2112.                 else {
  2113.                   sprintf(txt, "The card named %s %s has been copied to the clipboard.",
  2114.                           Names[index].FName, Names[index].LName);
  2115.                 sprintf(tmpBuff, "%s %s %s\n%s\n%s\n%s\n%s, %s %s\nPhone: %s\nFAX: %s\nPager ID: %s\n%s@%s\n",
  2116.                         Names[index].FName, Names[index].Initial, Names[index].LName,
  2117.                         Names[index].Company, Names[index].Division, Names[index].StrAddr,
  2118.                         Names[index].City, Names[index].State, Names[index].Zip,
  2119.                         Names[index].Phone, Names[index].Fax, Names[index].PagerID,
  2120.                         Names[index].MailUserId, Names[index].MailNodeId);
  2121.                 }
  2122.               }
  2123.               // copy it to the clipboard
  2124.               DosAllocSharedMem(&buff, NULL, sizeof(tmpBuff), OBJ_GIVEABLE |
  2125.                                 PAG_COMMIT | PAG_READ | PAG_WRITE);
  2126.               strcpy(buff, tmpBuff);
  2127.               WinOpenClipbrd(hab);
  2128.               WinSetClipbrdData(hab, (ULONG)buff, CF_TEXT, CFI_POINTER);
  2129.               WinCloseClipbrd(hab);
  2130.  
  2131.               WinMessageBox ( HWND_DESKTOP, hwndNB,
  2132.                               txt, "Contact/2", 0,
  2133.                               MB_OK | MB_INFORMATION | MB_APPLMODAL | MB_MOVEABLE);
  2134.             }
  2135.           }
  2136.         }
  2137.         // bring up help
  2138.         else if (recodata->virtual_id == VE_HELP)
  2139.           WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)HelpDlgProc, (HMODULE)NULL, ID_HELP, 0L);
  2140.         // turn back a page
  2141.         else if (recodata->virtual_id == VE_SCROLLLEFT) {
  2142.             ID = WinQueryWindowUShort(hwnd, QWS_ID);
  2143.             if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
  2144.                 (ID == ID_BCARD) || (ID == ID_BCARD2))
  2145.               hwndDlg = hwnd;
  2146.             else  {
  2147.               hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
  2148.               ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
  2149.             }
  2150.  
  2151.             // turn to the index page
  2152.             if (hwndDlg == hwndWelcome)
  2153.               WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(IndexCardId), 0L);
  2154.             else if (hwndDlg == hwndIndex) {
  2155.                 PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
  2156.                                     MPFROMLONG(IndexCardId),
  2157.                                     MPFROM2SHORT(BKA_PREV, BKA_MAJOR));
  2158.               WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
  2159.             }
  2160.             else if (ID == ID_BCARD) {
  2161.               CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
  2162.                 // turn back a page
  2163.                 PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
  2164.                                     MPFROMLONG(CardInfo->CardId),
  2165.                                     MPFROM2SHORT(BKA_PREV, 0));
  2166.                 WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
  2167.             }
  2168.             else  {
  2169.               index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
  2170.  
  2171.               // find out which card the gesture was done on
  2172.               WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
  2173.               WinQueryWindowRect(hwndDlg, &rect);
  2174.               if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y) {
  2175.                 // turn back a page
  2176.                 PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
  2177.                                     MPFROMLONG(Names[index+1].CardId),
  2178.                                     MPFROM2SHORT(BKA_PREV, 0));
  2179.                 WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
  2180.               }
  2181.               else {
  2182.                 // turn back a page
  2183.                 PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
  2184.                                     MPFROMLONG(Names[index].CardId),
  2185.                                     MPFROM2SHORT(BKA_PREV, 0));
  2186.                 WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
  2187.               }
  2188.             }
  2189.         }
  2190.         // turn forward a page
  2191.         else if (recodata->virtual_id == VE_SCROLLRIGHT) {
  2192.             ID = WinQueryWindowUShort(hwnd, QWS_ID);
  2193.             if ((hwnd == hwndIndex) || (hwnd == hwndWelcome) ||
  2194.                 (ID == ID_BCARD) || (ID == ID_BCARD2))
  2195.               hwndDlg = hwnd;
  2196.             else  {
  2197.               hwndDlg = WinQueryWindow( hwnd, QW_OWNER);
  2198.               ID = WinQueryWindowUShort(hwndDlg, QWS_ID);
  2199.             }
  2200.             // turn to the first page
  2201.             if (hwndDlg == hwndWelcome) {
  2202.               PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
  2203.                                          MPFROMLONG(WelcomeCardId),
  2204.                                          MPFROM2SHORT(BKA_NEXT, BKA_MAJOR));
  2205.               WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
  2206.             }
  2207.             // turn to the welcome page
  2208.             else if (hwndDlg == hwndIndex)
  2209.               WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(WelcomeCardId), 0L);
  2210.             else if (ID == ID_BCARD) {
  2211.               CardInfo = (CARDINFO *) WinQueryWindowULong(hwndDlg, 0);
  2212.               // turn forward a page
  2213.               PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
  2214.                                          MPFROMLONG(CardInfo->CardId),
  2215.                                          MPFROM2SHORT(BKA_NEXT, 0));
  2216.               WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
  2217.             }
  2218.             else  {
  2219.               index = (ULONG) WinQueryWindowULong(hwndDlg, 0);
  2220.  
  2221.               // find out which card the gesture was done on
  2222.               WinMapWindowPoints(HWND_DESKTOP, hwndDlg, &(recodata->ptlHotSpot), (LONG)1);
  2223.               WinQueryWindowRect(hwndDlg, &rect);
  2224.               if (((rect.yTop - rect.yBottom) / 2) > recodata->ptlHotSpot.y) {
  2225.                 // turn forward a page
  2226.                 PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
  2227.                                            MPFROMLONG(Names[index+1].CardId),
  2228.                                            MPFROM2SHORT(BKA_NEXT, 0));
  2229.                 WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
  2230.               }
  2231.               else {
  2232.                 // turn forward a page
  2233.                 PageID = (ULONG)WinSendMsg(hwndNB, BKM_QUERYPAGEID,
  2234.                                            MPFROMLONG(Names[index].CardId),
  2235.                                            MPFROM2SHORT(BKA_NEXT, 0));
  2236.                 WinSendMsg(hwndNB, BKM_TURNTOPAGE, MPFROMLONG(PageID), 0L);
  2237.               }
  2238.             }
  2239.         }
  2240. }
  2241.  
  2242.  
  2243. MRESULT EXPENTRY NoteBookSubWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  2244. {
  2245.    ULONG ID;
  2246.  
  2247.     switch (msg) {
  2248.      case WM_RECO:
  2249.        WinPostMsg(hwndClient, WM_MY_RECO, (MPARAM)hwnd, mp2);
  2250.      return (MRESULT)TRUE;
  2251.    } // end switch
  2252.    ID = WinQueryWindowUShort(hwnd, QWS_ID);
  2253.    if (ID > ID_BCARD2)
  2254.      return((*TwoCardSubProc[ID-ID_LOGO1])(hwnd,msg,mp1,mp2));
  2255.    else if (ID > ID_INDEX)
  2256.      return((*IndexSubProc[ID-ID_CONTAINER])(hwnd,msg,mp1,mp2));
  2257.    else if (ID > ID_WELCOME)
  2258.      return((*WelcomeSubProc[ID-ID_IBMBMP])(hwnd,msg,mp1,mp2));
  2259.    else if (ID > ID_BCARD)
  2260.      return((*CardSubProc[ID-ID_LOGO])(hwnd,msg,mp1,mp2));
  2261.    else
  2262.      return((*NBSubProc)(hwnd,msg,mp1,mp2));
  2263. }
  2264.  
  2265. MRESULT EXPENTRY SketchDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
  2266. {
  2267.   static CARDINFO *CardInfo;
  2268.          HWND hwndOwner;
  2269.          CHAR name[80];
  2270.  
  2271.   switch (message)
  2272.   {
  2273.     case WM_INITDLG:
  2274.       CardInfo = (CARDINFO *)mp2;
  2275.  
  2276.       // grab the name for the title
  2277.       if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
  2278.         sprintf(name,"Clip-a-Sketch: %s %s. %s", CardInfo->FName, CardInfo->Initial,
  2279.                 CardInfo->LName);
  2280.       else
  2281.         sprintf(name,"Clip-a-Sketch: %s %s", CardInfo->FName, CardInfo->LName);
  2282.       WinSetWindowText(hwnd, name);
  2283.  
  2284.       WinSendMsg(WinWindowFromID(hwnd, ID_SKETCH), SKM_SET_CTL_INK_COLOR,
  2285.                  MPFROMSHORT(CLR_BLUE), 0L);
  2286.       ReadAndDisplaySketch(hwnd, CardInfo->RecId);
  2287.       WinSetFocus(HWND_DESKTOP, hwnd);
  2288.     return (MRESULT)TRUE;
  2289.  
  2290.    case  WM_CONTROL:
  2291.     switch (HIUSHORT(mp1))
  2292.     {
  2293.         // add the stroke to the controls 'data base'
  2294.         case SKN_STROKE_ADD:
  2295.         return 0L;
  2296.  
  2297.         // clear entire control
  2298.         case SKN_CONTROL_CLEARED:
  2299.         return 0L;
  2300.  
  2301.         // undo last stroke
  2302.         case SKN_STROKE_UNDO:
  2303.         return 0L;
  2304.  
  2305.         default:
  2306.         break;
  2307.     }
  2308.     return (MRESULT)TRUE ;
  2309.  
  2310.    case WM_COMMAND:
  2311.     switch (LOUSHORT(mp1))
  2312.     {
  2313.        case DID_OK:
  2314.          SaveSketch(hwnd, CardInfo->RecId);
  2315.          WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  2316.        break;
  2317.  
  2318.        case DID_CANCEL:
  2319.          WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  2320.        break;
  2321.  
  2322.        case ID_CLEAR:
  2323.          WinSendMsg(WinWindowFromID(hwnd, ID_SKETCH), SKM_DELETE_ALL_STROKES, 0L, 0L);
  2324.        break;
  2325.  
  2326.        case ID_UNDO:
  2327.          WinSendMsg(WinWindowFromID(hwnd, ID_SKETCH), SKM_UNDO_LAST_STROKE, 0L, 0L);
  2328.        break;
  2329.  
  2330.        default:
  2331.        return WinDefWindowProc(hwnd, message, mp1, mp2);
  2332.     }
  2333.     break;
  2334.  
  2335.     case WM_CLOSE:
  2336.       WinSetFocus(HWND_DESKTOP, hwndClient);
  2337.       WinDismissDlg(hwnd, TRUE);
  2338.     return (MRESULT) TRUE;
  2339.  
  2340.     default:
  2341.       return(WinDefDlgProc(hwnd,message,mp1,mp2));
  2342.   }
  2343.   return(0L);
  2344. }
  2345.  
  2346. USHORT SaveSketch(HWND hwndDlg, CHAR *RecId)
  2347. {
  2348.   APIRET rc;                                  /* return code                */
  2349.  
  2350.   ULONG             ulStrokeCount;              /* Total Strokes in signat  */
  2351.   ULONG             ulSaveIndex;
  2352.   ULONG             ulSignatureSize;
  2353.   CHAR              filename[45];
  2354.   HFILE             hf;                    /* Address of file handle                 */
  2355.   ULONG             ulBytesRead;
  2356.   ULONG             ulBytesWritten;
  2357.   ULONG             ulAction;
  2358.   PSKETCHSTROKEDEF pStrokeData = NULL;
  2359.   ULONG            ulNewPtr;              /* file pointer                           */
  2360.   ULONG     *ulEachStrokeLength;           /* array of stroke lengths          */
  2361.  
  2362.  
  2363.   sprintf(filename, "%s\\%s.skt", BookPath, RecId);
  2364.   /****************************************************/
  2365.   /* Get the total count of strokes in the signature. */
  2366.   /****************************************************/
  2367.   ulStrokeCount =
  2368.   (ULONG) WinSendMsg(WinWindowFromID( hwndDlg, ID_SKETCH),
  2369.                      SKM_QUERY_CTL_STROKE_COUNT,
  2370.                      NULL, NULL);
  2371.   // if ther is nothing in the sketch control erase the file
  2372.   if (ulStrokeCount < 1) {
  2373.     unlink(filename);
  2374.     return TRUE;
  2375.   }
  2376.  
  2377.   /**************************************************************************/
  2378.   /* Next, Open file to save Application Record, if first time - create it. */
  2379.   /**************************************************************************/
  2380.   rc =  DosOpen(filename,
  2381.               &hf,
  2382.               &ulAction,
  2383.               0,
  2384.               FILE_NORMAL,
  2385.                        FILE_OPEN | FILE_CREATE,
  2386.                        (ULONG)OPEN_ACCESS_READWRITE |
  2387.                        OPEN_SHARE_DENYREADWRITE |
  2388.                        OPEN_FLAGS_FAIL_ON_ERROR,
  2389.                        (PEAOP2)NULL);
  2390.  
  2391.   if (rc)         /* Error opening the file                                  */
  2392.     {
  2393.        DosBeep(500,200);
  2394.        return FALSE;
  2395.     }
  2396.  
  2397.  
  2398.   ulSignatureSize = ulStrokeCount * sizeof(ULONG);  /* bytes in file     */
  2399.  
  2400.   /*******************************************************/
  2401.   /* Malloc enough to save the lengths of each stroke.   */
  2402.   /*******************************************************/
  2403.   ulEachStrokeLength = (ULONG *) calloc(ulStrokeCount, sizeof(ULONG) );
  2404.  
  2405.  
  2406.   /*************************************************************/
  2407.   /* First stroke to the last stroke -                         */
  2408.   /* Save each strokes' length in the array which was malloced */
  2409.   /*************************************************************/
  2410.   for (ulSaveIndex = 0; ulSaveIndex < ulStrokeCount; ulSaveIndex++)
  2411.     {
  2412.  
  2413.       ulEachStrokeLength[ulSaveIndex] =
  2414.       (ULONG) WinSendMsg(WinWindowFromID( hwndDlg, ID_SKETCH),
  2415.                          SKM_QUERY_STROKE_LENGTH,
  2416.                          MPFROMLONG(ulSaveIndex + 1), /* actual stroke number */
  2417.                          NULL);
  2418.       ulSignatureSize += ulEachStrokeLength[ulSaveIndex];
  2419.     }
  2420.  
  2421.  
  2422.   /************************************************************************/
  2423.   /* Write HEADER containing Stroke count and Sketch size. */
  2424.   /************************************************************************/
  2425.   DosWrite(hf,
  2426.            &ulSignatureSize,
  2427.            sizeof(ULONG),
  2428.            &ulBytesWritten);
  2429.  
  2430.   DosWrite(hf,
  2431.            &ulStrokeCount,
  2432.            sizeof(ULONG),
  2433.            &ulBytesWritten);
  2434.  
  2435.   if ( ulBytesWritten != (sizeof(ULONG)) )
  2436.     {
  2437.       DosBeep(500,200);
  2438.       free(ulEachStrokeLength);
  2439.       DosClose(hf);
  2440.       return(FALSE);
  2441.     }
  2442.  
  2443.  
  2444.   /*******************************************************/
  2445.   /* Write ALL of the stroke's lengths to the file.      */
  2446.   /*******************************************************/
  2447.   DosWrite(hf,
  2448.            ulEachStrokeLength,
  2449.            sizeof(ULONG) * ulStrokeCount,
  2450.            &ulBytesWritten);
  2451.  
  2452.   if ( ulBytesWritten != ( sizeof(ULONG) * ulStrokeCount) )
  2453.     {
  2454.  
  2455.       DosBeep(200,500);
  2456.       free(ulEachStrokeLength);
  2457.       DosClose(hf);
  2458.       return(FALSE);
  2459.     }
  2460.  
  2461.  
  2462.  
  2463.   /**************************************/
  2464.   /* First stroke to the last stroke -  */
  2465.   /* Write each stroke to the file.     */
  2466.   /**************************************/
  2467.   for (ulSaveIndex = 0; ulSaveIndex < ulStrokeCount; ulSaveIndex++)
  2468.     {
  2469.       /*******************************************************/
  2470.       /* Allocate a buffer (non-shared) based on that size.  */
  2471.       /*******************************************************/
  2472.       pStrokeData = malloc(ulEachStrokeLength[ulSaveIndex]);
  2473.       if (!pStrokeData)
  2474.         {
  2475.          DosBeep(500,200);
  2476.          free(ulEachStrokeLength);
  2477.          DosClose(hf);
  2478.          return(FALSE);
  2479.         }
  2480.  
  2481.       /*******************************/
  2482.       /* Get the Stroke information. */
  2483.       /*******************************/
  2484.       WinSendMsg(WinWindowFromID( hwndDlg, ID_SKETCH),
  2485.                  SKM_QUERY_STROKE_DATA,
  2486.                  MPFROMLONG(ulSaveIndex + 1), /* actual stroke number */
  2487.                  MPFROMP(pStrokeData) );
  2488.  
  2489.       /**********************************/
  2490.       /* Write the Stroke to file.      */
  2491.       /**********************************/
  2492.       DosWrite(hf,
  2493.                pStrokeData,
  2494.                ulEachStrokeLength[ulSaveIndex],
  2495.                &ulBytesWritten);
  2496.  
  2497.       if ( ulBytesWritten != ulEachStrokeLength[ulSaveIndex])
  2498.         {
  2499.           DosBeep(500,200);
  2500.           free(ulEachStrokeLength);
  2501.           free(pStrokeData);
  2502.           DosClose(hf);
  2503.           return(FALSE);
  2504.         }
  2505.  
  2506.       free(pStrokeData);
  2507.  
  2508.     }
  2509.     DosClose(hf);
  2510.     free(ulEachStrokeLength);
  2511.  
  2512.  
  2513.   return TRUE;
  2514. } /* SaveApp */
  2515.  
  2516. VOID SaveMailFile(CHAR *txt)
  2517. {
  2518.    CHAR  filename[45];
  2519.    LONG  pos=0;
  2520.    HFILE hf;                    /* Address of file handle                 */
  2521.    ULONG ulBytesWritten;
  2522.    ULONG ulAction;
  2523.    APIRET rc;                                  /* return code                */
  2524.  
  2525.    sprintf(filename, "%s\\penmail.txt", BookPath);
  2526.    rc =  DosOpen(filename,
  2527.               &hf,
  2528.               &ulAction,
  2529.               0,
  2530.               FILE_NORMAL,
  2531.                        FILE_OPEN | FILE_CREATE,
  2532.                        (ULONG)OPEN_ACCESS_READWRITE |
  2533.                        OPEN_SHARE_DENYREADWRITE |
  2534.                        OPEN_FLAGS_FAIL_ON_ERROR,
  2535.                        (PEAOP2)NULL);
  2536.  
  2537.   if (rc)         /* Error opening the file                                  */
  2538.     DosBeep(500,200);
  2539.  
  2540.   lseek(hf, 0L, SEEK_SET);
  2541.  
  2542.   DosWrite(hf,
  2543.            txt,
  2544.            strlen(txt),
  2545.            &ulBytesWritten);
  2546.  
  2547.   if ( ulBytesWritten != ( strlen(txt)) )
  2548.     {
  2549.  
  2550.       DosBeep(200,500);
  2551.       DosClose(hf);
  2552.     }
  2553.  
  2554.     /* force and End of File */
  2555.     pos = tell(hf);
  2556.     chsize(hf, pos);
  2557.  
  2558.     DosClose(hf);
  2559. } /* SaveApp */
  2560.  
  2561. USHORT ReadAndDisplaySketch(HWND hwndDlg, CHAR *RecId)
  2562. {
  2563.  
  2564.   ULONG        ulStrokeCount;             /* Total Strokes in signat  */
  2565.   ULONG        ulStrokeIndex;             /* stroke indexer                  */
  2566.   BOOL         rc;
  2567.   ULONG        ulSignatureSize;
  2568.   HFILE        hf;                    /* Address of file handle                 */
  2569.   ULONG        ulBytesRead;
  2570.   ULONG        ulBytesWritten;
  2571.   ULONG        ulAction;
  2572.   PSKETCHSTROKEDEF pStrokeData = NULL;
  2573.   CHAR         filename[45];
  2574.   ULONG        *ulEachStrokeLength;           /* array of stroke lengths  */
  2575.  
  2576.  
  2577.  
  2578.   sprintf(filename, "%s\\%s.skt", BookPath, RecId);
  2579.   rc =  DosOpen(filename,
  2580.               &hf,
  2581.               &ulAction,
  2582.               0,
  2583.               FILE_NORMAL,
  2584.                        FILE_OPEN,
  2585.                        (ULONG)OPEN_ACCESS_READWRITE |
  2586.                        OPEN_SHARE_DENYREADWRITE |
  2587.                        OPEN_FLAGS_FAIL_ON_ERROR,
  2588.                        (PEAOP2)NULL);
  2589.  
  2590.   if (rc)  // error or none exists
  2591.     {
  2592.        return FALSE;
  2593.     }
  2594.  
  2595.   DosRead(hf, &ulSignatureSize, sizeof(ULONG), &ulBytesRead);
  2596.   DosRead(hf, &ulStrokeCount, sizeof(ULONG), &ulBytesRead);
  2597.   if (ulBytesRead != sizeof(ULONG) ) {
  2598.     DosBeep(500,200);
  2599.     DosClose(hf);
  2600.     return FALSE;
  2601.   }
  2602.  
  2603.   /*********************************************************/
  2604.   /* Malloc enough to retrieve the lengths of each stroke. */
  2605.   /*********************************************************/
  2606.   ulEachStrokeLength = (ULONG *) calloc(ulStrokeCount, sizeof(ULONG) );
  2607.  
  2608.  
  2609.   /**************************************************/
  2610.   /* Read All stroke lengths into array of lengths. */
  2611.   /**************************************************/
  2612.   DosRead(hf, (VOID *) ulEachStrokeLength, (sizeof(ULONG) * ulStrokeCount), &ulBytesRead);
  2613.   if ( ulBytesRead != (sizeof(ULONG) * ulStrokeCount) )
  2614.     {
  2615.       DosBeep(500,200);
  2616.       DosClose(hf);
  2617.       free(ulEachStrokeLength);
  2618.       return(FALSE);
  2619.     }
  2620.  
  2621.  
  2622.   /**************************************/
  2623.   /* First stroke to the last stroke -  */
  2624.   /* Read each stroke from the file.    */
  2625.   /**************************************/
  2626.   for (ulStrokeIndex = 0; ulStrokeIndex < ulStrokeCount; ulStrokeIndex++)
  2627.     {
  2628.  
  2629.       /*******************************************************/
  2630.       /* Allocate a buffer (non-shared) based on that size.  */
  2631.       /*******************************************************/
  2632.       pStrokeData = malloc(ulEachStrokeLength[ulStrokeIndex]);
  2633.       if (!pStrokeData)
  2634.         {
  2635.           DosBeep(500,200);
  2636.           DosClose(hf);
  2637.           free(ulEachStrokeLength);
  2638.           return(FALSE);
  2639.         }
  2640.  
  2641.       memset(pStrokeData , '\0',ulEachStrokeLength[ulStrokeIndex]); /* Zap, Zap, Zap */
  2642.       /**************************************************/
  2643.       /* Read the stroke from the file into the buffer. */
  2644.       /**************************************************/
  2645.       DosRead(hf,
  2646.               pStrokeData,
  2647.               ulEachStrokeLength[ulStrokeIndex],
  2648.               &ulBytesRead);
  2649.  
  2650.       /**********************************************/
  2651.       /* The following code is necessary for Stroke */
  2652.       /* Data pointer fix ups after each read.      */
  2653.       /**********************************************/
  2654.       pStrokeData->pStroke = (PSTROKEDATA)    ( (PBYTE) pStrokeData + sizeof( SKETCHSTROKEDEF ));
  2655.       pStrokeData->pStroke->pXY  = (PPOINTL)  ( (PBYTE) pStrokeData + sizeof( SKETCHSTROKEDEF ) + sizeof( STROKEDATA ));
  2656.  
  2657.  
  2658.       if (pStrokeData->pStroke->pAuxInfo)
  2659.         {
  2660.           pStrokeData->pStroke->pAuxInfo = (PAUXDATAINFO)
  2661.               ( (PBYTE)  pStrokeData->pStroke->pXY
  2662.               + pStrokeData->pStroke->ulNumPoints * sizeof( POINTL ));
  2663.         }
  2664.  
  2665.  
  2666.       if (pStrokeData->pStroke->pAuxData)
  2667.         {
  2668.           pStrokeData->pStroke->pAuxData = (PAUXSTROKEDATA)
  2669.  
  2670.           ( (PBYTE)  pStrokeData->pStroke->pAuxInfo
  2671.             + sizeof( AUXDATAINFO )
  2672.             + sizeof( AUXDATADESC )
  2673.             * ( pStrokeData->pStroke->pAuxInfo->ulNumElements - 1 )
  2674.             + pStrokeData->pStroke->ulNumPoints
  2675.             * pStrokeData->pStroke->pAuxInfo->ulAuxSize);
  2676.         }
  2677.  
  2678.  
  2679.  
  2680.       if ( ulBytesRead != ulEachStrokeLength[ulStrokeIndex])
  2681.         {
  2682.           DosBeep(500,200);
  2683.           free(ulEachStrokeLength);
  2684.           free(pStrokeData);
  2685.           DosClose(hf);
  2686.           return(FALSE);
  2687.         }
  2688.  
  2689.       /*******************************************/
  2690.       /* Put the Stroke into the Sketch Control. */
  2691.       /*******************************************/
  2692.       rc = (BOOL)WinSendMsg( WinWindowFromID( hwndDlg, ID_SKETCH),
  2693.                              SKM_ADD_STROKE,
  2694.                              NULL,
  2695.                              MPFROMP(pStrokeData) );
  2696.  
  2697.  
  2698.       if (rc == FALSE)
  2699.         {
  2700.           DosBeep(500,200);
  2701.           free(ulEachStrokeLength);
  2702.           free(pStrokeData);
  2703.           DosClose(hf);
  2704.           return(FALSE);
  2705.         }
  2706.  
  2707.  
  2708.  
  2709.       free(pStrokeData);
  2710.     } /* end for loop - completed reading all strokes */
  2711.  
  2712.   /**************************************************/
  2713.   /* Free the array of stroke lengths.              */
  2714.   /**************************************************/
  2715.   free(ulEachStrokeLength);
  2716.   DosClose(hf);
  2717.  
  2718.   return TRUE;
  2719.  
  2720. } /* ReadandDisplaySignature */
  2721.  
  2722.  
  2723. MRESULT EXPENTRY PagerDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
  2724. {
  2725.   static CARDINFO *CardInfo;
  2726.   static BOOL     Paging=FALSE;
  2727.          HWND hwndOwner;
  2728.          CHAR name[80];
  2729.          SHORT Rows, Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX;
  2730.          POINTL     points;
  2731.          ULONG      ulWindowStyle=WS_GROUP | WS_TABSTOP | WS_VISIBLE | HX_3DBORDER;
  2732.   static PDDESTRUCT pddeData;
  2733.  
  2734.  
  2735.   switch (message)
  2736.   {
  2737.     case WM_INITDLG:
  2738.       CardInfo = (CARDINFO *)mp2;
  2739.  
  2740.       // grab the name for the title
  2741.       if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
  2742.         sprintf(name,"Call-a-Pager: %s %s. %s", CardInfo->FName, CardInfo->Initial,
  2743.                 CardInfo->LName);
  2744.       else
  2745.         sprintf(name,"Call-a-Pager: %s %s", CardInfo->FName, CardInfo->LName);
  2746.       WinSetWindowText(hwnd, name);
  2747.  
  2748.       points.y = 20;
  2749.       points.x = 3;
  2750.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  2751.  
  2752.       // find optimal size for handwriting comb
  2753.       Cols = 11;
  2754.       Rows = 4;
  2755.       CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
  2756.       CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
  2757.       BaseLineDY = CharBoxDY / 3;
  2758.       ControlDY = (Rows * (CharBoxDY + BaseLineDY)) + BaseLineDY;
  2759.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  2760.  
  2761.       WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  2762.                         points.x, points.y, ControlDX, ControlDY,
  2763.                         hwnd, HWND_TOP, ID_HWX_PAGERTXT, NULL, NULL );
  2764.  
  2765.       WinShowWindow(WinWindowFromID(hwnd, ID_SRVPAGE), FALSE);
  2766.       WinShowWindow(WinWindowFromID(hwnd, ID_PAGEING), FALSE);
  2767.  
  2768.       WinSetFocus(HWND_DESKTOP, hwnd);
  2769.  
  2770.     return (MRESULT)TRUE;
  2771.  
  2772.    case  WM_CONTROL:
  2773.     switch (HIUSHORT(mp1))
  2774.     {
  2775.         default:
  2776.           return(WinDefDlgProc(hwnd,message,mp1,mp2));
  2777.     }
  2778.     return (MRESULT)TRUE ;
  2779.  
  2780.    case WM_COMMAND:
  2781.     switch (LOUSHORT(mp1))
  2782.     {
  2783.        case DID_OK:
  2784.        {
  2785.          CONVCONTEXT Context;
  2786.          CHAR  txt[41], app[7]="SkySrv", name[7]="System";
  2787.  
  2788.          WinQueryDlgItemText(hwnd, ID_HWX_PAGERTXT, 40, txt);
  2789.          // no text so dont send anything
  2790.          if (txt[0] == 0) {
  2791.            WinMessageBox ( HWND_DESKTOP, hwndNB,
  2792.                           "There is no text to send. The Pager will not be called.", "Contact/2", 0,
  2793.                            MB_OK | MB_INFORMATION | MB_SYSTEMMODAL);
  2794.            break;
  2795.          }
  2796.          // show that page is being que'd
  2797.          WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
  2798.          WinShowWindow(WinWindowFromID(hwnd, ID_SRVPAGE), TRUE);
  2799.  
  2800.          DosSleep(500);
  2801.  
  2802.          Context.cb = sizeof(CONVCONTEXT);
  2803.          Context.fsContext = DDECTXT_CASESENSITIVE;
  2804.          Context.idCountry = DDE_COUNTRY;
  2805.          Context.usCodepage = DDE_CODEPAGE;
  2806.          Context.usLangID = 0L;
  2807.          Context.usSubLangID = 0L;
  2808.  
  2809.          // app is SkySrv topic is System
  2810.          // send the page message
  2811.          WinDdeInitiate(hwnd, app, name, &Context);
  2812.  
  2813.        }
  2814.        break;
  2815.  
  2816.        case DID_CANCEL:
  2817.          WinSetFocus(HWND_DESKTOP, hwnd);
  2818.          WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  2819.        break;
  2820.  
  2821.        default:
  2822.        return WinDefWindowProc(hwnd, message, mp1, mp2);
  2823.     }
  2824.     break;
  2825.  
  2826.     case WM_DDE_INITIATEACK:
  2827.     {
  2828.       CHAR  txt[41], msg[70];
  2829.       PID   DestPID;
  2830.       TID   DestTID;
  2831.       PDDEINIT pData;
  2832.  
  2833.       pData = (PDDEINIT)mp2;
  2834.       if ((pData != NULL) && (strcmp(pData->pszAppName, "SkySrv") == 0)) {
  2835.       DosAllocSharedMem((PPVOID)&pddeData, NULL, sizeof(DDESTRUCT)+70,
  2836.                         PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE |
  2837.                         OBJ_GIVEABLE | OBJ_GETTABLE );
  2838.       Paging = TRUE;
  2839.  
  2840.       pddeData->cbData = sizeof(DDESTRUCT)+70;
  2841.       pddeData->fsStatus = DDE_FACKREQ;
  2842.       pddeData->usFormat = DDEFMT_TEXT;
  2843.       pddeData->offszItemName = sizeof(DDESTRUCT);
  2844.       // there is no item name
  2845.       strcpy((BYTE *)pddeData + pddeData->offszItemName, "");
  2846.       // of set to begining of data
  2847.       pddeData->offabData = sizeof(DDESTRUCT)+1;
  2848.  
  2849.       // get data, from handwriting pad
  2850.       WinQueryDlgItemText(hwnd, ID_HWX_PAGERTXT, 40, txt);
  2851.       sprintf(msg, "[SndMsg('%s',0,'%s')]", CardInfo->PagerID, txt);
  2852.       strcpy((BYTE *)pddeData+pddeData->offszItemName+1, msg);
  2853.  
  2854.       // give the data to the server app.
  2855.       WinQueryWindowProcess((HWND)mp1, &DestPID, &DestTID );
  2856.       if( !DosGiveSharedMem(&pddeData, DestPID, PAG_WRITE )) {
  2857.         WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
  2858.         DosFreeMem(pData);
  2859.         WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  2860.         break;
  2861.       }
  2862.  
  2863.       // app is SkySrv topic is System
  2864.       WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_EXECUTE, pddeData, DDEPM_RETRY);
  2865.       }
  2866.       DosFreeMem(pData);
  2867.     }
  2868.     break;
  2869.  
  2870.     case WM_DDE_ACK:
  2871.       // show if sent or not...
  2872.       WinShowWindow(WinWindowFromID(hwnd, ID_PAGEING), TRUE);
  2873.  
  2874.       DosSleep(1200);
  2875.       WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
  2876.     break;
  2877.  
  2878.     case WM_DDE_TERMINATE:
  2879.       DosFreeMem(pddeData);
  2880.       Paging = FALSE;
  2881.       // now shut down the dialog box
  2882.       WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  2883.     break;
  2884.  
  2885.     case WM_CLOSE:
  2886.       if (Paging == TRUE) {
  2887.         WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
  2888.         DosFreeMem(pddeData);
  2889.         Paging = FALSE;
  2890.       }
  2891.       WinDismissDlg(hwnd, TRUE);
  2892.     return (MRESULT) TRUE;
  2893.  
  2894.     default:
  2895.       return(WinDefDlgProc(hwnd,message,mp1,mp2));
  2896.   }
  2897.   return(0L);
  2898. }
  2899.  
  2900.  
  2901. MRESULT EXPENTRY MailDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
  2902. {
  2903.   static CARDINFO *CardInfo;
  2904.   static BOOL     Mailing=FALSE;
  2905.   static USHORT  Step;
  2906.          HWND hwndOwner;
  2907.          CHAR name[84];
  2908.          SHORT Rows, Cols, CharBoxDX, CharBoxDY, BaseLineDY, ControlDY, ControlDX;
  2909.          POINTL     points;
  2910.          ULONG      ulWindowStyle=WS_GROUP | WS_TABSTOP | WS_VISIBLE | HX_3DBORDER;
  2911.   static PDDESTRUCT pddeData;
  2912.  
  2913.  
  2914.   switch (message)
  2915.   {
  2916.     case WM_INITDLG:
  2917.       CardInfo = (CARDINFO *)mp2;
  2918.  
  2919.       // grab the name for the title
  2920.       if (CardInfo->Initial != NULL && CardInfo->Initial[0] != 0)
  2921.         sprintf(name,"Send cc: Mail to %s %s. %s", CardInfo->FName, CardInfo->Initial,
  2922.                 CardInfo->LName);
  2923.       else
  2924.         sprintf(name,"Send cc: Mail to %s %s", CardInfo->FName, CardInfo->LName);
  2925.       WinSetWindowText(hwnd, name);
  2926.  
  2927.       points.y = 20;
  2928.       points.x = 5;
  2929.       WinMapDlgPoints(hwnd, &points, 1L, TRUE);
  2930.  
  2931.       // find optimal size for handwriting comb
  2932.       Cols = 13;
  2933.       Rows = 6;
  2934.       CharBoxDX = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DX);
  2935.       CharBoxDY = WrtQuerySysValue(HWND_DESKTOP, PPMSV_CHARACTER_BOX_DY);
  2936.       BaseLineDY = CharBoxDY / 3;
  2937.       ControlDY = (Rows * (CharBoxDY + BaseLineDY)) + BaseLineDY;
  2938.       ControlDX = (Cols * CharBoxDX) + (CharBoxDX / 2);
  2939.  
  2940.       WinCreateWindow ( hwnd, WC_HWXENTRY, "", ulWindowStyle,
  2941.                         points.x, points.y, ControlDX, ControlDY,
  2942.                         hwnd, HWND_TOP, ID_HWX_MAILTXT, NULL, NULL );
  2943.  
  2944.       WinShowWindow(WinWindowFromID(hwnd, ID_SRVMAIL), FALSE);
  2945.       WinShowWindow(WinWindowFromID(hwnd, ID_MAILING), FALSE);
  2946.  
  2947.       WinSetFocus(HWND_DESKTOP, hwnd);
  2948.  
  2949.     return (MRESULT)TRUE;
  2950.  
  2951.    case  WM_CONTROL:
  2952.     switch (HIUSHORT(mp1))
  2953.     {
  2954.         default:
  2955.           return(WinDefDlgProc(hwnd,message,mp1,mp2));
  2956.     }
  2957.     return (MRESULT)TRUE ;
  2958.  
  2959.    case WM_COMMAND:
  2960.     switch (LOUSHORT(mp1))
  2961.     {
  2962.        case DID_OK:
  2963.        {
  2964.          CONVCONTEXT Context;
  2965.          CHAR  txt[66], app[6]="wmail", name[9]="SendMail";
  2966.  
  2967.          WinQueryDlgItemText(hwnd, ID_HWX_MAILTXT, sizeof(txt), txt);
  2968.  
  2969.          // no text so dont send anything
  2970.          if (txt[0] == 0) {
  2971.            WinMessageBox ( HWND_DESKTOP, hwndNB,
  2972.                           "There is no text to send.", "Contact/2", 0,
  2973.                            MB_OK | MB_INFORMATION | MB_SYSTEMMODAL);
  2974.            break;
  2975.          }
  2976.          else { // save to a file
  2977.            WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
  2978.            // show that mail is being que'd
  2979.            WinShowWindow(WinWindowFromID(hwnd, ID_SRVMAIL), TRUE);
  2980.            SaveMailFile(txt);
  2981.          }
  2982.  
  2983.          Context.cb = sizeof(CONVCONTEXT);
  2984.          Context.fsContext = DDECTXT_CASESENSITIVE;
  2985.          Context.idCountry = DDE_COUNTRY;
  2986.          Context.usCodepage = DDE_CODEPAGE;
  2987.          Context.usLangID = 0L;
  2988.          Context.usSubLangID = 0L;
  2989.          Step = 0;
  2990.  
  2991.          // app is SkySrv topic is System
  2992.          // send the mail message
  2993.          WinDdeInitiate(hwnd, app, name, &Context);
  2994.  
  2995.        }
  2996.        break;
  2997.  
  2998.        case DID_CANCEL:
  2999.          WinSetFocus(HWND_DESKTOP, hwnd);
  3000.          WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  3001.        break;
  3002.  
  3003.        default:
  3004.        return WinDefWindowProc(hwnd, message, mp1, mp2);
  3005.     }
  3006.     break;
  3007.  
  3008.     case WM_DDE_INITIATEACK:
  3009.     {
  3010.       CHAR  msg[50];
  3011.       PID   DestPID;
  3012.       TID   DestTID;
  3013.       PDDEINIT pData;
  3014.  
  3015.       pData = (PDDEINIT)mp2;
  3016.       if ((pData != NULL) && (strcmp(pData->pszAppName, "wmail") == 0)) {
  3017.       DosAllocSharedMem((PPVOID)&pddeData, NULL, sizeof(DDESTRUCT)+70,
  3018.                         PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_TILE |
  3019.                         OBJ_GIVEABLE | OBJ_GETTABLE );
  3020.       Mailing = TRUE;
  3021.  
  3022.       pddeData->cbData = sizeof(DDESTRUCT)+70;
  3023.       pddeData->fsStatus = DDE_FACKREQ;
  3024.       pddeData->usFormat = DDEFMT_TEXT;
  3025.       pddeData->offszItemName = sizeof(DDESTRUCT);
  3026.       // there is no item name
  3027.       strcpy((BYTE *)pddeData + pddeData->offszItemName, "");
  3028.       // of set to begining of data
  3029.       pddeData->offabData = sizeof(DDESTRUCT)+1;
  3030.  
  3031.       strcpy(msg, "NewMessage");
  3032.       strcpy((BYTE *)pddeData+pddeData->offszItemName+1, msg);
  3033.  
  3034.       // give the data to the server app.
  3035.       WinQueryWindowProcess((HWND)mp1, &DestPID, &DestTID );
  3036.       if( !DosGiveSharedMem(&pddeData, DestPID, PAG_WRITE | PAG_READ)) {
  3037.         DosBeep(1000,500);
  3038.         WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
  3039.         DosFreeMem(pData);
  3040.         WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  3041.         return (MRESULT) TRUE;
  3042.       }
  3043.  
  3044.       Step++;
  3045.       // app is SkySrv topic is System
  3046.       WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_EXECUTE, pddeData, DDEPM_RETRY);
  3047.       }
  3048.       DosFreeMem(pData);
  3049.     }
  3050.     break;
  3051.  
  3052.     case WM_DDE_ACK:
  3053.     {
  3054.       PID   DestPID;
  3055.       TID   DestTID;
  3056.       CHAR  msg[50];
  3057.  
  3058.       if ( Step == 1) {
  3059.         WinSetPointer(HWND_DESKTOP,
  3060.                       WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
  3061.         sprintf(msg, "AttachFile %s\\penmail.txt", BookPath);
  3062.       }
  3063.       else if (Step == 2) {
  3064.         sprintf(msg, "To %s", CardInfo->MailUserId);
  3065.       }
  3066.       else if (Step == 3) {
  3067.         strcpy(msg, "Send");
  3068.         WinShowWindow(WinWindowFromID(hwnd, ID_MAILING), TRUE);
  3069.         WinSetPointer(HWND_DESKTOP,
  3070.                       WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE));
  3071.       }
  3072.       else {
  3073.         WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
  3074.         return (MRESULT) TRUE;
  3075.       }
  3076.  
  3077.       pddeData->fsStatus = DDE_FACKREQ;
  3078.       strcpy((BYTE *)pddeData+pddeData->offszItemName+1, msg);
  3079.  
  3080.       Step++;
  3081.       WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_EXECUTE, pddeData, DDEPM_RETRY);
  3082.     }
  3083.     break;
  3084.  
  3085.     case WM_DDE_TERMINATE:
  3086.       DosFreeMem(pddeData);
  3087.       Mailing = FALSE;
  3088.       // now shut down the dialog box
  3089.       WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  3090.     break;
  3091.  
  3092.     case WM_CLOSE:
  3093.       if (Mailing == TRUE) {
  3094.         WinDdePostMsg((HWND)mp1, hwnd, WM_DDE_TERMINATE, NULL, DDEPM_RETRY);
  3095.         Mailing = FALSE;
  3096.         DosFreeMem(pddeData);
  3097.       }
  3098.       WinDismissDlg(hwnd, TRUE);
  3099.     return (MRESULT) TRUE;
  3100.  
  3101.     default:
  3102.       return(WinDefDlgProc(hwnd,message,mp1,mp2));
  3103.   }
  3104.   return(0L);
  3105. }
  3106.  
  3107. BOOL Paint3dLines(HPS hps, PRECTL pRectl)
  3108. {                                              //
  3109.   POINTL p;                                    //
  3110.   POINTL pRt[4], pBot[4];
  3111.   RECTL  rClient;                              //
  3112.   SHORT  i;
  3113.                                                //
  3114.   rClient = *pRectl;                           // Get a copy of the rect
  3115.                                                //
  3116.                                                //
  3117.   GpiSetColor( hps, CLR_DARKGRAY);               // Color for right vert and bot horz
  3118.  
  3119.   // right side
  3120.   pRt[0].x =rClient.xRight+5;
  3121.   pRt[0].y =rClient.yTop-8;
  3122.   pRt[1].x =rClient.xRight+5;
  3123.   pRt[1].y =rClient.yBottom-6;
  3124.   pRt[2].x =rClient.xRight;
  3125.   pRt[2].y =rClient.yBottom;
  3126.   pRt[3].x =rClient.xRight;
  3127.   pRt[3].y =rClient.yTop-8;
  3128.  
  3129.   // bottom side
  3130.   pBot[0].x =rClient.xLeft+8;
  3131.   pBot[0].y =rClient.yBottom-6;
  3132.   pBot[1].x =rClient.xRight+5;
  3133.   pBot[1].y =rClient.yBottom-6;
  3134.   pBot[2].x =rClient.xRight;
  3135.   pBot[2].y =rClient.yBottom-1;
  3136.   pBot[3].x =rClient.xLeft+8;
  3137.   pBot[3].y =rClient.yBottom-1;
  3138.  
  3139.   GpiSetDrawingMode(hps, DM_DRAWANDRETAIN);
  3140.  
  3141.   GpiBeginPath(hps,1L);                      //
  3142.   GpiMove( hps, &pBot[3] );                  // Move
  3143.   GpiPolyLine(hps,4L ,&pBot[0]);             //
  3144.   GpiEndPath(hps);
  3145.   GpiFillPath(hps, 1L, FPATH_ALTERNATE);
  3146.  
  3147.   GpiBeginPath(hps,1L);                      //
  3148.   GpiMove( hps, &pRt[3] );                   // Move
  3149.   GpiPolyLine(hps,4L ,&pRt[0]);              //
  3150.   GpiEndPath(hps);
  3151.   GpiFillPath(hps, 1L, FPATH_ALTERNATE);
  3152.  
  3153.   GpiSetColor( hps, CLR_BLACK);              // Color for right vert and bot horz
  3154.   GpiSetLineWidth(hps, LINEWIDTH_THICK);
  3155.   p.x =rClient.xRight;
  3156.   p.y =rClient.yTop;
  3157.   GpiMove( hps, &p );                        // Move
  3158.   p.x =rClient.xRight;
  3159.   p.y =rClient.yBottom+1;
  3160.   GpiLine( hps, &p );                        // Draw it
  3161.   p.x =rClient.xLeft;
  3162.   p.y =rClient.yBottom+1;
  3163.   GpiLine( hps, &p );                        // Draw it
  3164.  
  3165.                                                //
  3166.   return( TRUE );                              //
  3167. }                                              //
  3168.  
  3169.  
  3170. VOID FindBmp(CARDINFO *Name, CARDREC *CardRec)
  3171. {
  3172.      // phone=1000, fax=0100, pager=0010, mail=0001
  3173.      ULONG flags=0x0000;
  3174.  
  3175.      if (Name->Phone[0] != 0)
  3176.        flags |= 0x1000;
  3177.      if (Name->Fax[0] != 0)
  3178.        flags |= 0x0100;
  3179.      if (Name->PagerID[0] != 0)
  3180.        flags |= 0x0010;
  3181.      if (Name->MailUserId[0] != 0)
  3182.        flags |= 0x0001;
  3183.  
  3184.      if (flags == 0x0001)
  3185.        CardRec->bitmap = hbmp0001;
  3186.      else if (flags == 0x0010)
  3187.        CardRec->bitmap = hbmp0010;
  3188.      else if (flags == 0x0011)
  3189.        CardRec->bitmap = hbmp0011;
  3190.      else if (flags == 0x0100)
  3191.        CardRec->bitmap = hbmp0100;
  3192.      else if (flags == 0x0101)
  3193.        CardRec->bitmap = hbmp0101;
  3194.      else if (flags == 0x0110)
  3195.        CardRec->bitmap = hbmp0110;
  3196.      else if (flags == 0x0111)
  3197.        CardRec->bitmap = hbmp0111;
  3198.      else if (flags == 0x1000)
  3199.        CardRec->bitmap = hbmp1000;
  3200.      else if (flags == 0x1001)
  3201.        CardRec->bitmap = hbmp1001;
  3202.      else if (flags == 0x1010)
  3203.        CardRec->bitmap |= hbmp1010;
  3204.      else if (flags == 0x1011)
  3205.        CardRec->bitmap = hbmp1011;
  3206.      else if (flags == 0x1100)
  3207.        CardRec->bitmap = hbmp1100;
  3208.      else if (flags == 0x1101)
  3209.        CardRec->bitmap = hbmp1101;
  3210.      else if (flags == 0x1110)
  3211.        CardRec->bitmap = hbmp1110;
  3212.      else if (flags == 0x1111)
  3213.        CardRec->bitmap = hbmp1111;
  3214.      else  // no method of communication 0x0000
  3215.        CardRec->bitmap = hbmp0000;
  3216. }
  3217.  
  3218. MRESULT EXPENTRY HelpDlgProc( HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2 )
  3219. {
  3220.  CHAR   *msg;
  3221.  CHAR   szFontName[23];
  3222.  ULONG  indx=CLR_RED;
  3223.  
  3224.   switch (message)
  3225.   {
  3226.     case WM_INITDLG:
  3227.       msg = (CHAR *)malloc(475);
  3228.       sprintf(msg, "%s %s %s", STRTXT1, STRTXT2, STRTXT3);
  3229.       WinSetDlgItemText(hwnd, ID_TEXT2, msg);
  3230.       free(msg);
  3231.  
  3232.       strcpy( szFontName, "10.Helvetica");
  3233.       WinSetPresParam( hwnd, PP_FONTNAMESIZE,
  3234.                       (LONG)strlen( szFontName ) + 1L,
  3235.                       (PVOID)szFontName );
  3236.  
  3237.       // set up different font and color for my name
  3238.       strcpy( szFontName, "12.Tms Rmn Bold Italic");
  3239.       WinSetPresParam( WinWindowFromID(hwnd, ID_TEXT4), PP_FONTNAMESIZE,
  3240.                       (LONG)strlen( szFontName ) + 1L,
  3241.                       (PVOID)szFontName );
  3242.       WinSetPresParam(WinWindowFromID(hwnd, ID_TEXT4), PP_FOREGROUNDCOLORINDEX, 4L, (PVOID) &indx);
  3243.  
  3244.       WinSetFocus(HWND_DESKTOP, hwnd);
  3245.     return (MRESULT)TRUE;
  3246.  
  3247.    case  WM_CONTROL:
  3248.     switch (HIUSHORT(mp1))
  3249.     {
  3250.         default:
  3251.           return(WinDefDlgProc(hwnd,message,mp1,mp2));
  3252.     }
  3253.     return (MRESULT)TRUE ;
  3254.  
  3255.    case WM_COMMAND:
  3256.     switch (LOUSHORT(mp1))
  3257.     {
  3258.        case DID_CANCEL:
  3259.          WinSetFocus(HWND_DESKTOP, hwnd);
  3260.          WinSendMsg(hwnd, WM_CLOSE, 0L, 0L);
  3261.        break;
  3262.  
  3263.        default:
  3264.        return WinDefWindowProc(hwnd, message, mp1, mp2);
  3265.     }
  3266.     break;
  3267.  
  3268.     case WM_CLOSE:
  3269.       WinDismissDlg(hwnd, TRUE);
  3270.     return (MRESULT) TRUE;
  3271.  
  3272.     default:
  3273.       return(WinDefDlgProc(hwnd,message,mp1,mp2));
  3274.   }
  3275.   return(0L);
  3276. }
  3277.