home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / bidi / arabic / style / sty_dlg.c < prev    next >
C/C++ Source or Header  |  1999-05-11  |  84KB  |  2,576 lines

  1. /**********************************************************************
  2. *
  3. *  File Name   : STY_DLG.C
  4. *
  5. *  Description : This module contains the Dialog Procedures for the user
  6. *                defined dialogs as well as any support code they need.
  7. *
  8. *  Concepts    : Dialog procedures for user defined dialogs,
  9. *                initialization of controls in the dialog boxs,
  10. *                use of presentation parameters.
  11. *                BIDI - Added: Bidirectional Language processing sample code.
  12. *
  13. *  API's       :  DosAllocMem             WinQueryFocus
  14. *                 DosFreeMem              WinQueryPointerPos
  15. *                 GpiQueryFonts           WinQueryPresParams
  16. *                 WinCreateWindow         WinQueryWindowText
  17. *                 WinDefDlgProc           WinQueryWindowUShort
  18. *                 WinDismissDlg           WinReleasePS
  19. *                 WinGetPS                WinRemovePresParams
  20. *                 WinLoadMenu             WinSendDlgItemMsg
  21. *                 WinLoadPointer          WinSendMsg
  22. *                 WinLoadString           WinSetDlgItemText
  23. *                 WinMapWindowPoints      WinSetPresParams
  24. *                 WinPopupMenu            WinWindowFromID
  25. *
  26. *  Copyright (C) 1992 IBM Corporation
  27. *
  28. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  29. *      sample code created by IBM Corporation. This sample code is not
  30. *      part of any standard or IBM product and is provided to you solely
  31. *      for  the purpose of assisting you in the development of your
  32. *      applications.  The code is provided "AS IS", without
  33. *      warranty of any kind.  IBM shall not be liable for any damages
  34. *      arising out of your use of the sample code, even if they have been
  35. *      advised of the possibility of such damages.                                                    *
  36. ************************************************************************/
  37.  
  38. /*  Include files, macros, defined constants, and externs              */
  39.  
  40. #define INCL_WINWINDOWMGR
  41. #define INCL_WINFRAMEMGR
  42. #define INCL_WINPOINTERS
  43. #define INCL_WININPUT
  44. #define INCL_WINLISTBOXES
  45. #define INCL_WINENTRYFIELDS
  46. #define INCL_WINSTDSPIN
  47. #define INCL_WINSTDBOOK
  48. #define INCL_WINMLE
  49. #define INCL_WINMENUS
  50. #define INCL_WINSTATICS
  51. #define INCL_WINSTDCNR
  52. #define INCL_WINSTDSLIDER
  53. #define INCL_WINSTDVALSET
  54. #define INCL_WINDIALOGS
  55. #define INCL_WINSYS
  56. #define INCL_WINCOUNTRY
  57. #define INCL_WINHOOKS
  58. #define INCL_GPILCIDS
  59. #define INCL_GPIBITMAPS
  60. #define INCL_DOSMEMMGR
  61. #define INCL_DOSNLS
  62.  
  63. #include <os2.h>
  64. #include <string.h>
  65. #include <stdlib.h>
  66.  
  67. #define  INCL_WINSTDDLGS
  68. #define  INCL_CATALOGSTRUCTS
  69. #include <pmbidi.h>
  70. #include "sty_main.h"
  71. #include "sty_dlg.h"
  72. #include "sty_xtrn.h"
  73. #include "sty_help.h"
  74.  
  75. typedef struct _USERRECORD
  76. {
  77.   RECORDCORE  recordCore;
  78. /*
  79.   CDATE       date;
  80.   CTIME       time;
  81.   PSZ         recordData;
  82. */
  83. //BIDI
  84.   PSZ         EnglishName;
  85.   PSZ         NationalName;
  86. } USERRECORD, *PUSERRECORD;
  87.  
  88. #define COLORNAMELEN    20
  89. #define NUMCOLORS       15  /* number of colors used in PP Demo */
  90. #define NUMSPINCOLORS   16  /* number of colors used in SPIN Demo */
  91. #define NUMFONTS         4  /* number of fonts used in PP Demo */
  92. #define FONTPOINTSIZE   80  /* point size to use in PP Demo */
  93. #define PPFONTPOINTSIZE  2              /* length of font point prefix */
  94.  
  95. #define TAB_WIDTH  120
  96. #define TAB_HEIGHT  30
  97.  
  98. /*  Global variables                                                   */
  99.                                         /* array of clr names          */
  100. static CHAR apszPresParamColor[NUMCOLORS][COLORNAMELEN];
  101. static PSZ *apszPresParamFont = NULL;
  102. static LONG lNumFonts;
  103. static CNRINFO cnrinfo;
  104. static ULONG ulCnrAttributes;
  105. static RECORDINSERT recordInsert;
  106. static PUSERRECORD pUserRecord, pStartRecord;
  107. static PFIELDINFO pFieldInfo, firstFieldInfo;
  108. static FIELDINFOINSERT fieldInfoInsert;
  109. static PFIELDINFOINSERT pFieldInfoInsert;
  110. static CHAR pszViewText[] = "Text for Text View.";
  111. static CHAR pszViewIcon[] = "Text for Icon View.";
  112. static CHAR pszViewName[] = "Text for Name View.";
  113. static CHAR pszTowerEnglish[64] = "Tower";
  114. static CHAR pszTowerNational[64];
  115. static CHAR pszWaterfallEnglish[64] = "Waterfall";
  116. static CHAR pszWaterfallNational[64];
  117. static CHAR pszGlobeEnglish[64] = "Globe";
  118. static CHAR pszGlobeNational[64];
  119. static CHAR pszKeyEnglish[64] = "Key";
  120. static CHAR pszKeyNational[64];
  121. static CHAR pszColumnText1English[64]= "Picture";
  122. static CHAR pszColumnText1National[64];
  123. static CHAR pszColumnText2[64];
  124. static CHAR pszColumnText3[64]= "English";
  125. static CHAR pszSampleData[] = "Sample Data";
  126. static CHAR pszCnrTitleEnglish[64] = "Sample Container";
  127. static CHAR pszCnrTitleNational[64];
  128.  
  129. /*
  130.  * Set up an array of colors in the same order as the stringtable
  131.  * constants
  132.  */
  133. static ULONG aulColor[NUMCOLORS-1] =
  134.               { CLR_BLUE, CLR_RED, CLR_PINK, CLR_GREEN, CLR_CYAN,
  135.                 CLR_YELLOW, CLR_DARKGRAY, CLR_DARKBLUE, CLR_DARKRED,
  136.                 CLR_DARKPINK, CLR_DARKGREEN, CLR_DARKCYAN, CLR_BROWN,
  137.                 CLR_PALEGRAY };
  138.  
  139. /*  Entry point declarations                                           */
  140.  
  141. MRESULT EXPENTRY ProdInfoDlgProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2);
  142. MRESULT EXPENTRY DemoDlgProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2);
  143. MRESULT EXPENTRY PresParamDemoDlgProc(HWND hwnd, USHORT msg, MPARAM mp1,
  144.                                       MPARAM mp2);
  145. BOOL InitializeValueSet(HWND hwnd);
  146. BOOL InitializeSpinButton(HWND hwnd);
  147. BOOL InitializeSlider(HWND hwnd);
  148. BOOL InitializeNoteBook(HWND hwnd);
  149. BOOL InitializeContainer(HWND hwnd);
  150. BOOL LoadListBox(HWND hwnd);
  151. BOOL InitPresParamDemoDlg(HWND hwnd);
  152. BOOL UpdatePresParamDemoDlg(HWND hwnd);
  153. VOID ShowDlgHelp(HWND hwnd);
  154. VOID SetSysMenu(HWND hwnd);
  155.  
  156.  
  157. /*********************************************************************
  158.  *  Name : ProdInfoDlgProc
  159.  *
  160.  *  Description : Processes all messages sent to the Product
  161.  *                Information dialog box.
  162.  *
  163.  *  Concepts : Called for each message sent to the Product
  164.  *             Information dialog box.  The Product
  165.  *             Information box only has a button control so
  166.  *             this routine only processes WM_COMMAND
  167.  *             messages.  Any WM_COMMAND posted must have come
  168.  *             from the Ok button so we dismiss the dialog
  169.  *             upon receiving it.
  170.  *
  171.  *  API's : WinDismissDlg
  172.  *          WinDefDlgProc
  173.  *
  174.  * Parameters   : hwnd - Window handle to which message is addressed
  175.  *                msg - Message type
  176.  *                mp1 - First message parameter
  177.  *                mp2 - Second message parameter
  178.  *
  179.  *  Returns : Dependent upon message sent
  180.  *
  181.  ****************************************************************/
  182. MRESULT EXPENTRY ProdInfoDlgProc( HWND hwnd, USHORT msg, MPARAM mp1,
  183.                                   MPARAM mp2)
  184. {
  185.    switch(msg)
  186.    {
  187.       case WM_COMMAND:
  188.          /*
  189.           * No matter what the command, close the dialog
  190.           */
  191.          WinDismissDlg(hwnd, TRUE);
  192.          break;
  193.  
  194.       case WM_HELP:
  195.          ShowDlgHelp(hwnd);
  196.          break;
  197.  
  198.       default:
  199.          return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  200.          break;
  201.    }
  202.    return (MRESULT)0;
  203. }           /* End of ProdInfolDlgProc()                               */
  204.  
  205.  
  206.  
  207. /* 4 records - first index form 0 to 3 *
  208.  * 3 fields  second index from 1 to 2  *
  209.  * field titles -     first index = 4L *
  210.  * container title    first index = 5L */
  211.  
  212. PSZ pszTexts[6][3] =
  213.  {
  214.     {pszTowerNational, pszTowerNational, pszTowerEnglish},
  215.     {pszWaterfallNational, pszWaterfallNational, pszWaterfallEnglish},
  216.     {pszGlobeNational, pszGlobeNational, pszGlobeEnglish},
  217.     {pszKeyNational, pszKeyNational, pszKeyEnglish},
  218.     {pszColumnText1National, pszColumnText2, pszColumnText3},
  219.     {pszCnrTitleNational}
  220.  };
  221.  
  222.  
  223.  
  224. /*********************************************************************
  225.  *  Name : DemoDlgProc
  226.  *
  227.  *  Description : Processes all messages sent to all Demo dialogs.
  228.  *
  229.  *  Concepts : Called for each message sent to a demo dialog box.
  230.  *             A switch statement branches to the routines to be
  231.  *             performed for each message processed.  Any messages
  232.  *             not specifically process are passed to the default
  233.  *             window procedure WinDefDlgProc().
  234.  *
  235.  *  API's : WinDismissDlg
  236.  *          WinLoadMenu
  237.  *          WinQueryPointerPos
  238.  *          WinMapWindowPoints
  239.  *          WinPopupMenu
  240.  *          WinSendDlgItemMsg
  241.  *          WinSetDlgItemText
  242.  *          WinDefDlgProc
  243.  *
  244.  * Parameters   : hwnd - Window handle to which message is addressed
  245.  *                msg - Message type
  246.  *                mp1 - First message parameter
  247.  *                mp2 - Second message parameter
  248.  *
  249.  *  Returns : Dependent upon message sent
  250.  *
  251.  ****************************************************************/
  252. MRESULT EXPENTRY DemoDlgProc( HWND hwnd, USHORT msg, MPARAM mp1,
  253.                               MPARAM mp2)
  254. {
  255.    CHAR      acBuffer[4];
  256.    CHAR      *cData;
  257.    PSHORT    psIdDlg;
  258. // int       rc;
  259.  
  260.    cnrinfo.pszCnrTitle = pszCnrTitleNational;
  261.    ulCnrAttributes = CA_CONTAINERTITLE | CA_TITLESEPARATOR;
  262.  
  263.    switch(msg)
  264.    {
  265.       case WM_INITDLG:
  266.  
  267.          SetSysMenu(hwnd);
  268.          psIdDlg = (PSHORT) mp2;
  269.  
  270.          switch(*psIdDlg)
  271.          {
  272.         /*
  273.          * The ShowDemoDlg() filled mp2 with a pointer to the id of
  274.          * the dialog template used to create the dialog box.
  275.          */
  276.             case IDD_LISTBOXDLG:
  277.             /*
  278.              * Load some text into the list boxes.  If any of the
  279.              * LoadListBox() routines fail, abort the dialog
  280.              */
  281.                if (!LoadListBox(WinWindowFromID(hwnd, IDC_LISTBOX1)) ||
  282.                    !LoadListBox(WinWindowFromID(hwnd, IDC_LISTBOX2)) ||
  283.                    !LoadListBox(WinWindowFromID(hwnd, IDC_MULTISELLISTBOX1)) ||
  284.                    !LoadListBox(WinWindowFromID(hwnd, IDC_MULTISELLISTBOX2)))
  285.                {
  286.                   WinDismissDlg(hwnd, FALSE);
  287.                }
  288.                break;
  289.  
  290.             case IDD_COMBOBOXDLG:
  291.             /*
  292.              * Load some text into the combo boxes.  If any of the
  293.              * LoadListBox() routines fail, abort the dialog
  294.              */
  295.                if (!LoadListBox(WinWindowFromID(hwnd, IDC_SIMPLE)) ||
  296.                    !LoadListBox(WinWindowFromID(hwnd, IDC_DROPDOWN)) ||
  297.                    !LoadListBox(WinWindowFromID(hwnd, IDC_DROPDOWNLIST)))
  298.                {
  299.                   WinDismissDlg(hwnd, FALSE);
  300.                }
  301.                break;
  302.  
  303.             case IDD_SPINBUTTONDLG:
  304.             /*
  305.              * Initialize the master and servant Spinbuttons.
  306.              * If the initialization routine fails, abort
  307.              * the dialog
  308.              */
  309.                if (!InitializeSpinButton(hwnd))
  310.                {
  311.                   WinDismissDlg(hwnd, FALSE);
  312.                }
  313.                break;
  314.  
  315.             case IDD_VALUESETDLG:
  316.             /*
  317.              * Initialize the Valueset control.
  318.              * If the initialization routine fails, abort
  319.              * the dialog
  320.              */
  321.                if (!InitializeValueSet(hwnd))
  322.                {
  323.                   WinDismissDlg(hwnd, FALSE);
  324.                }
  325.                break;
  326.  
  327.             case IDD_CONTAINERDLG:
  328.             /*
  329.              * Initialize the Container control.
  330.              * If the initialization routine fails, abort
  331.              * the dialog
  332.              */
  333.                cnrinfo.flWindowAttr = CV_ICON | ulCnrAttributes;
  334.                if (!InitializeContainer(hwnd))
  335.                {
  336.                   WinDismissDlg(hwnd, FALSE);
  337.                }
  338.                break;
  339.  
  340.             case IDD_NOTEBOOKDLG:
  341.             /*
  342.              * Initialize the Notebook control.
  343.              * If the initialization routine fails, abort
  344.              * the dialog
  345.              */
  346.                if (!InitializeNoteBook(hwnd))
  347.                {
  348.                   WinDismissDlg(hwnd, FALSE);
  349.                }
  350.                break;
  351.  
  352.             case IDD_SLIDERDLG:
  353.             /*
  354.              * Initialize the Slider control.
  355.              * If the initialization routine fails, abort
  356.              * the dialog
  357.              */
  358.                if (!InitializeSlider(hwnd))
  359.                {
  360.                   WinDismissDlg(hwnd, FALSE);
  361.                }
  362.                break;
  363.  
  364.             default:
  365.                break;
  366.          }
  367.          break;
  368.  
  369.       case WM_CONTROL:
  370.          /*
  371.           * Process the WM_CONTROL messages for the slider and valueset
  372.           * set controls.
  373.           */
  374.          switch(SHORT2FROMMP(mp1))
  375.          {
  376.             case CN_REALLOCPSZ:
  377.                return (MRESULT) TRUE;
  378.  
  379.             case CN_CONTEXTMENU:
  380.             {
  381.                POINTL point;
  382.                HWND hwndMenu;
  383.                HWND hwndContainer;
  384.                /*
  385.                 * If we receive a EN_CONTEXTMENU MESSAGE and if the
  386.                 * current dialog if the container dialog, display a
  387.                 * popup menu that allows the user to change the
  388.                 * container view.
  389.                 */
  390.                 hwndContainer = WinWindowFromID(hwnd,IDC_CONTAINER);
  391.  
  392.                 hwndMenu = WinLoadMenu(hwnd, 0, IDD_CONTAINERMENU);
  393.                 WinQueryPointerPos(HWND_DESKTOP, &point);
  394.                 WinMapWindowPoints(HWND_DESKTOP,hwndContainer,&point,1);
  395.  
  396.                 WinPopupMenu(hwndContainer, hwnd, hwndMenu,
  397.                              (SHORT)point.x, (SHORT)point.y,
  398.                              IDM_ICON, PU_NONE | PU_SELECTITEM |
  399.                              PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_KEYBOARD);
  400.                break;
  401.             }
  402.             case SLN_CHANGE:
  403.             {
  404.                LONG ulValue;
  405.  
  406.                if (SHORT1FROMMP(mp1) == IDC_HSLIDER)
  407.                {
  408.                   ulValue = (ULONG) WinSendDlgItemMsg(hwnd, IDC_HSLIDER,
  409.                      SLM_QUERYSLIDERINFO,
  410.                      MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
  411.                      NULL);
  412.                   cData = _ltoa(ulValue,acBuffer,10);
  413.                   WinSetDlgItemText(hwnd,IDC_HSLIDERDATA, cData);
  414.                }
  415.                else
  416.                {
  417.                   ulValue = (ULONG) WinSendDlgItemMsg(hwnd, IDC_VSLIDER,
  418.                      SLM_QUERYSLIDERINFO,
  419.                      MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
  420.                      NULL);
  421.                   cData = _ltoa(ulValue,acBuffer,10);
  422.                   WinSetDlgItemText(hwnd,IDC_VSLIDERDATA, cData);
  423.                }
  424.                break;
  425.             }
  426.             case VN_SELECT:
  427.             case VN_ENTER:
  428.             {
  429.                CHAR  pszNotificationTxt[256];
  430.                CHAR  pszTmp[5];
  431.                ULONG ulRowCol;
  432.  
  433.                ulRowCol = (ULONG)WinSendDlgItemMsg(hwnd, IDC_VALUESET,
  434.                   VM_QUERYSELECTEDITEM, NULL, NULL);
  435.  
  436.                if ((SHORT2FROMMP(mp1)) == VN_SELECT)
  437.                   strcpy (pszNotificationTxt, "VN_SELECT for item at row ");
  438.                else
  439.                   strcpy (pszNotificationTxt, "VN_ENTER for item at row ");
  440.  
  441.                _itoa(SHORT1FROMMP(ulRowCol), pszTmp, 10);
  442.                strcat (pszNotificationTxt, pszTmp);
  443.                strcat (pszNotificationTxt, ",Column ");
  444.                _itoa(SHORT2FROMMP(ulRowCol), pszTmp, 10);
  445.                strcat (pszNotificationTxt, pszTmp);
  446.                WinSetDlgItemText(hwnd,IDC_VALUESETTEXT, pszNotificationTxt);
  447.                break;
  448.             }
  449.          }
  450.          break;
  451.       case WM_COMMAND:
  452.          switch( SHORT1FROMMP( mp1 ) )     /* Extract the command value    */
  453.          {
  454.             /*
  455.              * Process the command messages from the container popup menu
  456.              */
  457.             case IDM_ICON:
  458.                cnrinfo.flWindowAttr = CV_ICON | ulCnrAttributes;
  459.                WinSendDlgItemMsg(hwnd,IDC_CONTAINER,CM_SETCNRINFO,&cnrinfo,
  460.                               MPFROMLONG(CMA_FLWINDOWATTR));
  461.                break;
  462.  
  463.             case IDM_NAME:
  464.                cnrinfo.flWindowAttr = CV_NAME | ulCnrAttributes;
  465.                WinSendDlgItemMsg(hwnd,IDC_CONTAINER,CM_SETCNRINFO,&cnrinfo,
  466.                              MPFROMLONG(CMA_FLWINDOWATTR));
  467.                break;
  468.  
  469.             case IDM_TEXT:
  470.                cnrinfo.flWindowAttr = CV_TEXT | ulCnrAttributes;
  471.                WinSendDlgItemMsg(hwnd,IDC_CONTAINER,CM_SETCNRINFO,&cnrinfo,
  472.                                 MPFROMLONG(CMA_FLWINDOWATTR));
  473.                break;
  474.  
  475.             case IDM_DETAIL:
  476.                cnrinfo.flWindowAttr = CV_DETAIL | ulCnrAttributes |
  477.                   CA_DETAILSVIEWTITLES;
  478.  
  479.                WinSendDlgItemMsg(hwnd,IDC_CONTAINER,CM_SETCNRINFO,&cnrinfo,
  480.                                 MPFROMLONG(CMA_FLWINDOWATTR));
  481.  
  482.                WinSendDlgItemMsg(hwnd,IDC_CONTAINER,
  483.                                  CM_INVALIDATEDETAILFIELDINFO,      /*@@@RBS*/
  484.                                  NULL, NULL);
  485.  
  486.                break;
  487.  
  488.  
  489.  
  490. EndDialog:
  491.             case IDC_SLE_DLG_END:
  492.             case IDC_MLE_DLG_END:
  493.             case DID_OK:
  494.             case DID_CANCEL:          /* The Cancel pushbutton or Escape key */
  495.                WinDismissDlg( hwnd, TRUE );     /* Removes the dialog box    */
  496.                return (MRESULT)FALSE;
  497.  
  498.             default:
  499.                break;
  500.          }
  501.          break;
  502.  
  503.       case WM_HELP:
  504.          ShowDlgHelp(hwnd);
  505.          break;
  506.  
  507.       default:
  508.          return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  509.          break;
  510.    }
  511.    return (MRESULT)0;
  512. }                                            /* End of DemoDlgProc()        */
  513.  
  514. /*********************************************************************
  515.  *  Name : LoadListBox
  516.  *
  517.  *  Description : Loads the demo list box with 0 through 9
  518.  *
  519.  *
  520.  *  Concepts : Called each time a demo list box is
  521.  *             initialized.  A for 0 to 9 loop is converts
  522.  *             the INT to a string which is added to the
  523.  *             listbox via LM_INSERTITEM
  524.  *
  525.  *  API's : WinLoadString
  526.  *          WinSendMsg
  527.  *
  528.  *  Parameters : hwnd - Window handle of the list box.
  529.  *
  530.  *  Returns: TRUE if list box is loaded successfully, FALSE otherwise
  531.  *
  532.  ****************************************************************/
  533. BOOL LoadListBox(HWND hwnd)
  534. {
  535.    SHORT sCounter;
  536.    CHAR pszTemp[MESSAGELEN];
  537.    SHORT sReturn;
  538.  
  539.    SHORT BaseStringID;
  540.    SHORT WindowID;
  541.  
  542.    WindowID = WinQueryWindowUShort(hwnd, QWS_ID);
  543.  
  544. //BIDI
  545. //
  546. //  Set the listboxes (and comboboxes) bidi attributes.
  547. //
  548. //---------------------------------------
  549.    {
  550.     ULONG BidiAttr;
  551.     switch(WindowID) {
  552.  
  553.        case IDC_LISTBOX1:
  554.        case IDC_MULTISELLISTBOX1:
  555.        case IDC_SIMPLE:
  556.             BidiAttr = BDA_TEXTTYPE_VISUAL  |
  557.                        BDA_TEXT_ORIENT_LTR  |
  558.                        BDA_WND_ORIENT_RTL;
  559.             break;
  560.  
  561.  
  562.        case IDC_LISTBOX2:
  563.        case IDC_MULTISELLISTBOX2:
  564.        case IDC_DROPDOWN:
  565.        case IDC_DROPDOWNLIST:
  566.              BidiAttr = BDA_TEXTTYPE_IMPLICIT |
  567.                         BDA_WND_ORIENT_RTL;
  568.              break;
  569.  
  570.        default:
  571.              BidiAttr = 0;
  572.              break;
  573.  
  574.     } /* end switch */
  575.  
  576.  
  577.     WinSetLangInfo(hwnd, LI_BD_WND_ATTR, BidiAttr, BDAM_ALL, LIF_WND_REFRESH, 0L);
  578.    }
  579. //---------------------------------------
  580. //BIDI
  581.  
  582.  
  583.    BaseStringID = (WindowID == IDC_LISTBOX1) ? IDS_LISTBOX1_1 :
  584.                   (WindowID == IDC_LISTBOX2) ? IDS_LISTBOX2_1 :
  585.                   (WindowID == IDC_MULTISELLISTBOX1) ? IDS_LISTBOX1_1 :
  586.                   (WindowID == IDC_MULTISELLISTBOX2) ? IDS_LISTBOX2_1 :
  587.                   (WindowID == IDC_SIMPLE)       ? IDS_LISTBOX1_1 :
  588.                   (WindowID == IDC_DROPDOWN)     ? IDS_LISTBOX2_1 :
  589.                   (WindowID == IDC_DROPDOWNLIST) ? IDS_LISTBOX2_1 :
  590.                    IDS_LISTBOX1_1 ;
  591.  
  592.    BaseStringID += ARA_OFF;
  593.  
  594.    for(sCounter = 0; sCounter < 10; sCounter++)
  595.    {
  596.       if (!WinLoadString(hab, (HMODULE)0, (SHORT)(BaseStringID + sCounter),
  597.                         MESSAGELEN, (PSZ)pszTemp))
  598.       {
  599.          MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, FALSE);
  600.          return FALSE;
  601.       }
  602.       sReturn = (SHORT)WinSendMsg(hwnd, LM_INSERTITEM,
  603.                                MPFROMSHORT(LIT_SORTASCENDING),
  604.                                MPFROMP((PSZ)pszTemp));
  605.  
  606.       if (sReturn == LIT_ERROR || sReturn == LIT_MEMERROR)
  607.       {
  608.          MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, FALSE);
  609.  
  610.          return FALSE;
  611.       }
  612.     }
  613.     return TRUE;
  614.  
  615. }                                          /*    End of LoadListBox()       */
  616.  
  617.  
  618. /*********************************************************************
  619.  *  Name : PresParamDemoDlgProc
  620.  *
  621.  *  Description : Processes all messages sent to the PresParamDemo
  622.  *                dialog.
  623.  *
  624.  *  Concepts : Called for each message sent to the PresParamDemo
  625.  *             dialog box.  A switch statement branches to the
  626.  *             routines to be performed for each message
  627.  *             processed.  Any messages not specifically process
  628.  *             are passed to the default window procedure
  629.  *             WinDefDlgProc().
  630.  *
  631.  *  API's : WinDismissDlg
  632.  *          WinDefDlgProc
  633.  *
  634.  *  Parameters   : hwnd - Window handle to which message is addressed
  635.  *                 msg - Message type
  636.  *                 mp1 - First message parameter
  637.  *                 mp2 - Second message parameter
  638.  *
  639.  *  Returns: Dependent upon message sent
  640.  *
  641.  ****************************************************************/
  642. MRESULT EXPENTRY PresParamDemoDlgProc( HWND hwnd, USHORT msg,
  643.                                        MPARAM mp1, MPARAM mp2)
  644. {
  645.    switch(msg)
  646.    {
  647.       case WM_INITDLG:
  648.          /*
  649.           * If initialization fails, abort the dialog
  650.           */
  651.          if (!InitPresParamDemoDlg(hwnd))
  652.              WinDismissDlg(hwnd, FALSE);
  653.          return (MRESULT)FALSE;
  654.          break;
  655.  
  656.       case WM_COMMAND:
  657.          switch(SHORT1FROMMP(mp1))
  658.          {
  659.             case IDC_CANCEL:
  660.             /*
  661.              * If done, close the dialog
  662.              */
  663.                WinDismissDlg(hwnd, TRUE);
  664.                break;
  665.  
  666.             case IDC_APPLY:
  667.             /*
  668.              * Update the dialog box
  669.              */
  670.                UpdatePresParamDemoDlg(hwnd);
  671.                break;
  672.  
  673.             default:
  674.                break;
  675.          }
  676.          break;
  677.  
  678.       case WM_HELP:
  679.          ShowDlgHelp(hwnd);
  680.          break;
  681.  
  682.       default:
  683.          return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  684.          break;
  685.    }
  686.    return (MRESULT)0;
  687. }                                      /* End of PresParamDemoDlgProc() */
  688.  
  689.  
  690. //BIDI
  691. /*********************************************************************
  692.  *  Name : TextConvertDlgProc
  693.  *
  694.  *  Description : Processes all messages sent to the TextConvert
  695.  *                dialog.
  696.  *
  697.  *  Concepts :
  698.  *
  699.  *  API's : WinDismissDlg
  700.  *          WinDefDlgProc
  701.  *
  702.  *  Parameters   : hwnd - Window handle to which message is addressed
  703.  *                 msg - Message type
  704.  *                 mp1 - First message parameter
  705.  *                 mp2 - Second message parameter
  706.  *
  707.  *  Returns: Dependent upon message sent
  708.  *
  709.  ****************************************************************/
  710. MRESULT EXPENTRY TextConvertDlgProc( HWND hwnd, USHORT msg,
  711.                                        MPARAM mp1, MPARAM mp2)
  712. {
  713.    ULONG rc;
  714.  
  715.    switch(msg)
  716.    {
  717.  
  718.       case WM_COMMAND:
  719.          switch(SHORT1FROMMP(mp1))
  720.          {
  721.             case IDC_CANCEL:
  722.             /*
  723.              * If done, close the dialog
  724.              */
  725.                WinDismissDlg(hwnd, TRUE);
  726.                break;
  727.  
  728.             case IDC_TEXTCONV_START:
  729.             /*
  730.              * Start the Text Conversion
  731.              */
  732.                {
  733.                HWND hwndResult;
  734.                hwndResult =  WinWindowFromID (hwnd, IDC_TEXTCONV_RESULT);
  735.  
  736.                WinSetWindowText ( hwndResult, "Text Transformation in progress..." );
  737.  
  738.                rc = TransformText(hwnd);
  739.  
  740.                WinSetWindowText ( hwndResult, "Text Transformation Ended..." );
  741.  
  742.                ReportTestResult(hwnd, rc);
  743.  
  744.                break;
  745.                }
  746.  
  747.             default:
  748.                break;
  749.          }
  750.          break;
  751.  
  752.  
  753.       default:
  754.          return(WinDefDlgProc(hwnd, msg, mp1, mp2));
  755.          break;
  756.    }
  757.    return (MRESULT)0;
  758. }                                      /* End of TextConvertDlgProc() */
  759. //BIDI End
  760.  
  761. /*********************************************************************
  762.  *  Name : InitPresParamDemoDlg
  763.  *
  764.  *  Description : Places the colors and fonts into the
  765.  *                PresParamDemoDlg's comboboxes.
  766.  *
  767.  *  Concepts : Called when the PP demo dialog is initialized.
  768.  *             LM_INSERTITEM is sent to each combobox for the
  769.  *             color or font string added to the combobox.
  770.  *
  771.  *  API's : WinLoadString
  772.  *          WinWindowFromID
  773.  *          WinSendMsg
  774.  *          GpiQueryFonts
  775.  *          WinGetPS
  776.  *          WinReleasePS
  777.  *          DosAllocMem
  778.  *          DosFreeMem
  779.  *
  780.  *  Parameters : hwnd - Window handle of the dialog
  781.  *
  782.  *  Returns: TRUE if initialization is successfull, FALSE if not
  783.  *
  784.  ****************************************************************/
  785. BOOL InitPresParamDemoDlg(HWND hwnd)
  786. {
  787.    HWND hwndTemp;
  788.    SHORT sCounter;
  789.    SHORT sReturn;
  790.    PFONTMETRICS pfm, pfmSave;
  791.    LONG lTemp, lFonts;
  792.    HPS hps;
  793.    PSZ *ppszT;
  794.    BOOL bHaveFont;
  795.  
  796.    /*
  797.     * Load the color table
  798.     */
  799.    for (sCounter = 0; sCounter < NUMCOLORS; sCounter++)
  800.    {
  801.       if (!WinLoadString(hab, (HMODULE)0, (SHORT)(sCounter + IDS_FIRSTCOLOR),
  802.              COLORNAMELEN, (PSZ)apszPresParamColor[sCounter]))
  803.       {
  804.          MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, FALSE);
  805.          return FALSE;
  806.       }
  807.    }
  808.    /*
  809.     * Load foreground color combo box
  810.     */
  811.    hwndTemp = WinWindowFromID(hwnd, IDC_FORECOLORLIST);
  812.  
  813.    for(sCounter = 0; sCounter < NUMCOLORS; sCounter++)
  814.    {
  815.       sReturn = (SHORT)WinSendMsg(hwndTemp, LM_INSERTITEM,
  816.                           MPFROMSHORT(LIT_SORTASCENDING),
  817.                           MPFROMP((PSZ)apszPresParamColor[sCounter]));
  818.  
  819.       if (sCounter == LIT_ERROR || sCounter == LIT_MEMERROR)
  820.       {
  821.          MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR,
  822.               FALSE);
  823.          return FALSE;
  824.       }
  825.    }
  826.  
  827.    /*
  828.    * Load background color combo box
  829.    */
  830.    hwndTemp = WinWindowFromID(hwnd, IDC_BACKCOLORLIST);
  831.  
  832.    for(sCounter = 0; sCounter < NUMCOLORS; sCounter++)
  833.    {
  834.       sReturn = (SHORT)WinSendMsg(hwndTemp, LM_INSERTITEM,
  835.                             MPFROMSHORT(LIT_SORTASCENDING),
  836.                             MPFROMP((PSZ)apszPresParamColor[sCounter]));
  837.  
  838.        if (sCounter == LIT_ERROR || sCounter == LIT_MEMERROR)
  839.        {
  840.           MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR,
  841.                 FALSE);
  842.           return FALSE;
  843.        }
  844.    }
  845.    /*
  846.     * Fonts.  Find all of the fonts of point size desired and normal
  847.     * weight.  Put the facenames in the combo box
  848.     */
  849.    hwndTemp = WinWindowFromID(hwnd, IDC_FONTLIST);
  850.    hps = WinGetPS(hwndTemp);
  851.  
  852.    /*
  853.     * Determine the number of fonts available
  854.     */
  855.    lFonts = 0;
  856.    lTemp = 0;
  857.    lFonts = GpiQueryFonts(hps, QF_PUBLIC, NULL, &lTemp,
  858.                   (ULONG)sizeof(FONTMETRICS), (PFONTMETRICS)NULL);
  859.  
  860.    if (lFonts == GPI_ALTERROR)
  861.    {
  862.        MessageBox(hwndMain, IDMSG_CANNOTLOADFONTS, MB_OK | MB_ERROR, FALSE);
  863.        WinReleasePS(hps);
  864.        return FALSE;
  865.    }
  866.  
  867.    /*
  868.     * Allocate buffer for fontmetric structures
  869.     */
  870.    if (DosAllocMem((PPVOID)&pfm, lFonts * (ULONG)sizeof(FONTMETRICS),
  871.            fALLOC))
  872.    {
  873.       MessageBox(hwndMain, IDMSG_CANNOTALLOCATEMEMORY, MB_OK | MB_ERROR,
  874.             FALSE);
  875.       WinReleasePS(hps);
  876.       return FALSE;
  877.    }
  878.    pfmSave = pfm;
  879.  
  880.    /*
  881.     * Get all fonts
  882.     */
  883.    lTemp = GpiQueryFonts(hps, QF_PUBLIC, NULL, &lFonts,
  884.                 (ULONG)sizeof(FONTMETRICS), (PFONTMETRICS)pfm);
  885.  
  886.    WinReleasePS(hps);
  887.  
  888.    if (lTemp == GPI_ALTERROR)
  889.    {
  890.       MessageBox(hwndMain, IDMSG_CANNOTLOADFONTS, MB_OK | MB_ERROR, FALSE);
  891.       return FALSE;
  892.    }
  893.  
  894.    /*
  895.     * Allocate buffer for array of string names, freeing the first
  896.     * buffer if necessary
  897.     */
  898.    if ((BOOL)apszPresParamFont)
  899.    {
  900.       ppszT = apszPresParamFont;
  901.       while ((BOOL)*ppszT)
  902.       {
  903.          DosFreeMem(*ppszT++);
  904.       }
  905.  
  906.       DosFreeMem(apszPresParamFont);
  907.    }
  908.  
  909.    if (DosAllocMem((PPVOID)&apszPresParamFont,
  910.           (lFonts + 1) * (ULONG)sizeof(PSZ), fALLOC))
  911.    {
  912.       MessageBox(hwndMain, IDMSG_CANNOTALLOCATEMEMORY, MB_OK | MB_ERROR,
  913.            FALSE);
  914.       DosFreeMem((PVOID)pfmSave);
  915.       apszPresParamFont = NULL;
  916.       return FALSE;
  917.    }
  918.  
  919.    /*
  920.     * Initialize array to NULL
  921.     */
  922.    lTemp = 0;
  923.    ppszT = apszPresParamFont;
  924.    while (lTemp++ < lFonts)
  925.        *ppszT++ = (PSZ)NULL;
  926.    *ppszT = (PSZ)NULL;
  927.  
  928.  
  929.    /*
  930.     * Walk through all fonts.  If the font matches the point size
  931.     * desired and has a weight and width class of normal (5) and
  932.     * no special attributes (e. g. italic, underline, etc.).  If
  933.     * it does, then add its string to the combo box
  934.     */
  935.    lNumFonts = 0;
  936.    ppszT = apszPresParamFont;
  937.  
  938.    while (lFonts--)
  939.    {
  940.       if (pfm->sNominalPointSize == FONTPOINTSIZE &&
  941.              pfm->usWeightClass == 5 && pfm->usWidthClass == 5 &&
  942.              pfm->fsSelection == 0)
  943.       {
  944.       /*
  945.        * Make sure we don't have this font.  If we don't,
  946.        * then add the font to the list
  947.        */
  948.          lTemp = 0;
  949.          bHaveFont = FALSE;
  950.          while (lTemp < lNumFonts)
  951.          {
  952.             if (!strcmp(pfm->szFacename, apszPresParamFont[(INT)lTemp]))
  953.             {
  954.                bHaveFont = TRUE;
  955.                break;
  956.             }
  957.             else
  958.                lTemp++;
  959.          }
  960.  
  961.          if (!bHaveFont)
  962.          {
  963.             if (DosAllocMem((PPVOID)ppszT,
  964.                 (LONG)(FACESIZE * sizeof(CHAR)), fALLOC))
  965.             {
  966.                MessageBox(hwndMain, IDMSG_CANNOTALLOCATEMEMORY,
  967.                   MB_OK | MB_ERROR, FALSE);
  968.                DosFreeMem((PVOID)pfmSave);
  969.                return FALSE;
  970.              }
  971.  
  972.              strcpy(*ppszT++, pfm->szFacename);
  973.              lNumFonts++;
  974.          }
  975.       }
  976.       pfm++;
  977.    }
  978.  
  979.    /*
  980.     * Install the name of each font into the combo box
  981.     */
  982.    ppszT = apszPresParamFont;
  983.    while ((BOOL)*ppszT)
  984.    {
  985.       lTemp = (LONG)WinSendMsg(hwndTemp, LM_INSERTITEM,
  986.                    MPFROMSHORT(LIT_SORTASCENDING), MPFROMP((PSZ)*ppszT++));
  987.  
  988.       if (sCounter == LIT_ERROR || sCounter == LIT_MEMERROR)
  989.       {
  990.          MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR,
  991.               FALSE);
  992.          DosFreeMem((PVOID)pfmSave);
  993.          return FALSE;
  994.       }
  995.    }
  996.  
  997.    /*
  998.     * Add "DefaulTemp" text onto the end
  999.     */
  1000.    lTemp = (LONG)WinSendMsg(hwndTemp, LM_INSERTITEM,
  1001.                  MPFROMSHORT(LIT_SORTASCENDING),
  1002.                  MPFROMP(apszPresParamColor[IDS_DEFAULT - IDS_FIRSTCOLOR]));
  1003.  
  1004.    if (sCounter == LIT_ERROR || sCounter == LIT_MEMERROR)
  1005.    {
  1006.       MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, FALSE);
  1007.       DosFreeMem((PVOID)pfmSave);
  1008.       return FALSE;
  1009.    }
  1010.    DosFreeMem((PVOID)pfmSave);
  1011.    return TRUE;
  1012. }                                      /* End of InitPresParamDemoDlg()   */
  1013.  
  1014. /*********************************************************************
  1015.  *  Name : UpdatePresParamDemoDlg
  1016.  *
  1017.  *  Description : Sets/Removes the Presentation Parameter of the sample
  1018.  *                text window depending upon the parameters chosen,
  1019.  *
  1020.  *  Concepts : Called when user wants to update the window.  The string
  1021.  *             of each combobox is queried and then the color or font
  1022.  *             is set depending upon the string chosen.
  1023.  *
  1024.  *  API's : WinWindowFromID
  1025.  *          WinQueryWindowText
  1026.  *          WinSendMsg
  1027.  *          WinSetPresParams
  1028.  *          WinQueryPresParams
  1029.  *          WinRemovePresParams
  1030.  *
  1031.  *  Parameters : hwnd - Handle of Presentation Params dialog
  1032.  *
  1033.  *  Returns: TRUE if update is successfull, FALSE if not
  1034.  *
  1035.  ****************************************************************/
  1036. BOOL UpdatePresParamDemoDlg(HWND hwnd)
  1037. {
  1038.    HWND hwndTemp, hwndSampleText, hwndSampleButton;
  1039.    CHAR pszTemp[COLORNAMELEN];
  1040.    BYTE abBuf[FACESIZE + PPFONTPOINTSIZE];
  1041.    ULONG ulColor, ulPresParams;
  1042.    SHORT sCounter;
  1043.  
  1044.    /*
  1045.     * Get window handle of the sample text box
  1046.     */
  1047.    hwndSampleText = WinWindowFromID(hwnd, IDC_SAMPLETEXT);
  1048.    hwndSampleButton = WinWindowFromID(hwnd, IDC_CHECKBOX);
  1049.  
  1050.    /*
  1051.     * Get the text of the foreground color combobox
  1052.    */
  1053.    hwndTemp = WinWindowFromID(hwnd, IDC_FORECOLORLIST);
  1054.  
  1055.    if (WinQueryWindowText(hwndTemp, COLORNAMELEN, (PSZ)pszTemp))
  1056.    {
  1057.    /*
  1058.     * Find the text in the list of color names
  1059.     */
  1060.       sCounter = 0;
  1061.       while (sCounter < NUMCOLORS)
  1062.       {
  1063.          if (!strcmp(pszTemp, apszPresParamColor[sCounter]))
  1064.          {
  1065.             ulColor = aulColor[sCounter];
  1066.             break;
  1067.          }
  1068.          else
  1069.             sCounter++;
  1070.       }
  1071.  
  1072.       /*
  1073.        * If color is not default, set the color.  If the default is
  1074.        * selected, then remove the color presentation parameter if
  1075.        * it exists.  If the value is not a valid color, then don't
  1076.        * don't do anything
  1077.        */
  1078.        if (sCounter < NUMCOLORS)
  1079.        {
  1080.           sCounter += IDS_FIRSTCOLOR;
  1081.           if (sCounter < IDS_DEFAULT)
  1082.           {
  1083.              if (!WinSetPresParam(hwndSampleText, PP_FOREGROUNDCOLORINDEX,
  1084.                    (ULONG)sizeof(LONG), (PVOID)&ulColor) ||
  1085.                    !WinSetPresParam(hwndSampleButton,
  1086.                    PP_FOREGROUNDCOLORINDEX, (ULONG)sizeof(LONG),
  1087.                    (PVOID)&ulColor))
  1088.              {
  1089.                 MessageBox(hwndMain, IDMSG_CANNOTSETPP, MB_OK | MB_ERROR, FALSE);
  1090.              }
  1091.           }
  1092.           else
  1093.           {
  1094.           /*
  1095.            * If setting presentation parameter to the default, remove
  1096.            * the presentation parameter, but only if it has been
  1097.            * set
  1098.            */
  1099.               if (sCounter == IDS_DEFAULT &&
  1100.                    WinQueryPresParam(hwndSampleText, PP_FOREGROUNDCOLORINDEX,
  1101.                    0, &ulPresParams, (ULONG)sizeof(LONG), (PVOID)&ulColor,
  1102.                    QPF_NOINHERIT) != 0)
  1103.               {
  1104.                  if (!WinRemovePresParam(hwndSampleText,
  1105.                      PP_FOREGROUNDCOLORINDEX) ||
  1106.                      !WinRemovePresParam(hwndSampleButton,
  1107.                      PP_FOREGROUNDCOLORINDEX))
  1108.                  {
  1109.                     MessageBox(hwndMain, IDMSG_CANNOTSETPP, MB_OK | MB_ERROR,
  1110.                          FALSE);
  1111.                  }
  1112.               }
  1113.           }
  1114.        }
  1115.    }
  1116.  
  1117.    /*
  1118.     * Do the same for the background color combobox
  1119.     */
  1120.    hwndTemp = WinWindowFromID(hwnd, IDC_BACKCOLORLIST);
  1121.    if (WinQueryWindowText(hwndTemp, COLORNAMELEN, (PSZ)pszTemp))
  1122.    {
  1123.    /*
  1124.     * Find the text in the list of color names
  1125.    */
  1126.       sCounter = 0;
  1127.       while (sCounter < NUMCOLORS)
  1128.       {
  1129.          if (!strcmp(pszTemp, apszPresParamColor[sCounter]))
  1130.          {
  1131.             ulColor = aulColor[sCounter];
  1132.             break;
  1133.          }
  1134.          else
  1135.             sCounter++;
  1136.       }
  1137.  
  1138.       /*
  1139.        * If color is not default, set the color.  If the default is
  1140.        * selected, then remove the color presentation parameter.  If
  1141.        * the value is not a valid color, the don't do anything
  1142.        */
  1143.        if (sCounter < NUMCOLORS)
  1144.        {
  1145.           sCounter += IDS_FIRSTCOLOR;
  1146.           if (sCounter < IDS_DEFAULT)
  1147.           {
  1148.              if (!WinSetPresParam(hwndSampleText, PP_BACKGROUNDCOLORINDEX,
  1149.                  (ULONG)sizeof(LONG), (PVOID)&ulColor) ||
  1150.                  !WinSetPresParam(hwndSampleButton, PP_BACKGROUNDCOLORINDEX,
  1151.                  (ULONG)sizeof(LONG), (PVOID)&ulColor))
  1152.              {
  1153.                 MessageBox(hwndMain, IDMSG_CANNOTSETPP, MB_OK | MB_ERROR,
  1154.                       FALSE);
  1155.              }
  1156.           }
  1157.           else
  1158.           {
  1159.              if (sCounter == IDS_DEFAULT &&
  1160.                   WinQueryPresParam(hwndSampleText,
  1161.                   PP_BACKGROUNDCOLORINDEX, 0, &ulPresParams, (ULONG)sizeof(LONG),
  1162.                   (PVOID)&ulColor, QPF_NOINHERIT) != 0)
  1163.              {
  1164.                 if (!WinRemovePresParam(hwndSampleText,
  1165.                     PP_BACKGROUNDCOLORINDEX) ||
  1166.                     !WinRemovePresParam(hwndSampleButton,
  1167.                     PP_BACKGROUNDCOLORINDEX))
  1168.                 {
  1169.                    MessageBox(hwndMain, IDMSG_CANNOTSETPP, MB_OK | MB_ERROR,
  1170.                          FALSE);
  1171.                 }
  1172.              }
  1173.           }
  1174.        }
  1175.    }
  1176.  
  1177.    /*
  1178.     * Get the text of the font combobox
  1179.     */
  1180.    hwndTemp = WinWindowFromID(hwnd, IDC_FONTLIST);
  1181.    if (WinQueryWindowText(hwndTemp, FACESIZE, (PSZ)pszTemp))
  1182.    {
  1183.    /*
  1184.     * If Font selected is "Default", remove font pres. param.
  1185.     */
  1186.       if (!strcmp(pszTemp, apszPresParamColor[IDS_DEFAULT - IDS_FIRSTCOLOR]))
  1187.       {
  1188.          if (WinQueryPresParam(hwndSampleText, PP_FONTNAMESIZE, 0,
  1189.               &ulPresParams, (ULONG)(FACESIZE + PPFONTPOINTSIZE), (PVOID)abBuf,
  1190.               QPF_NOINHERIT) != 0)
  1191.          {
  1192.             if (!WinRemovePresParam(hwndSampleText, PP_FONTNAMESIZE) ||
  1193.                 !WinRemovePresParam(hwndSampleButton, PP_FONTNAMESIZE))
  1194.             {
  1195.                MessageBox(hwndMain, IDMSG_CANNOTSETPP, MB_OK | MB_ERROR,
  1196.                     FALSE);
  1197.             }
  1198.          }
  1199.       }
  1200.       else
  1201.       {
  1202.       /*
  1203.        * Font is not default.
  1204.        * AbBuf will hold the font point size and name in
  1205.        * the form <pt>.<name>.  First we fill abBuf with the
  1206.        * font point prefix and then append the font name
  1207.        * retrieved from the combobox.
  1208.        */
  1209.  
  1210.          if (!WinLoadString(hab, (HMODULE)0, IDS_PPFONTPOINT,
  1211.               COLORNAMELEN, (PSZ)abBuf))
  1212.          {
  1213.             MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR,
  1214.                  FALSE);
  1215.             return FALSE;
  1216.          }
  1217.          strcat((PSZ)abBuf, pszTemp);
  1218.  
  1219.          if (!WinSetPresParam(hwndSampleText, PP_FONTNAMESIZE,
  1220.              (ULONG)strlen((PSZ)abBuf) + 1, (PVOID)abBuf) ||
  1221.              !WinSetPresParam(hwndSampleButton, PP_FONTNAMESIZE,
  1222.              (ULONG)strlen((PSZ)abBuf) + 1, (PVOID)abBuf))
  1223.          {
  1224.             MessageBox(hwndMain, IDMSG_CANNOTSETPP, MB_OK | MB_ERROR,
  1225.                  FALSE);
  1226.          }
  1227.       }
  1228.    }
  1229.    return TRUE;
  1230. }                                     /* End of UpdatePresParamDemoDlg() */
  1231.  
  1232. /*********************************************************************
  1233.  *  Name : ShowDlgHelp
  1234.  *
  1235.  *  Description : Displays the help panel for the current selected
  1236.  *                item in the dialog window
  1237.  *
  1238.  *  Concepts : Called each time a WM_HELP message is posted to a
  1239.  *             dialog gets the id value of the window and determine
  1240.  *             which help panel to display.  Then sends a message
  1241.  *             to the help instance to display the panel.  If the
  1242.  *             dialog or item is not included here, then the
  1243.  *             unknown dialog or unknown item panel is displayed.
  1244.  *
  1245.  *  API's : WinQueryFocus
  1246.  *          WinQueryWindowUShort
  1247.  *          WinWindowFromID
  1248.  *
  1249.  *  Parameters : hwnd - Handle of the dialog box
  1250.  *
  1251.  *  Returns: Void
  1252.  *
  1253.  ****************************************************************/
  1254. VOID ShowDlgHelp(HWND hwnd)
  1255. {
  1256.    SHORT idPanel, idDlg, idItem;
  1257.    HWND hwndFocus;
  1258.  
  1259.    /*
  1260.    * Get the id of the dialog box
  1261.    */
  1262.    idDlg = WinQueryWindowUShort(hwnd, QWS_ID);
  1263.  
  1264.    /*
  1265.     * Finds which window has the focus and gets its id
  1266.     */
  1267.    hwndFocus = WinQueryFocus(HWND_DESKTOP);
  1268.    idItem = WinQueryWindowUShort(hwndFocus, QWS_ID);
  1269.  
  1270.    switch(idDlg)
  1271.    {
  1272.       case IDD_BUTTONSDLG:
  1273.          switch(idItem)
  1274.          {
  1275.             case IDC_RADIO1:
  1276.             case IDC_RADIO2:
  1277.             case IDC_RADIO3:
  1278.                idPanel = PANEL_BUTTONSDLG_RADIO;
  1279.                break;
  1280.  
  1281.             case IDC_CHECKBOX:
  1282.                idPanel = PANEL_BUTTONSDLG_CHECKBOX;
  1283.                break;
  1284.  
  1285.             case IDC_3STATE:
  1286.                idPanel = PANEL_BUTTONSDLG_THREESTATE;
  1287.                break;
  1288.  
  1289.             case IDC_PUSHBUTTON:
  1290.                idPanel = PANEL_BUTTONSDLG_PUSHBUTTON;
  1291.                break;
  1292.  
  1293.             case IDC_OK:
  1294.                idPanel = PANEL_BUTTONSDLG_OK;
  1295.                break;
  1296.  
  1297.             case IDC_HELP:
  1298.                idPanel = PANEL_BUTTONSDLG_HELP;
  1299.                break;
  1300.  
  1301.             default:
  1302.                idPanel = PANEL_UNKNOWN;
  1303.                break;
  1304.          }
  1305.          break;
  1306.  
  1307.       case IDD_LISTBOXDLG:
  1308.          switch(idItem)
  1309.          {
  1310.             case IDC_LISTBOX1:
  1311.             case IDC_LISTBOX2:
  1312.                idPanel = PANEL_LISTBOXDLG_SINGLE;
  1313.                break;
  1314.  
  1315.             case IDC_MULTISELLISTBOX1:
  1316.             case IDC_MULTISELLISTBOX2:
  1317.                idPanel = PANEL_LISTBOXDLG_MULTIPLE;
  1318.                break;
  1319.  
  1320.             case IDC_OK:
  1321.                idPanel = PANEL_LISTBOXDLG_OK;
  1322.                break;
  1323.  
  1324.             case IDC_HELP:
  1325.                idPanel = PANEL_LISTBOXDLG_HELP;
  1326.                break;
  1327.  
  1328.             default:
  1329.                idPanel = PANEL_UNKNOWN;
  1330.                break;
  1331.          }
  1332.          break;
  1333.  
  1334.       case IDD_COMBOBOXDLG:
  1335.          switch(idItem)
  1336.          {
  1337.             case IDC_SIMPLE:
  1338.                idPanel = PANEL_COMBOBOXDLG_SIMPLE;
  1339.                break;
  1340.  
  1341.             case IDC_DROPDOWN:
  1342.                idPanel = PANEL_COMBOBOXDLG_DROPDOWN;
  1343.                break;
  1344.  
  1345.             case IDC_DROPDOWNLIST:
  1346.                idPanel = PANEL_COMBOBOXDLG_DROPDOWNLIST;
  1347.                break;
  1348.  
  1349.             case IDC_OK:
  1350.                idPanel = PANEL_COMBOBOXDLG_OK;
  1351.                break;
  1352.  
  1353.             case IDC_HELP:
  1354.                idPanel = PANEL_COMBOBOXDLG_HELP;
  1355.                break;
  1356.  
  1357.             default:
  1358.                /*
  1359.                 * Check to see if window that has the focus is the
  1360.                 * entry field of the combobox.  If it is, then
  1361.                 * call the appropriate combobox help panel.  If
  1362.                 * not, then call the unknown panel
  1363.                 */
  1364.                if (WinWindowFromID(WinWindowFromID(hwnd, IDC_SIMPLE),
  1365.                    CBID_EDIT) == hwndFocus)
  1366.                {
  1367.                   idPanel = PANEL_COMBOBOXDLG_SIMPLE;
  1368.                }
  1369.                else
  1370.                   if (WinWindowFromID(WinWindowFromID(hwnd, IDC_DROPDOWN),
  1371.                      CBID_EDIT) == hwndFocus)
  1372.                   {
  1373.                        idPanel = PANEL_COMBOBOXDLG_DROPDOWN;
  1374.                   }
  1375.                   else
  1376.                        if (WinWindowFromID(
  1377.                            WinWindowFromID(hwnd, IDC_DROPDOWNLIST),
  1378.                            CBID_EDIT) == hwndFocus)
  1379.                        {
  1380.                           idPanel = PANEL_COMBOBOXDLG_DROPDOWNLIST;
  1381.                        }
  1382.                        else
  1383.                           idPanel = PANEL_UNKNOWN;
  1384.               break;
  1385.          }
  1386.          break;
  1387.  
  1388.       case IDD_SL_ENTRYFIELDDLG:
  1389.       case IDD_ML_ENTRYFIELDDLG:
  1390.          switch(idItem)
  1391.          {
  1392.             case IDC_ENTRY_1:
  1393.             case IDC_ENTRY_2:
  1394.             case IDC_ENTRY_3:
  1395.             case IDC_ENTRY_4:
  1396.                idPanel = PANEL_ENTRYFIELDDLG_ENTRY;
  1397.                break;
  1398.  
  1399.             case IDC_MLE_1:
  1400.             case IDC_MLE_2:
  1401.                idPanel = PANEL_ENTRYFIELDDLG_MLE;
  1402.                break;
  1403.  
  1404.             case IDC_OK:
  1405.                idPanel = PANEL_ENTRYFIELDDLG_OK;
  1406.                break;
  1407.  
  1408.             case IDC_HELP:
  1409.                idPanel = PANEL_ENTRYFIELDDLG_HELP;
  1410.                break;
  1411.  
  1412.             default:
  1413.                idPanel = PANEL_UNKNOWN;
  1414.                break;
  1415.          }
  1416.          break;
  1417.  
  1418.       case IDD_STATICDLG:
  1419.          switch(idItem)
  1420.          {
  1421.             case IDC_OK:
  1422.                idPanel = PANEL_STATICDLG_OK;
  1423.                break;
  1424.  
  1425.             case IDC_HELP:
  1426.                idPanel = PANEL_STATICDLG_HELP;
  1427.                break;
  1428.  
  1429.             default:
  1430.                idPanel = PANEL_UNKNOWN;
  1431.                break;
  1432.          }
  1433.          break;
  1434.  
  1435.       case IDD_PPDEMODLG:
  1436.          switch(idItem)
  1437.          {
  1438.             case IDC_FORECOLORLIST:
  1439.                idPanel = PANEL_PPDEMODLG_FORECOLORLIST;
  1440.                break;
  1441.  
  1442.             case IDC_BACKCOLORLIST:
  1443.                idPanel = PANEL_PPDEMODLG_BACKCOLORLIST;
  1444.                break;
  1445.  
  1446.             case IDC_FONTLIST:
  1447.                idPanel = PANEL_PPDEMODLG_FONTLIST;
  1448.                break;
  1449.  
  1450.             case IDC_CHECKBOX:
  1451.                idPanel = PANEL_PPDEMODLG_TESTBUTTON;
  1452.                break;
  1453.  
  1454.             case IDC_CANCEL:
  1455.                idPanel = PANEL_PPDEMODLG_CANCEL;
  1456.                break;
  1457.  
  1458.             case IDC_APPLY:
  1459.                idPanel = PANEL_PPDEMODLG_APPLY;
  1460.                break;
  1461.  
  1462.             case IDC_HELP:
  1463.                idPanel = PANEL_PPDEMODLG_HELP;
  1464.                break;
  1465.  
  1466.             default:
  1467.             /*
  1468.              * Check to see if window that has the focus is the
  1469.              * entry field of the combobox.  If it is, then
  1470.              * call the appropriate combobox help panel.  If
  1471.              * not, then call the unknown panel
  1472.              */
  1473.                if (WinWindowFromID(
  1474.                    WinWindowFromID(hwnd, IDC_FORECOLORLIST),
  1475.                    CBID_EDIT) == hwndFocus)
  1476.                {
  1477.                   idPanel = PANEL_PPDEMODLG_FORECOLORLIST;
  1478.                }
  1479.                else
  1480.                   if (WinWindowFromID(
  1481.                       WinWindowFromID(hwnd, IDC_BACKCOLORLIST),
  1482.                       CBID_EDIT) == hwndFocus)
  1483.                   {
  1484.                      idPanel = PANEL_PPDEMODLG_BACKCOLORLIST;
  1485.                   }
  1486.                   else
  1487.                      if(WinWindowFromID(
  1488.                         WinWindowFromID(hwnd, IDC_FONTLIST),
  1489.                         CBID_EDIT) == hwndFocus)
  1490.                      {
  1491.                         idPanel = PANEL_PPDEMODLG_FONTLIST;
  1492.                      }
  1493.                      else
  1494.                         idPanel = PANEL_UNKNOWN;
  1495.                break;
  1496.          }
  1497.          break;
  1498.  
  1499.       case IDD_CONTAINERDLG:
  1500.          switch(idItem)
  1501.          {
  1502.             case IDC_CONTAINER:
  1503.                idPanel = PANEL_CONTAINERDLG_CONTAINER;
  1504.                break;
  1505.  
  1506.             case IDC_OK:
  1507.                idPanel = PANEL_CONTAINERDLG_OK;
  1508.                break;
  1509.  
  1510.             case IDC_CANCEL:
  1511.                idPanel = PANEL_CONTAINERDLG_CANCEL;
  1512.                break;
  1513.  
  1514.             case IDC_HELP:
  1515.                idPanel = PANEL_CONTAINERDLG_HELP;
  1516.                break;
  1517.  
  1518.             default:
  1519.                idPanel = PANEL_UNKNOWN;
  1520.                break;
  1521.          }
  1522.          break;
  1523.  
  1524.       case IDD_NOTEBOOKDLG:
  1525.          switch(idItem)
  1526.          {
  1527.             case IDC_NOTEBOOK:
  1528.                idPanel = PANEL_NOTEBOOKDLG_NOTEBOOK;
  1529.                break;
  1530.  
  1531.             case IDC_OK:
  1532.                idPanel = PANEL_NOTEBOOKDLG_OK;
  1533.                break;
  1534.  
  1535.             case IDC_CANCEL:
  1536.                idPanel = PANEL_NOTEBOOKDLG_CANCEL;
  1537.                break;
  1538.  
  1539.             case IDC_HELP:
  1540.                idPanel = PANEL_NOTEBOOKDLG_HELP;
  1541.                break;
  1542.  
  1543.             default:
  1544.                idPanel = PANEL_UNKNOWN;
  1545.                break;
  1546.         }
  1547.         break;
  1548.       case IDD_SLIDERDLG:
  1549.          switch(idItem)
  1550.          {
  1551.             case IDC_VSLIDER:
  1552.                idPanel = PANEL_SLIDERDLG_VSLIDER;
  1553.                break;
  1554.  
  1555.             case IDC_HSLIDER:
  1556.                idPanel = PANEL_SLIDERDLG_HSLIDER;
  1557.                break;
  1558.  
  1559.             case IDC_OK:
  1560.                idPanel = PANEL_SLIDERDLG_OK;
  1561.                break;
  1562.  
  1563.             case IDC_CANCEL:
  1564.                idPanel = PANEL_SLIDERDLG_CANCEL;
  1565.                break;
  1566.  
  1567.             case IDC_HELP:
  1568.                idPanel = PANEL_SLIDERDLG_HELP;
  1569.                break;
  1570.  
  1571.             default:
  1572.                idPanel = PANEL_UNKNOWN;
  1573.                break;
  1574.          }
  1575.          break;
  1576.       case IDD_VALUESETDLG:
  1577.          switch(idItem)
  1578.          {
  1579.             case IDC_VALUESET:
  1580.                idPanel = PANEL_VALUESETDLG_VALUESET;
  1581.                break;
  1582.  
  1583.             case IDC_OK:
  1584.                idPanel = PANEL_VALUESETDLG_OK;
  1585.                break;
  1586.  
  1587.             case IDC_CANCEL:
  1588.                idPanel = PANEL_VALUESETDLG_CANCEL;
  1589.                break;
  1590.  
  1591.             case IDC_HELP:
  1592.                idPanel = PANEL_VALUESETDLG_HELP;
  1593.                break;
  1594.  
  1595.             default:
  1596.                idPanel = PANEL_UNKNOWN;
  1597.                break;
  1598.          }
  1599.          break;
  1600.       case IDD_SPINBUTTONDLG:
  1601.          switch(idItem)
  1602.          {
  1603.             case IDC_MASTER:
  1604.                idPanel = PANEL_SPINBUTTONDLG_MASTER;
  1605.                break;
  1606.  
  1607.             case IDC_SERVANT:
  1608.                idPanel = PANEL_SPINBUTTONDLG_SERVANT;
  1609.                break;
  1610.  
  1611.             case IDC_OK:
  1612.                idPanel = PANEL_SPINBUTTONDLG_OK;
  1613.                break;
  1614.  
  1615.             case IDC_CANCEL:
  1616.                idPanel = PANEL_SPINBUTTONDLG_CANCEL;
  1617.                break;
  1618.  
  1619.             case IDC_HELP:
  1620.                idPanel = PANEL_SPINBUTTONDLG_HELP;
  1621.                break;
  1622.  
  1623.             default:
  1624.                idPanel = PANEL_UNKNOWN;
  1625.                break;
  1626.          }
  1627.          break;
  1628.  
  1629.       case IDD_PRODINFO:
  1630.          idPanel = PANEL_ABOUTBOX;
  1631.          break;
  1632.  
  1633.       default:
  1634.          idPanel = PANEL_UNKNOWNDLG;
  1635.          break;
  1636.    }
  1637.    DisplayHelpPanel(idPanel);
  1638. }                                       /* End of ShowDlgHelp()        */
  1639.  
  1640. /*********************************************************************
  1641.  *  Name : InitializeValueSet
  1642.  *
  1643.  *  Description : Loads the demo Value Set with 4 different icons
  1644.  *                and with 4 colors derived form the color index.
  1645.  *
  1646.  *  Concepts : Called each time a demo Value Set is initialized A
  1647.  *             for 1 to 4 loop sets an Icon in each column of the
  1648.  *             First row of the Value Set via a VM_SETITEM
  1649.  *             message.  The Second row is set to a color by
  1650.  *             sending the VM_SETITEMATTR message.
  1651.  *
  1652.  *  API's : WinSendDlgItemMsg
  1653.  *
  1654.  *  Parameters : hwnd - Handle of the Valueset dialog.
  1655.  *
  1656.  *  Returns: TRUE if Value Set is loaded successfully, FALSE otherwise
  1657.  *
  1658.  ****************************************************************/
  1659. BOOL InitializeValueSet(HWND hwnd)
  1660. {
  1661.    USHORT usIndex;
  1662. //BIDI
  1663. // Set the Value Set to have Right-To-Left text orientation and
  1664. // Visual text.
  1665. //
  1666.     WinSetLangInfo(WinWindowFromID(hwnd,IDC_VALUESET),
  1667.               LI_BD_WND_ATTR,
  1668.               (BDA_INIT            |
  1669.                BDA_TEXT_ORIENT_RTL |
  1670.                BDA_TEXTTYPE_VISUAL  ),
  1671.               BDAM_ALL, 0L, 0L);
  1672.  
  1673.    for (usIndex = 1; usIndex <= 4;usIndex++)
  1674.    {
  1675.      // First row
  1676.      if (usIndex ==1) {
  1677.         // First item is a Text item.
  1678.         if ( !WinSendDlgItemMsg( hwnd,IDC_VALUESET, VM_SETITEMATTR,
  1679.               MPFROM2SHORT(1,usIndex),
  1680.               MPFROM2SHORT( VIA_TEXT, TRUE )))
  1681.             return FALSE;
  1682.         if ( !WinSendDlgItemMsg(hwnd, IDC_VALUESET, VM_SETITEM,
  1683.               MPFROM2SHORT(1,usIndex),
  1684.               MPFROMP("txeT yM")))
  1685.             return FALSE;
  1686.  
  1687.       } else {
  1688.          // Other items are icons.
  1689.         if ( !WinSendDlgItemMsg(hwnd, IDC_VALUESET, VM_SETITEM,
  1690.               MPFROM2SHORT(1,usIndex),
  1691.               MPFROMLONG( WinLoadPointer(HWND_DESKTOP, 0,
  1692.               (SHORT) (IDR_MAIN + usIndex)))))
  1693.             return FALSE;
  1694.      }
  1695.  
  1696.      // Second row
  1697.      if ( !WinSendDlgItemMsg( hwnd,IDC_VALUESET, VM_SETITEMATTR,
  1698.           MPFROM2SHORT(2,usIndex),
  1699.           MPFROM2SHORT( VIA_COLORINDEX, TRUE )))
  1700.         return FALSE;
  1701.  
  1702.      if ( !WinSendDlgItemMsg(hwnd, IDC_VALUESET, VM_SETITEM,
  1703.           MPFROM2SHORT(2,usIndex),
  1704.           MPFROMSHORT(usIndex)))
  1705.         return FALSE;
  1706.    }
  1707.    return TRUE;
  1708. }                                       /* End of InitializeValueset    */
  1709. /*********************************************************************
  1710.  *  Name : InitializeSlider
  1711.  *
  1712.  *  Description :  Set the Sliders Tick size and Scale Text.
  1713.  *
  1714.  *  Concepts : Called each time a demo Slider controls ar initialized
  1715.  *             Ses the he initail value of the sliders output display
  1716.  *             to 0. A for 0 to 10 for loop sets the ruler text and
  1717.  *             tick size for both the Horizontal and Vertical Sliders
  1718.  *             via SLM_SETSCALETEXT and SLM_SETTICKSIZE message.
  1719.  *
  1720.  *  API's : WinSendDlgItemMsg
  1721.  *
  1722.  *  Parameters : hwnd - Handle of the Slider dialog.
  1723.  *
  1724.  *  Returns: TRUE if Sliders are initialized successfully, FALSE otherwise
  1725.  *
  1726.  *******************************************************************/
  1727. BOOL InitializeSlider(HWND hwnd)
  1728. {
  1729.    USHORT usIndex;
  1730.    CHAR   acBuffer[4];
  1731.    CHAR   *cData;
  1732.  
  1733. //BIDI
  1734. //
  1735. // Sets both slider to have RtL window orientation and RtL text.
  1736. //
  1737.    WinSetLangInfo(WinWindowFromID(hwnd,IDC_HSLIDERDATA),
  1738.             LI_BD_WND_ATTR, BDA_WND_ORIENT_RTL | BDA_TEXT_ORIENT_RTL | BDA_INIT,
  1739.                  BDAM_ALL, 0L, 0L);
  1740.    WinSetLangInfo(WinWindowFromID(hwnd,IDC_VSLIDERDATA),
  1741.             LI_BD_WND_ATTR, BDA_WND_ORIENT_RTL | BDA_TEXT_ORIENT_RTL | BDA_INIT,
  1742.                  BDAM_ALL, 0L, 0L);
  1743. //BIDI
  1744.  
  1745.    cData = _ltoa(0,acBuffer,10);
  1746.    WinSetDlgItemText(hwnd,IDC_HSLIDERDATA, cData);
  1747.    WinSetDlgItemText(hwnd,IDC_VSLIDERDATA, cData);
  1748.    for (usIndex = 0;usIndex < 10 ;usIndex ++ )
  1749.    {
  1750.       _itoa(usIndex,acBuffer,10);
  1751.       if ( !WinSendDlgItemMsg(hwnd, IDC_HSLIDER, SLM_SETTICKSIZE,
  1752.                MPFROM2SHORT(usIndex, 5), NULL))
  1753.         return FALSE;
  1754.  
  1755.       if ( !WinSendDlgItemMsg(hwnd, IDC_HSLIDER, SLM_SETSCALETEXT,
  1756.                MPFROMSHORT(usIndex), MPFROMP(acBuffer)))
  1757.         return FALSE;
  1758.  
  1759.       if ( !WinSendDlgItemMsg(hwnd, IDC_VSLIDER, SLM_SETTICKSIZE,
  1760.                MPFROM2SHORT(usIndex, 5), NULL))
  1761.         return FALSE;
  1762.  
  1763.       if ( !WinSendDlgItemMsg(hwnd, IDC_VSLIDER, SLM_SETSCALETEXT,
  1764.                  MPFROMSHORT(usIndex), MPFROMP(acBuffer)))
  1765.         return FALSE;
  1766.    }
  1767.    return TRUE;
  1768. }                                       /* End of InitializeSlider      */
  1769.  
  1770. //BIDI
  1771. /*********************************************************************
  1772.  *  Name : Bidi_QueryCp()
  1773.  *
  1774.  *  Description : Routine to query the current window codepage.
  1775.  *
  1776.  *
  1777.  *********************************************************************/
  1778. ULONG  Bidi_QueryCp()
  1779. {
  1780. ULONG  CpList[2];
  1781. ULONG  CpSize;
  1782.  
  1783. ULONG cp = WinQueryCp(HMQ_CURRENT);
  1784.  
  1785.       /* If WinQueryCp fails, (this happens sometimes), then */
  1786.             /* we use Process codepage.                            */
  1787.  
  1788.       if (cp == 0L)
  1789.       {
  1790.  
  1791.          DosQueryCp(sizeof(CpList),       /* Length of list */
  1792.                              CpList,               /* List */
  1793.                            &CpSize);             /* Length of returned list */
  1794.  
  1795.          cp = CpList[0];
  1796.                }
  1797.  
  1798.       return cp;
  1799.  
  1800. }  /* Bidi_QueryCp() */
  1801. // BIDI - end
  1802.  
  1803. /*********************************************************************
  1804.  *  Name : InitializeSpinButton
  1805.  *
  1806.  *  Description : Set the intital values for the spin button controls.
  1807.  *
  1808.  *  Concepts : Sends a SPBM_SETARRAY to the Master Spin Button to set
  1809.  *             the values (text strings) available to the control.
  1810.  *             Sets the initial value to the array index of 0 by
  1811.  *             sending a SPBM_SETCURRENTVALUE.  The Servant Spin Button
  1812.  *             is initialized to the range 0 to 100 by sending a
  1813.  *             SPBM_SETLIMITS message.  Sends a SPBM_SETMASTER message
  1814.  *             to set the MASTER/SERVANT relationship between the two
  1815.  *             spin buttons.
  1816.  *
  1817.  *  API's : WinSendDlgItemMsg
  1818.  *          WinWindowFromID
  1819.  *
  1820.  *  Parameters : hwnd - Handle of the Spinnbutton dialog.
  1821.  *
  1822.  *  Returns: TRUE if Spinbuttons are initialized successfully, FALSE otherwise
  1823.  *
  1824.  ****************************************************************/
  1825. static CHAR aspinColors[NUMSPINCOLORS][32];
  1826.  
  1827. BOOL InitializeSpinButton(HWND hwnd)
  1828. {
  1829.    static PSZ   spinColors[NUMSPINCOLORS];
  1830. /*
  1831.    static PSZ   spinColors[] = {"White", "Black", "Blue", "Red"," Pink",
  1832.                      "Green", "Cyan", "Yellow", "Dark Grey", "Dark Blue",
  1833.                      "Dark Red", "Dark Pink", "Dark Green", "Dark Cyan",
  1834.                      "Brown", "Pale Grey"};
  1835. */
  1836.    ULONG I, J;
  1837.  
  1838. //BIDI
  1839. // Sets both spinbuttons to have right-to-left window orientation
  1840. // and right-to-left, Visual text.
  1841. //
  1842.    WinSetLangInfo(WinWindowFromID(hwnd,IDC_MASTER),
  1843.             LI_BD_WND_ATTR,
  1844.             (BDA_INIT              |
  1845.              BDA_WND_ORIENT_RTL    |
  1846.              BDA_TEXT_ORIENT_RTL   |
  1847.              BDA_TEXTTYPE_VISUAL   ),
  1848.              BDAM_ALL, 0L, 0L);
  1849.    WinSetLangInfo(WinWindowFromID(hwnd,IDC_SERVANT),
  1850.             LI_BD_WND_ATTR,
  1851.             (BDA_INIT              |
  1852.              BDA_WND_ORIENT_RTL    |
  1853.              BDA_TEXT_ORIENT_RTL   |
  1854.              BDA_TEXTTYPE_VISUAL   ),
  1855.              BDAM_ALL, 0L, 0L);
  1856.  
  1857.    I = IDS_SPIN_WHITE;
  1858.       I += ARA_OFF;
  1859.  
  1860. //BIDI
  1861.  
  1862.    for (J = 0; J < NUMSPINCOLORS; J++, I += 2)
  1863.    {
  1864.       WinLoadString(hab, NULLHANDLE, I, 31, aspinColors[J]);
  1865.       spinColors[J] = aspinColors[J];
  1866.    }
  1867.  
  1868.    if ( !WinSendDlgItemMsg( hwnd, IDC_MASTER, SPBM_SETARRAY, spinColors,
  1869.              MPFROMLONG(NUMSPINCOLORS)))
  1870.       return FALSE;
  1871.  
  1872.    if ( !WinSendDlgItemMsg( hwnd, IDC_MASTER, SPBM_SETCURRENTVALUE,
  1873.              MPFROMLONG(0), NULL))
  1874.       return FALSE;
  1875.  
  1876.    if ( !WinSendDlgItemMsg( hwnd, IDC_SERVANT, SPBM_SETLIMITS,
  1877.              MPFROMLONG(100), MPFROMLONG(0)))
  1878.       return FALSE;
  1879.  
  1880.    if ( !WinSendDlgItemMsg( hwnd, IDC_SERVANT, SPBM_SETCURRENTVALUE,
  1881.              MPFROMLONG(0), NULL))
  1882.       return FALSE;
  1883.  
  1884.    if (!WinSendDlgItemMsg(
  1885.            hwnd,
  1886.            IDC_SERVANT,
  1887.            SPBM_SETMASTER,
  1888.            MPFROMHWND( WinWindowFromID(hwnd, IDC_MASTER)),
  1889.            MPVOID)
  1890.       )
  1891.       return FALSE;
  1892.    return TRUE;
  1893. }                                       /* End of InitializeSpinbutton  */
  1894.  
  1895.  
  1896.  
  1897. static CHAR  pszNoteBookText[512];
  1898. static CHAR  pszStatusLine1[64];
  1899. static CHAR  pszStatusLine2[64];
  1900. static CHAR  pszStatusLine3[64];
  1901. static CHAR  pszTab1Ma[64];
  1902. static CHAR  pszTab1Mi1[64];
  1903. static CHAR  pszTab1Mi2[64];
  1904. static CHAR  pszTab2Ma[64];
  1905. static CHAR  pszCatTitle[20];
  1906. VOID LoadBookStrings(ULONG Cp)
  1907. {
  1908.    LONG Offset = ARA_OFF;
  1909.  
  1910.    WinLoadString(hab, NULLHANDLE, Offset+IDS_BOOK_PAGE2, 511,  pszNoteBookText);
  1911.    WinLoadString(hab, NULLHANDLE, Offset+IDS_BOOK_STL1,  63,   pszStatusLine1);
  1912.    WinLoadString(hab, NULLHANDLE, Offset+IDS_BOOK_STL2,  63,   pszStatusLine2);
  1913.    WinLoadString(hab, NULLHANDLE, Offset+IDS_BOOK_STL3,   63,  pszStatusLine3);
  1914.    WinLoadString(hab, NULLHANDLE, Offset+IDS_BOOK_TAB1MA, 63,  pszTab1Ma);
  1915.    WinLoadString(hab, NULLHANDLE, Offset+IDS_BOOK_TAB1MI1,63,  pszTab1Mi1);
  1916.    WinLoadString(hab, NULLHANDLE, Offset+IDS_BOOK_TAB1MI2,63,  pszTab1Mi2);
  1917.    WinLoadString(hab, NULLHANDLE, Offset+IDS_BOOK_TAB2MA, 63,  pszTab2Ma);
  1918.    WinLoadString(hab, NULLHANDLE, Offset+IDS_BOOK_TITLE , 19,  pszCatTitle);
  1919.  
  1920. }
  1921.  
  1922. /*********************************************************************
  1923.  *  Name : InitializeNotebook
  1924.  *
  1925.  *  Description : Set the intital pages for a notebook control.
  1926.  *
  1927.  *  Concepts : Called each time a demo NoteBook Control is
  1928.  *             initialized Sends a BKM_INSERTPAGE message to the
  1929.  *             notebook control to insert the first page into the
  1930.  *             control.  Sets the status line text for the first page
  1931.  *             by sending a BKM_SETSTATUSLINETEXT message.  Creates a
  1932.  *             window containing a bitmap and associates the whidow
  1933.  *             with the notebook by sending a BKM_SETPAGEWINDOWHWND
  1934.  *             message.  Repeats these steps with the execption of
  1935.  *             createing a MLE for use in the second notebook page.
  1936.  *
  1937.  *  API's : WinSendDlgItemMsg
  1938.  *          WinCreateWindow
  1939.  *          WinSendMsg
  1940.  *
  1941.  *  Parameters :  hwnd - Handle of the Notebook dialog
  1942.  *
  1943.  *  Returns: TRUE if The NoteBook is initialized successfully, FALSE otherwise
  1944.  *
  1945.  ****************************************************************/
  1946. BOOL InitializeNoteBook(HWND hwnd)
  1947. {
  1948.    HWND hwndPage;
  1949.    ULONG ulPageId;
  1950.    ULONG ipt = 0;
  1951.    CHAR pszMleBuffer[512];
  1952.    ULONG ChildId;
  1953.    USHORT usWidth, usHeight;
  1954.    ULONG myMR;
  1955.  
  1956.    BD_ATTR_MASK AttrMask;
  1957.  
  1958.    BOOKPAGEINFO     PageInfo;
  1959.    BOOKPAGEBIDIINFO bpBidiInfo;
  1960. /*
  1961.    {"Applications written for the Presentation Manager have full\
  1962.     access to the complete set of user interface tools: menus,\
  1963.     icons, scroll bars, etc., and often present a WYSIWYG\
  1964.     (what-you-see-is-what-you-get) view of their data.\
  1965.     Presentation Manager programs often make extensive use\
  1966.     of a mouse and display, and they have access to all the\
  1967.     32-bit features of version 2.0."};
  1968. */
  1969.    ULONG             Cp = Bidi_QueryCp();
  1970.    LoadBookStrings(Cp);
  1971.  
  1972.    ChildId = IDC_NOTEBOOK;
  1973.  
  1974. //BIDI
  1975. //
  1976. // Sets the notebook window to be RtL with Visual/RtL text.
  1977. //
  1978.    WinSetLangInfo(WinWindowFromID(hwnd,ChildId),
  1979.             LI_BD_WND_ATTR,
  1980.             (BDA_INIT              |
  1981.              BDA_WND_ORIENT_RTL    |
  1982.              BDA_TEXT_ORIENT_RTL   |
  1983.              BDA_TEXTTYPE_VISUAL   ),
  1984.              BDAM_ALL, 0L, 0L);
  1985.    /*
  1986.     * Insert the first page.
  1987.     */
  1988.    ulPageId = (LONG)WinSendDlgItemMsg(hwnd, ChildId,
  1989.         BKM_INSERTPAGE, NULL,
  1990.         MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR |
  1991.         BKA_MINOR), BKA_LAST));
  1992.  
  1993.    if ( !ulPageId)
  1994.      return FALSE;
  1995.  
  1996.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  1997.         BKM_SETSTATUSLINETEXT, MPFROMLONG(ulPageId),
  1998.       /*  MPFROMP("Page 1 of 3"))) */
  1999.        MPFROMP(pszStatusLine1)))
  2000.      return FALSE;
  2001.  
  2002.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2003.         BKM_SETTABTEXT, MPFROMLONG(ulPageId),
  2004.         MPFROMP("pszTab1Ma")))
  2005.      return FALSE;
  2006.  
  2007. //BIDI
  2008. // Initializes the bidi attributes of the minor tab.
  2009. // and points to it from the BookPageInfo.
  2010. //
  2011.    memset (&bpBidiInfo,0, sizeof(bpBidiInfo));
  2012.    memset (&PageInfo  ,0, sizeof(PageInfo));
  2013.    bpBidiInfo.bamMinorTab.ulBdAttr = BDA_TEXT_ORIENT_RTL |
  2014.                                      BDA_TEXTTYPE_VISUAL |
  2015.                                      BDA_INIT;
  2016.    bpBidiInfo.bamMinorTab.ulBdMask = BDAM_ALL;
  2017.  
  2018.    PageInfo.cb          = sizeof(PageInfo);
  2019.    PageInfo.fl          = BFA_MINORTABTEXT | BFA_BIDIINFO;
  2020.    PageInfo.cbMinorTab  = strlen(pszTab1Mi1);
  2021.    PageInfo.pszMinorTab = pszTab1Mi1;
  2022.    PageInfo.pBidiInfo   = (PVOID) &bpBidiInfo;
  2023.  
  2024.  
  2025.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2026.         BKM_SETPAGEINFO, MPFROMLONG(ulPageId), MPFROMP(&PageInfo)))
  2027.       return FALSE;
  2028.  
  2029.    hwndPage =
  2030.    WinCreateWindow(               /* parent-window handle                    */
  2031.       hwnd,                       /* pointer to registered class name        */
  2032.       WC_STATIC,                  /* pointer to window text                  */
  2033.       "#6",                       /* window style                            */
  2034.       WS_VISIBLE | SS_BITMAP,     /* horizontal position of window           */
  2035.       0,                          /* vertical position of window             */
  2036.       0,                          /* window width                            */
  2037.       0,                          /* window height                           */
  2038.       0,                          /* owner-window handle                     */
  2039.       NULLHANDLE,                 /* handle to sibling window                */
  2040.       HWND_TOP,                   /* window identifier                       */
  2041.       0,                          /* pointer to buffer                       */
  2042.       NULL,                       /* pointer to structure with pres. params. */
  2043.       NULL);
  2044. //BIDI
  2045. //
  2046. // Sets the first page window to be RtL with Visual/RtL text.
  2047. //
  2048.    WinSetLangInfo(hwndPage,
  2049.             LI_BD_WND_ATTR,
  2050.             (BDA_INIT              |
  2051.              BDA_WND_ORIENT_RTL    |
  2052.              BDA_TEXT_ORIENT_RTL   |
  2053.              BDA_TEXTTYPE_VISUAL   ),
  2054.             BDAM_ALL, 0L, 0L);
  2055.  
  2056.    if (!hwndPage)
  2057.      return FALSE;
  2058.  
  2059.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2060.          BKM_SETPAGEWINDOWHWND, MPFROMLONG(ulPageId),
  2061.          MPFROMHWND(hwndPage)))
  2062.      return FALSE;
  2063.  
  2064.    /*
  2065.     * Insert the second page.
  2066.     */
  2067.     ulPageId = (LONG)WinSendDlgItemMsg(hwnd, ChildId,
  2068.          BKM_INSERTPAGE, NULL,
  2069.          MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR),
  2070.          BKA_LAST));
  2071.  
  2072.    if (!ulPageId)
  2073.      return FALSE;
  2074.  
  2075.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2076.          BKM_SETSTATUSLINETEXT, MPFROMLONG(ulPageId),
  2077.         /* MPFROMP("Page 2 of 3"))) */
  2078.        MPFROMP(pszStatusLine2)))
  2079.      return FALSE;
  2080.  
  2081.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2082.         BKM_SETTABTEXT, MPFROMLONG(ulPageId),
  2083.         MPFROMP("pszTab1Mi2")))
  2084.      return FALSE;
  2085.  
  2086.    AttrMask.ulBdAttr = BDA_TEXTTYPE_VISUAL | BDA_TEXT_ORIENT_RTL | BDA_INIT ;
  2087.    AttrMask.ulBdMask = BDAM_ALL;
  2088.  
  2089.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2090.         BKM_SETTABTEXTBIDIATTR, MPFROMLONG(ulPageId),
  2091.         MPFROMP(&AttrMask)))
  2092.    return FALSE;
  2093.  
  2094.  
  2095.    hwndPage =
  2096.    WinCreateWindow(               /* parent-window handle                    */
  2097.       hwnd,                       /* pointer to registered class name        */
  2098.       WC_STATIC,                  /* pointer to window text                  */
  2099.       "#7",                       /* window style                            */
  2100.       WS_VISIBLE | SS_ICON,       /* horizontal position of window           */
  2101.       0,                          /* vertical position of window             */
  2102.       0,                          /* window width                            */
  2103.       0,                          /* window height                           */
  2104.       0,                          /* owner-window handle                     */
  2105.       NULLHANDLE,                 /* handle to sibling window                */
  2106.       HWND_TOP,                   /* window identifier                       */
  2107.       0,                          /* pointer to buffer                       */
  2108.       NULL,                       /* pointer to structure with pres. params. */
  2109.       NULL);
  2110. //BIDI
  2111. //
  2112. // Sets the second page window to be RtL with Visual/RtL text.
  2113. //
  2114.    WinSetLangInfo(hwndPage,
  2115.             LI_BD_WND_ATTR,
  2116.             (BDA_INIT              |
  2117.              BDA_WND_ORIENT_RTL    |
  2118.              BDA_TEXT_ORIENT_RTL   |
  2119.              BDA_TEXTTYPE_VISUAL   ),
  2120.             BDAM_ALL, 0L, 0L);
  2121.  
  2122.    if (!hwndPage)
  2123.      return FALSE;
  2124.  
  2125.    if( !WinSendDlgItemMsg(hwnd, ChildId,
  2126.          BKM_SETPAGEWINDOWHWND, MPFROMLONG(ulPageId),
  2127.          MPFROMHWND(hwndPage)))
  2128.      return FALSE;
  2129.  
  2130.    /*
  2131.     * Insert the third page.
  2132.     */
  2133.     ulPageId = (LONG)WinSendDlgItemMsg(hwnd, ChildId,
  2134.          BKM_INSERTPAGE, NULL,
  2135.          MPFROM2SHORT((BKA_STATUSTEXTON | BKA_AUTOPAGESIZE | BKA_MAJOR),
  2136.          BKA_LAST));
  2137.  
  2138.    if (!ulPageId)
  2139.      return FALSE;
  2140.  
  2141.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2142.          BKM_SETSTATUSLINETEXT, MPFROMLONG(ulPageId),
  2143.         /* MPFROMP("Page 3 of 3"))) */
  2144.        MPFROMP(pszStatusLine3)))
  2145.      return FALSE;
  2146.  
  2147.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2148.         BKM_SETTABTEXT, MPFROMLONG(ulPageId),
  2149.         MPFROMP(pszTab2Ma)))
  2150.      return FALSE;
  2151.  
  2152.  
  2153.    // The tab text will be Visual/LtR
  2154.  
  2155.    AttrMask.ulBdAttr = BDA_TEXTTYPE_VISUAL | BDA_TEXT_ORIENT_LTR | BDA_INIT ;
  2156.    AttrMask.ulBdMask = BDAM_ALL;
  2157.  
  2158.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2159.         BKM_SETTABTEXTBIDIATTR, MPFROMLONG(ulPageId),
  2160.         MPFROMP(&AttrMask)))
  2161.    return FALSE;
  2162.  
  2163.    hwndPage =
  2164.    WinCreateWindow(
  2165.       hwnd,                       /* parent-window handle                    */
  2166.       WC_MLE,                     /* pointer to registered class name        */
  2167.       NULL,                       /* pointer to window text                  */
  2168.       WS_VISIBLE | MLS_WORDWRAP | /* window style                            */
  2169.          MLS_READONLY,
  2170.       0,                          /* horizontal position of window           */
  2171.       0,                          /* vertical position of window             */
  2172.       0,                          /* window width                            */
  2173.       0,                          /* window height                           */
  2174.       NULLHANDLE,                 /* owner-window handle                     */
  2175.       HWND_TOP,                   /* handle to sibling window                */
  2176.       0,                          /* window identifier                       */
  2177.       NULL,                       /* pointer to buffer                       */
  2178.       NULL);                      /* pointer to structure with pres. params. */
  2179. //BIDI
  2180. //
  2181. // Sets the first page window to be RtL with Visual/RtL text.
  2182. // (This is for the text that is displayed in the page itself).
  2183. //
  2184.    WinSetLangInfo(hwndPage,
  2185.             LI_BD_WND_ATTR,
  2186.             (BDA_INIT              |
  2187.              BDA_WND_ORIENT_RTL    |
  2188.              BDA_TEXT_ORIENT_RTL   |
  2189.              BDA_TEXTTYPE_VISUAL   ),
  2190.             BDAM_ALL, 0L, 0L);
  2191.  
  2192.    if (!hwndPage)
  2193.      return FALSE;
  2194.  
  2195.    if ( !WinSendMsg(hwndPage, MLM_SETIMPORTEXPORT,
  2196.          MPFROMP(pszMleBuffer),
  2197.          MPFROMSHORT(sizeof(pszMleBuffer))))
  2198.      return FALSE;
  2199.  
  2200.      memset(pszMleBuffer,'\0',sizeof(pszMleBuffer));
  2201.      strcpy(pszMleBuffer, pszNoteBookText);
  2202.  
  2203.    if ( !WinSendMsg(hwndPage, MLM_IMPORT, &ipt,
  2204.          MPFROMSHORT(sizeof(pszMleBuffer))))
  2205.      return FALSE;
  2206.  
  2207.    if( !WinSendDlgItemMsg(hwnd, ChildId,
  2208.          BKM_SETPAGEWINDOWHWND, MPFROMLONG(ulPageId),
  2209.          MPFROMHWND(hwndPage)))
  2210.      return FALSE;
  2211.  
  2212.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2213.         BKM_SETDIMENSIONS,
  2214.         MPFROM2SHORT(TAB_WIDTH,TAB_HEIGHT),
  2215.         MPFROMSHORT(BKA_MAJORTAB)))
  2216.      return FALSE;
  2217.  
  2218.    if ( !WinSendDlgItemMsg(hwnd, ChildId,
  2219.         BKM_SETDIMENSIONS,
  2220.         MPFROM2SHORT(TAB_WIDTH,TAB_HEIGHT),
  2221.         MPFROMSHORT(BKA_MINORTAB)))
  2222.      return FALSE;
  2223.  
  2224.    return TRUE;
  2225. }                                       /* End of InitializeNotebook    */
  2226.  
  2227. struct _IDS_SZ
  2228. {
  2229.    ULONG ids;
  2230.    PSZ   psz;
  2231. }  ids_sz[] =
  2232.  
  2233.    {
  2234.       {IDS_CNR_TITLE,         pszCnrTitleNational},
  2235.       {IDS_CNR_COLUMNTITLE,   pszColumnText2},
  2236.       {IDS_CNR_PICTURE,       pszColumnText1National},
  2237.       {IDS_CNR_TOWER,         pszTowerNational},
  2238.       {IDS_CNR_WATERFALL,     pszWaterfallNational},
  2239.       {IDS_CNR_GLOBE,         pszGlobeNational},
  2240.       {IDS_CNR_KEY,           pszKeyNational}
  2241.    };
  2242.  
  2243. VOID LoadCnrStrings(ULONG Cp)
  2244. {
  2245.    LONG ul, idx ;
  2246.    ULONG    Offset = ARA_OFF;
  2247.    for (ul = 0; ul < sizeof (ids_sz) / sizeof (ids_sz[0]); ul++)
  2248.    {
  2249.      idx = ids_sz[ul].ids + Offset;
  2250.      WinLoadString(hab, NULLHANDLE, idx, 63L, ids_sz[ul].psz);
  2251.    }
  2252.  
  2253.    return;
  2254. }
  2255.  
  2256. /*********************************************************************
  2257.  *  Name : InitializeContainer
  2258.  *
  2259.  *  Description : Initialize and insert a record into the container.
  2260.  *
  2261.  *
  2262.  *  Concepts : Called each time a demo Container Control is initialized.
  2263.  *             Allocates and inserts a user record into a container.
  2264.  *             Allocates and inserst  details view information.
  2265.  *             Sets the containers info.
  2266.  *
  2267.  *  API's : WinLoadPointer
  2268.  *          WinSendDlgItemMsg
  2269.  *
  2270.  *  Parameters : hwnd - Handle of the container dialog.
  2271.  *
  2272.  *  Returns: TRUE if The Container is initialized successfully, FALSE otherwise
  2273.  *
  2274.  ****************************************************************/
  2275. BOOL InitializeContainer(HWND hwnd)
  2276. {
  2277.  
  2278.   USHORT            nRecords = 4 /*1*/;
  2279.   HPOINTER          hptrTower, hptrWaterfall, hptrGlobe, hptrKey;
  2280.   ULONG             cbRecordData;
  2281.   ULONG             Cp = Bidi_QueryCp();
  2282.  
  2283.   LoadCnrStrings(Cp);
  2284.  
  2285. //BIDI
  2286. //
  2287. // Sets the container window to RtL window orientation, and Implicit text
  2288. // with contextual text orientation.
  2289. //
  2290.   WinSetLangInfo(WinWindowFromID(hwnd,IDC_CONTAINER),
  2291.             LI_BD_WND_ATTR,
  2292.             (BDA_WND_ORIENT_RTL      |
  2293.              BDA_TEXTTYPE_IMPLICIT   |
  2294.              BDA_TEXT_ORIENT_CONTEXT |
  2295.              BDA_INIT),
  2296.             BDAM_ALL, 0L, 0L);
  2297.  
  2298. /*
  2299.   hptr = WinLoadPointer(HWND_DESKTOP, 0, IDR_MAIN);
  2300. */
  2301.   hptrTower = WinLoadPointer(HWND_DESKTOP, 0, IDR_TOWER);
  2302.   hptrWaterfall = WinLoadPointer(HWND_DESKTOP, 0, IDR_WATERFALL);
  2303.   hptrGlobe = WinLoadPointer(HWND_DESKTOP, 0, IDR_GLOBE);
  2304.   hptrKey = WinLoadPointer(HWND_DESKTOP, 0, IDR_KEY);
  2305.  
  2306.   cbRecordData = (LONG) (sizeof(USERRECORD) - sizeof(RECORDCORE));
  2307.   pUserRecord = WinSendDlgItemMsg(hwnd,IDC_CONTAINER,
  2308.                    CM_ALLOCRECORD, MPFROMLONG(cbRecordData) ,
  2309.                    MPFROMSHORT(nRecords));
  2310.   pStartRecord = pUserRecord;
  2311.  
  2312.   pUserRecord->recordCore.cb = sizeof(RECORDCORE);              /*RBS*/
  2313.   pUserRecord->recordCore.pszText = pszTowerNational;
  2314.   pUserRecord->recordCore.pszIcon = pszTowerNational;
  2315.   pUserRecord->recordCore.pszName = pszTowerNational;
  2316.   pUserRecord->recordCore.hptrIcon = hptrTower;
  2317.  
  2318. /*
  2319.   pUserRecord->date.day = 11;
  2320.   pUserRecord->date.month = 11;
  2321.   pUserRecord->date.year = 11;
  2322.   pUserRecord->time.seconds    = 12;
  2323.   pUserRecord->time.minutes    = 12;
  2324.   pUserRecord->time.hours      = 12;
  2325.   pUserRecord->recordData = (PSZ)pszSampleData;
  2326. */
  2327.   pUserRecord->EnglishName = pszTowerEnglish;
  2328.   pUserRecord->NationalName = pszTowerNational;
  2329.  
  2330.   pUserRecord = (PUSERRECORD) pUserRecord->recordCore.preccNextRecord;
  2331.   pUserRecord->recordCore.cb = sizeof(RECORDCORE);              /*RBS*/
  2332.   pUserRecord->recordCore.pszText = pszWaterfallNational;
  2333.   pUserRecord->recordCore.pszIcon = pszWaterfallNational;
  2334.   pUserRecord->recordCore.pszName = pszWaterfallNational;
  2335.   pUserRecord->recordCore.hptrIcon = hptrWaterfall;
  2336.  
  2337. /*
  2338.   pUserRecord->date.day = 11;
  2339.   pUserRecord->date.month = 11;
  2340.   pUserRecord->date.year = 11;
  2341.   pUserRecord->time.seconds    = 12;
  2342.   pUserRecord->time.minutes    = 12;
  2343.   pUserRecord->time.hours      = 12;
  2344.   pUserRecord->recordData = (PSZ)pszSampleData;
  2345. */
  2346.   pUserRecord->EnglishName = pszWaterfallEnglish;
  2347.   pUserRecord->NationalName = pszWaterfallNational;
  2348.  
  2349.   pUserRecord = (PUSERRECORD) pUserRecord->recordCore.preccNextRecord;
  2350.   pUserRecord->recordCore.cb = sizeof(RECORDCORE);              /*RBS*/
  2351.   pUserRecord->recordCore.pszText = pszGlobeNational;
  2352.   pUserRecord->recordCore.pszIcon = pszGlobeNational;
  2353.   pUserRecord->recordCore.pszName = pszGlobeNational;
  2354.   pUserRecord->recordCore.hptrIcon = hptrGlobe;
  2355.  
  2356. /*
  2357.   pUserRecord->date.day = 11;
  2358.   pUserRecord->date.month = 11;
  2359.   pUserRecord->date.year = 11;
  2360.   pUserRecord->time.seconds    = 12;
  2361.   pUserRecord->time.minutes    = 12;
  2362.   pUserRecord->time.hours      = 12;
  2363.   pUserRecord->recordData = (PSZ)pszSampleData;
  2364. */
  2365.   pUserRecord->EnglishName = pszGlobeEnglish;
  2366.   pUserRecord->NationalName = pszGlobeNational;
  2367.  
  2368.   pUserRecord = (PUSERRECORD) pUserRecord->recordCore.preccNextRecord;
  2369.   pUserRecord->recordCore.cb = sizeof(RECORDCORE);              /*RBS*/
  2370.   pUserRecord->recordCore.pszText = pszKeyNational;
  2371.   pUserRecord->recordCore.pszIcon = pszKeyNational;
  2372.   pUserRecord->recordCore.pszName = pszKeyNational;
  2373.   pUserRecord->recordCore.hptrIcon = hptrKey;
  2374.  
  2375. /*
  2376.   pUserRecord->date.day = 11;
  2377.   pUserRecord->date.month = 11;
  2378.   pUserRecord->date.year = 11;
  2379.   pUserRecord->time.seconds    = 12;
  2380.   pUserRecord->time.minutes    = 12;
  2381.   pUserRecord->time.hours      = 12;
  2382.   pUserRecord->recordData = (PSZ)pszSampleData;
  2383. */
  2384.   pUserRecord->EnglishName = pszKeyEnglish;
  2385.   pUserRecord->NationalName = pszKeyNational;
  2386.  
  2387.  
  2388.   recordInsert.cb = sizeof(RECORDINSERT);                   /*RBS*/
  2389.   recordInsert.pRecordParent= NULL;
  2390.   recordInsert.pRecordOrder = (PRECORDCORE)CMA_END;
  2391.   recordInsert.zOrder = (USHORT)CMA_TOP;
  2392.   recordInsert.cRecordsInsert=(USHORT)4 /*1*/;
  2393.   recordInsert.fInvalidateRecord = TRUE;
  2394.  
  2395.   WinSendDlgItemMsg(hwnd,IDC_CONTAINER, CM_INSERTRECORD,
  2396.                    (PRECORDCORE)pStartRecord, &recordInsert);
  2397.  
  2398.   pFieldInfo = WinSendDlgItemMsg(hwnd, IDC_CONTAINER,
  2399.                         CM_ALLOCDETAILFIELDINFO,MPFROMLONG(3), NULL);
  2400.  
  2401.   firstFieldInfo = pFieldInfo;
  2402.  
  2403.   pFieldInfo->cb = sizeof(FIELDINFO);                       /*RBS*/
  2404. /*
  2405.   pFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_CENTER |
  2406.                          CFA_SEPARATOR;
  2407. */
  2408.   pFieldInfo->flData = CFA_BITMAPORICON | CFA_HORZSEPARATOR | CFA_CENTER |
  2409.                          CFA_SEPARATOR;
  2410.   pFieldInfo->flTitle = CFA_CENTER;
  2411.   pFieldInfo->pTitleData = (PVOID) pszColumnText1National;
  2412.   pFieldInfo->offStruct = FIELDOFFSET(RECORDCORE, hptrIcon);
  2413.   pFieldInfo = pFieldInfo->pNextFieldInfo;
  2414.  
  2415.   pFieldInfo->cb = sizeof(FIELDINFO);                       /*RBS*/
  2416. /*
  2417.   pFieldInfo->flData = CFA_DATE | CFA_HORZSEPARATOR | CFA_CENTER |
  2418.                          CFA_SEPARATOR;
  2419. */
  2420.   pFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_RIGHT |
  2421.                          CFA_SEPARATOR;
  2422.   pFieldInfo->flTitle = CFA_CENTER;
  2423.   pFieldInfo->pTitleData =  (PVOID) pszColumnText2;
  2424.   pFieldInfo->offStruct = FIELDOFFSET(USERRECORD,NationalName);
  2425.   pFieldInfo = pFieldInfo->pNextFieldInfo;
  2426.  
  2427.   pFieldInfo->cb = sizeof(FIELDINFO);                       /*RBS*/
  2428. /*
  2429.   pFieldInfo->flData = CFA_TIME | CFA_HORZSEPARATOR | CFA_CENTER |
  2430.                          CFA_SEPARATOR;
  2431. */
  2432.   pFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_LEFT |
  2433.                          CFA_SEPARATOR;
  2434.   pFieldInfo->flTitle = CFA_CENTER;
  2435.   pFieldInfo->pTitleData = (PVOID) pszColumnText3;
  2436.   pFieldInfo->offStruct = FIELDOFFSET(USERRECORD,EnglishName);
  2437.  
  2438.  
  2439.   fieldInfoInsert.cb = (ULONG)(sizeof(FIELDINFOINSERT));    /*RBS*/
  2440.   fieldInfoInsert.pFieldInfoOrder = (PFIELDINFO)CMA_FIRST;
  2441.   fieldInfoInsert.cFieldInfoInsert = (SHORT) 3;
  2442.   fieldInfoInsert.fInvalidateFieldInfo = TRUE;              /*RBS*/
  2443.  
  2444.   pFieldInfoInsert = &fieldInfoInsert;
  2445.  
  2446.   WinSendDlgItemMsg(hwnd,IDC_CONTAINER, CM_INSERTDETAILFIELDINFO,
  2447.                     MPFROMP(firstFieldInfo),
  2448.                     MPFROMP(pFieldInfoInsert));
  2449. //BIDI
  2450. //
  2451. // Set the fields (columns) bidi attributes.
  2452. //
  2453.   {
  2454.      BD_ATTR_MASK attr_mask;
  2455.      attr_mask.ulBdAttr = BDA_INIT                |
  2456.                           BDA_WND_ORIENT_RTL      |
  2457.                           BDA_TEXT_ORIENT_CONTEXT |
  2458.                           BDA_TEXTTYPE_IMPLICIT ;
  2459.  
  2460.      attr_mask.ulBdMask = BDAM_INIT             |
  2461.                           BDAM_WND_ORIENTATION  |
  2462.                           BDAM_TEXT_ORIENTATION |
  2463.                           BDAM_TEXTTYPE ;
  2464.  
  2465.      WinSendDlgItemMsg(hwnd,IDC_CONTAINER, CM_SETFIELDBIDIATTR,
  2466.                         MPFROMP(firstFieldInfo),
  2467.                         MPFROMP(&attr_mask));
  2468.      WinSendDlgItemMsg(hwnd,IDC_CONTAINER, CM_SETFIELDBIDIATTR,
  2469.                         MPFROMP(firstFieldInfo->pNextFieldInfo),
  2470.                         MPFROMP(&attr_mask));
  2471.  
  2472.      attr_mask.ulBdAttr = BDA_INIT                |
  2473.                           BDA_WND_ORIENT_LTR      |
  2474.                           BDA_TEXT_ORIENT_CONTEXT |
  2475.                           BDA_TEXTTYPE_IMPLICIT ;
  2476.  
  2477.      attr_mask.ulBdMask = BDAM_INIT             |
  2478.                           BDAM_WND_ORIENTATION  |
  2479.                           BDAM_TEXT_ORIENTATION |
  2480.                           BDAM_TEXTTYPE ;
  2481.      WinSendDlgItemMsg(hwnd,IDC_CONTAINER, CM_SETFIELDBIDIATTR,
  2482.                     MPFROMP((firstFieldInfo->pNextFieldInfo)->pNextFieldInfo),
  2483.                         MPFROMP(&attr_mask));
  2484.   }
  2485.  
  2486.   WinSendDlgItemMsg(hwnd,IDC_CONTAINER,CM_SETCNRINFO,&cnrinfo,
  2487.                      MPFROMLONG(CMA_FLWINDOWATTR | CMA_CNRTITLE));
  2488.  
  2489. return TRUE;
  2490. }                                       /* End of InitializeContainer    */
  2491.  
  2492. /***********************************************************
  2493.  * Name         : SetSysMenu
  2494.  *
  2495.  * Description  : Procedure to remove unselectable items from
  2496.  *                the window system menu.
  2497.  *
  2498.  * Concepts     : This routine determines the number of items
  2499.  *                in the system menu, loops through those
  2500.  *                items removing disabled menu items and menu
  2501.  *                seperators.
  2502.  *
  2503.  * API's        : WinMessageBox
  2504.  *
  2505.  * Parameters   : None
  2506.  *
  2507.  * Return       : None
  2508.  *
  2509.  **************************************************************/
  2510. VOID SetSysMenu(HWND hwndDlg)
  2511. {
  2512.   SHORT sMenuItems;
  2513.   USHORT usItemid;
  2514.   MENUITEM menuItem;
  2515.   HWND  hwndSubMenu;
  2516.  
  2517.   /* Determine the definition of the system menu */
  2518.   memset( &menuItem, 0, sizeof(menuItem));
  2519.   WinSendDlgItemMsg(hwndDlg,FID_SYSMENU, MM_QUERYITEM,
  2520.                     MPFROM2SHORT((SHORT)SC_SYSMENU,FALSE),
  2521.                     MPFROMP(&menuItem));
  2522.  
  2523.   hwndSubMenu = menuItem.hwndSubMenu;
  2524.  
  2525.   /* Find the number of items in the in the submenu */
  2526.   sMenuItems = (SHORT)WinSendMsg(hwndSubMenu,
  2527.                                  MM_QUERYITEMCOUNT,NULL,NULL);
  2528.   /*
  2529.    * Loop through the submenu items and remove disabled
  2530.    * menu items and menu separators.
  2531.    */
  2532.   for (sMenuItems - 1 ; sMenuItems >= 0 ;sMenuItems-- )
  2533.   {
  2534.     /* Find the item ID for the current position. */
  2535.     usItemid = (USHORT)WinSendMsg(hwndSubMenu,MM_ITEMIDFROMPOSITION,
  2536.                          MPFROMSHORT(sMenuItems), NULL);
  2537.  
  2538.     /* Query the definition of the current item*/
  2539.     WinSendMsg(hwndSubMenu, MM_QUERYITEM,
  2540.                MPFROM2SHORT(usItemid,FALSE), MPFROMP(&menuItem));
  2541.  
  2542.    /*
  2543.     * If the menu item is disabled or the item has a style
  2544.     * of MIS_SEPARATOR - delete it.
  2545.     */
  2546.     if ((BOOL)(WinSendMsg(hwndSubMenu, MM_QUERYITEMATTR,
  2547.           MPFROM2SHORT(usItemid,FALSE), (MPARAM)MIA_DISABLED)) ||
  2548.           (menuItem.afStyle & MIS_SEPARATOR))
  2549.     {
  2550.       WinSendMsg(hwndSubMenu, MM_DELETEITEM,
  2551.                 MPFROM2SHORT(usItemid,FALSE),NULL);
  2552.     }
  2553.   }
  2554. }                                       /* End of SetSysMenu()           */
  2555.  
  2556.  
  2557.  
  2558. /***********************************************************
  2559.  * Name         : ReportTestResult
  2560.  *
  2561.  * Description  : Reports to the user the result of a test.
  2562.  *
  2563.  **************************************************************/
  2564. VOID ReportTestResult(HWND hwnd, BOOL fResult)
  2565. {
  2566.    MessageBox ( hwnd,
  2567.                 fResult ? IDMSG_TEST_SUCCESSFUL : IDMSG_TEST_ERROR,
  2568.                 MB_OK | MB_MOVEABLE,
  2569.                 !fResult
  2570.               );
  2571.    return;
  2572. }  /*ReportTestResult() */
  2573.  
  2574.  
  2575.  
  2576.