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