home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lstbx2.zip / lbcc.zip / LBCC.C < prev    next >
C/C++ Source or Header  |  1994-04-22  |  34KB  |  919 lines

  1. #pragma    title("Super List Box DLL  --  Version 2.10 -- (LBCC.C)")
  2. #pragma    subtitle("   Prominare Designer - Interface Definitions")
  3.     
  4. #define    INCL_DOS           /* Include OS/2 DOS Kernal        */
  5. #define    INCL_GPI           /* Include OS/2 PM GPI Interface    */
  6. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  7. #define    INCL_NLS           /* Include OS/2 PM NLS Support    */
  8.  
  9. #if defined(__IBMC__)
  10.  
  11. #pragma    info(noext)
  12.  
  13. #endif
  14.  
  15. #include <os2.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19.  
  20. #include <ccls32.h>
  21.  
  22. #include "LBCC.h"
  23. #include "listbox.h"
  24.  
  25. /* This    module contains    an example installable control that can    be used    */
  26. /* by Prominare    Designer to include within applications    where        */
  27. /* additional facilities are provided that are not found within    the    */
  28. /* default controls of OS/2 Presentation Manager.            */
  29. /*                                    */
  30. /* For complete    details    regarding the Custom Control Library        */
  31. /* Specification (CCLS), Version 2.1c, consult Section 2 in the        */
  32. /* Prominare Development System    Programming Guide.            */
  33. /*                                    */
  34. /* The DLL is created using the    following options in Prominare Builder:    */
  35. /*                                    */
  36. /* Option           Value                        */
  37. /* ------           -----                        */
  38. /* Op Sys           OS/2 PM Static DLL                */
  39. /* Optimization           Maximize                        */
  40. /* Compile Type           Subsystem                    */
  41. /* CPU               80386                        */
  42. /* Warning Level       3                        */
  43. /*                                    */
  44. /* Equivalent command line invocation:                    */
  45. /*                                    */
  46. /*     Icc -G3e- -O+ -Rn -W3 -C    LBCC.C                    */
  47.  
  48. /* Filename:   LBCC.C                            */
  49.  
  50. /*  Version:   2.10                            */
  51. /*  Created:   1994-04-22                        */
  52. /*  Revised:   1994-04-22                        */
  53.  
  54. /* Routines:   BOOL EXPENTRY LBCCRegister(HAB hAB);            */
  55. /*           BOOL EXPENTRY LBCCQuery(PUSERINFO32 pUserInfo);        */
  56. /*           MRESULT EXPENTRY    LBCCStyles(HWND    hWnd, ULONG msg,    */
  57. /*                       MPARAM mp1, MPARAM mp2);    */
  58. /*           MRESULT EXPENTRY    LBCCAnalystStyles(HWND hWnd,        */
  59. /*                          ULONG    msg,        */
  60. /*                          MPARAM mp1,        */
  61. /*                          MPARAM mp2);        */
  62.  
  63.  
  64. /* Copyright ╕ 1989-1994  Prominare Inc.  All Rights Reserved.        */
  65.  
  66. /* --------------------------------------------------------------------    */
  67.  
  68. /************************************************************************/
  69. /************************************************************************/
  70. /*               DISCLAIMER OF WARRANTIES.            */
  71. /************************************************************************/
  72. /************************************************************************/
  73. /*     The following [enclosed]    code is    library    code created by        */
  74. /*     Prominare Inc.  This library code is  provided to you solely    */
  75. /*     for the purpose of assisting you    in the development of your    */
  76. /*     applications.  The code is provided "AS IS", without        */
  77. /*     warranty    of any kind.  Prominare    Inc. shall not be liable    */
  78. /*     for any damages arising out of your use of the library code,    */
  79. /*     even if they have been advised of the possibility of such    */
  80. /*     damages.                                */
  81. /************************************************************************/
  82. /************************************************************************/
  83.  
  84. BOOL    EXPENTRY LBCCRegister(HAB hAB);
  85. BOOL    EXPENTRY LBCCQuery(PUSERINFO32 pUserInfo);
  86. MRESULT    EXPENTRY LBCCStyles(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2);
  87. MRESULT    EXPENTRY LBCCAnalystStyles(HWND    hWnd, ULONG msg, MPARAM    mp1, MPARAM mp2);
  88.  
  89. #pragma    subtitle("   Super List Box DLL - Control Initialization Function")
  90. #pragma    page ( )
  91.  
  92. /* --- LBCCRegister ------------------------------------ [ Public ] ---    */
  93. /*                                    */
  94. /*     This function is    used to    register the installable control class    */
  95. /*     with OS/2 Presentation Manager.    The registration must use the    */
  96. /*     USER_CWINDOWWORDS to reserve memory for the control to allow for    */
  97. /*     proper usage by Prominare Designer and for use by the control    */
  98. /*     dialog and window procedures.  The information for the control    */
  99. /*     containing the style, presentation parameters and control data    */
  100. /*     is pointed to by    a pointer that can be referenced by the        */
  101. /*     control's dialog and window procedure as required.  The memory   */
  102. /*     for the structure is allocated and controlled through Prominare    */
  103. /*     Designer.   The control can reserve more    memory for its use    */
  104. /*     by adding the memory required to    that of    the USER_CWINDOWWORDS    */
  105. /*     constant.                            */
  106. /*                                    */
  107. /*     Upon Entry:                            */
  108. /*                                    */
  109. /*     HAB hAB;    = Application Anchor Block Handle            */
  110. /*                                    */
  111. /*     Upon Exit:                            */
  112. /*                                    */
  113. /*     LBCCRegister =  TRUE : Class Registration Successful        */
  114. /*            = FALSE : Class Registration Failed            */
  115. /*                                    */
  116. /* --------------------------------------------------------------------    */
  117.  
  118. BOOL EXPENTRY LBCCRegister(HAB hAB)
  119.  
  120. {
  121.                /* Register the control class with OS/2        */
  122.                /* Presentation Manager and return registration    */
  123.                /* result                    */
  124.  
  125. return(fRegisterListBox(hAB));
  126.  
  127. }
  128. #pragma    subtitle("   Super List Box DLL - Query Control Information Function")
  129. #pragma    page ( )
  130.  
  131. /* --- LBCCQuery --------------------------------------- [ Public ] ---    */
  132. /*                                    */
  133. /*     This function is    used to    return to the caller information    */
  134. /*     regarding the installable control and its capabilities.    The    */
  135. /*     function    should return a    true value otherwise Prominare        */
  136. /*     Designer    will not register the control as being usable.        */
  137. /*                                    */
  138. /*     Upon Entry:                            */
  139. /*                                    */
  140. /*     PUSERINFO32 pUserInfo; =    User Information Pointer        */
  141. /*                                    */
  142. /*     Upon Exit:                            */
  143. /*                                    */
  144. /*     LBCCQuery =  TRUE : User    Information Being Returned        */
  145. /*         = FALSE : No User Information Available        */
  146. /*                                    */
  147. /* --------------------------------------------------------------------    */
  148.  
  149. BOOL EXPENTRY LBCCQuery(PUSERINFO32 pUserInfo)
  150.  
  151. {
  152.                /* Complete the User Information    structure    */
  153.                /* passed to the    function by Prominare Designer    */
  154.  
  155.                /* Complete the version and number of control    */
  156.                /* types.  In Version 2.1c of CCSL, only    one    */
  157.                /* control type is used.                */
  158. pUserInfo->ulMajor = 2UL;
  159. pUserInfo->ulMinor = 0UL;
  160. pUserInfo->cTypes = 1UL;
  161.                /* Complete the author and control classname    */
  162.  
  163. strcpy(pUserInfo->szAuthor,    "Prominare Inc.");
  164. strcpy(pUserInfo->szClassname, "ListBoxWindow");
  165. strcpy(pUserInfo->szName,      "LBCC");
  166.  
  167.                /* Complete the default size and    style of the    */
  168.                /* first    user control type            */
  169.  
  170. pUserInfo->utDefined[0].cx         = 48L;
  171. pUserInfo->utDefined[0].cy         = 32L;
  172. pUserInfo->utDefined[0].flStyle         = WS_VISIBLE;
  173.  
  174.                /* Set the maximum amount of text control can    */
  175.                /* accept including NULL    termination byte    */
  176.  
  177. pUserInfo->utDefined[0].cMaxText     = 0UL;
  178.  
  179.                /* Save the style's dialogue ID, type, control   */
  180.                /* data size and    count of style masks        */
  181.  
  182. pUserInfo->utDefined[0].idDlg         = DLG_CTRLUSER;
  183. pUserInfo->utDefined[0].idDlgAnalyst = DLG_CTRLUSER;
  184. pUserInfo->utDefined[0].ulType         = UTYPE_PRIVATE;
  185. pUserInfo->utDefined[0].cCtlData     = sizeof(LISTBOXCDATA);
  186. pUserInfo->utDefined[0].cMasks         = 6UL;
  187. pUserInfo->utDefined[0].flOptions    = CCLSOPT_VARICDATA | CCLSOPT_REFRESH;
  188. pUserInfo->utDefined[0].flStyleType  = STYLETYPE_BITFLAGS;
  189. pUserInfo->utDefined[0].stMasks[0].flStyleMask = LS_MULTIPLESEL;
  190. pUserInfo->utDefined[0].stMasks[0].idStyle     = IDS_LS_MULTIPLESEL;
  191. pUserInfo->utDefined[0].stMasks[1].flStyleMask = LS_OWNERDRAW;
  192. pUserInfo->utDefined[0].stMasks[1].idStyle     = IDS_LS_OWNERDRAW;
  193. pUserInfo->utDefined[0].stMasks[2].flStyleMask = LS_NOADJUSTPOS;
  194. pUserInfo->utDefined[0].stMasks[2].idStyle     = IDS_LS_NOADJUSTPOS;
  195. pUserInfo->utDefined[0].stMasks[3].flStyleMask = LS_HORZSCROLL;
  196. pUserInfo->utDefined[0].stMasks[3].idStyle     = IDS_LS_HORZSCROLL;
  197. pUserInfo->utDefined[0].stMasks[4].flStyleMask = LS_EXTENDEDSEL;
  198. pUserInfo->utDefined[0].stMasks[4].idStyle     = IDS_LS_EXTENDEDSEL;
  199. pUserInfo->utDefined[0].stMasks[5].flStyleMask = LSXS_CHECKBOX;
  200. pUserInfo->utDefined[0].stMasks[5].idStyle     = IDS_LSXS_CHECKBOX;
  201.  
  202.                /* Save the description of the control        */
  203.  
  204. strcpy(pUserInfo->utDefined[0].szDescription, "32-Bit List Box");
  205.  
  206.                /* Return the success flag back to Prominare    */
  207.                /* Designer                    */
  208. return(TRUE);
  209. }
  210. #pragma    subtitle("   Super List Box DLL - Control Styles Dialogue Procedure")
  211. #pragma    page ( )
  212.  
  213. /* --- LBCCStyles -------------------------------------- [ Public ] ---    */
  214. /*                                    */
  215. /*     This function is    used for the custom control's styles dialogue   */
  216. /*     box procedure.                            */
  217. /*                                    */
  218. /*     When the    dialogue is invoked from Prominare Designer, the    */
  219. /*     address of the user style information is    contained in message    */
  220. /*     parameter 2.  The dialogue is responsible for saving the        */
  221. /*     address.     The best method to do this is to save the pointer    */
  222. /*     in the dialogue's reserved memory where it can be retrieved as   */
  223. /*     needed.                                */
  224. /*                                    */
  225. /*     Upon Entry:                            */
  226. /*                                    */
  227. /*     HWND   hWnd; = Dialog Window Handle                */
  228. /*     ULONG  msg;  = PM Message                    */
  229. /*     MPARAM mp1;  = Message Parameter    1                */
  230. /*     MPARAM mp2;  = Message Parameter    2                */
  231. /*                                    */
  232. /*     Upon Exit:                            */
  233. /*                                    */
  234. /*     LBCCStyles = Message Handling Result                */
  235. /*                                    */
  236. /* --------------------------------------------------------------------    */
  237.  
  238. MRESULT    EXPENTRY LBCCStyles(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  239.  
  240. {
  241. CHAR          szBuffer[256];       /* Buffer                */
  242. INT          cItems;           /* Items Count            */
  243. INT          cLen;           /* Text Length            */
  244. INT          cLines;           /* Lines Count            */
  245. INT          cSounds;           /* Sounds Count            */
  246. INT          cTextLen;           /* Text Length            */
  247. IPT          iptData;           /* MLE Data Start Position        */
  248. PCHAR          pch;           /* Character    String Pointer        */
  249. PCHAR          pchData;           /* Data Pointer            */
  250. PLISTBOXCDATA plbwcd;           /* List Box CTLDATA Pointer        */
  251. PUSERSTYLE32  pust;           /* User Style Pointer        */
  252. SWP          swp;           /* Screen Window Position Holder    */
  253. register INT i,    n;           /* Loop Counter            */
  254.  
  255. switch ( msg )
  256.    {
  257.                /* Perform dialogue initialization        */
  258.    case    WM_INITDLG :
  259.                /* Save the pointer to user style information    */
  260.                /* within the dialog's reserved memory           */
  261.  
  262.        WinSetWindowPtr(hWnd, QWL_USER, (PVOID)mp2);
  263.  
  264.                /* Get the pointer to the user style information    */
  265.  
  266.        if ( (pust = (PUSERSTYLE32)mp2) != NULL )
  267.        {
  268.                /* Set the text,    ID symbol and value for    the    */
  269.                /* control                    */
  270.  
  271.        WinSetDlgItemText(hWnd, EF_SYMBOL, pust->szid);
  272.        WinSetDlgItemText(hWnd, EF_SYMBOLVALUE, _ltoa((LONG)pust->id, szBuffer, 10));
  273.        plbwcd = (PLISTBOXCDATA)pust->pbCtlData;
  274.  
  275.        if (    plbwcd->vdata.lbcd1_1.cItems )
  276.            {
  277.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_SETTEXTLIMIT,
  278.                  MPFROMLONG(16384L), 0L);
  279.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_DISABLEREFRESH, 0L, 0L);
  280.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_RESETUNDO,    0L, 0L);
  281.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_FORMAT,
  282.                  MPFROMSHORT(MLFIE_NOTRANS), 0L);
  283.            for ( i = n = 0,    iptData    = 0L; i    < plbwcd->vdata.lbcd1_1.cItems;    i++ )
  284.            {
  285.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_SETIMPORTEXPORT,
  286.                      MPFROMP(szBuffer),
  287.                      MPFROMLONG(cLen = (INT)strlen(strcat(strcpy(szBuffer,
  288.                                          &plbwcd->vdata.lbcd1_1.abList[n]),
  289.                                       "\n"))));
  290.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_IMPORT, MPFROMP(&iptData),
  291.                      MPFROMLONG(cLen));
  292.            n +=    (INT)strlen(&plbwcd->vdata.lbcd1_1.abList[n]) +    1;
  293.            }
  294.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_ENABLEREFRESH, 0L,    0L);
  295.            if ( plbwcd->vdata.lbcd1_1.cSounds )
  296.            {
  297.            WinSetDlgItemText(hWnd, EF_SND1, &plbwcd->vdata.lbcd1_1.abList[n]);
  298.            if (    plbwcd->vdata.lbcd1_1.cSounds == 2 )
  299.                {
  300.                n += (INT)strlen(&plbwcd->vdata.lbcd1_1.abList[n]) + 1;
  301.                WinSetDlgItemText(hWnd, EF_SND2,    &plbwcd->vdata.lbcd1_1.abList[n]);
  302.                }
  303.            }
  304.            }
  305.                /* Set multiple selection check box if selected    */
  306.  
  307.        if (    pust->flStyle &    LS_MULTIPLESEL )
  308.            WinSendDlgItemMsg(hWnd, CB_LS_MULTIPLESEL, BM_SETCHECK,
  309.                  MPFROMSHORT(TRUE), 0L);
  310.  
  311.                /* Set Owner draw check box if selected        */
  312.  
  313.        if (    pust->flStyle &    LS_OWNERDRAW )
  314.            WinSendDlgItemMsg(hWnd, CB_LS_OWNERDRAW,    BM_SETCHECK,
  315.                  MPFROMSHORT(TRUE), 0L);
  316.  
  317.                /* Set No adjust    position check box if selected    */
  318.  
  319.        if (    pust->flStyle &    LS_NOADJUSTPOS )
  320.            WinSendDlgItemMsg(hWnd, CB_LS_NOADJUSTPOS, BM_SETCHECK,
  321.                  MPFROMSHORT(TRUE), 0L);
  322.  
  323.                /* Set Horizontal scroll    check box if selected    */
  324.  
  325.        if (    pust->flStyle &    LS_HORZSCROLL )
  326.            WinSendDlgItemMsg(hWnd, CB_LS_HORZSCROLL, BM_SETCHECK,
  327.                  MPFROMSHORT(TRUE), 0L);
  328.  
  329.                /* Set Extended selection check box if selected    */
  330.  
  331.        if (    pust->flStyle &    LS_EXTENDEDSEL )
  332.            WinSendDlgItemMsg(hWnd, CB_LS_EXTENDEDSEL, BM_SETCHECK,
  333.                  MPFROMSHORT(TRUE), 0L);
  334.  
  335.                /* Set Check box    selection check    box if selected    */
  336.  
  337.        if (    plbwcd && plbwcd->vdata.lbcd1_1.flExtStyles & LSXS_CHECKBOX )
  338.            WinSendDlgItemMsg(hWnd, CB_LSXS_CHECKBOX, BM_SETCHECK,
  339.                  MPFROMSHORT(TRUE), 0L);
  340.  
  341.        if (    pust->flStyle &    WS_VISIBLE )
  342.            WinSendDlgItemMsg(hWnd, CB_VISIBLE, BM_SETCHECK,
  343.                  MPFROMSHORT(TRUE), 0L);
  344.  
  345.        if (    pust->flStyle &    WS_GROUP )
  346.            WinSendDlgItemMsg(hWnd, CB_GROUP, BM_SETCHECK,
  347.                  MPFROMSHORT(TRUE), 0L);
  348.  
  349.        if (    pust->flStyle &    WS_DISABLED )
  350.            WinSendDlgItemMsg(hWnd, CB_DISABLED, BM_SETCHECK,
  351.                  MPFROMSHORT(TRUE), 0L);
  352.  
  353.        if (    pust->flStyle &    WS_TABSTOP )
  354.            WinSendDlgItemMsg(hWnd, CB_TABSTOP, BM_SETCHECK,
  355.                  MPFROMSHORT(TRUE), 0L);
  356.        }
  357.                /* Centre dialog    on the screen            */
  358.  
  359.        WinQueryWindowPos(hWnd, (PSWP)&swp);
  360.        WinSetWindowPos(hWnd, HWND_TOP,
  361.                (WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN) - swp.cx) /    2L,
  362.                (WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - swp.cy) /    2L,
  363.                0L, 0L, SWP_MOVE);
  364.        break;
  365.                /* Process push button selections        */
  366.    case    WM_COMMAND :
  367.        switch (    SHORT1FROMMP(mp1) )
  368.        {
  369.                /* Presentation push button selected        */
  370.  
  371.        case    DID_PRESPARAM :
  372.  
  373.                /* Get the pointer to the user style information    */
  374.  
  375.            if ( (pust = PDATA32FROMDLG(hWnd)) != NULL )
  376.  
  377.                /* Get the address of the look up function from    */
  378.                /* user style information structure and display    */
  379.                /* the dialog.  The value selected within the    */
  380.                /* dialog will be automatically placed within    */
  381.                /* the required entry fields            */
  382.  
  383.            pust->pfnGetPresParams(hWnd);
  384.            break;
  385.                /* ID List push button selected            */
  386.  
  387.        case    DID_IDLIST :
  388.  
  389.                /* Get the pointer to the user style information    */
  390.  
  391.            if ( (pust = PDATA32FROMDLG(hWnd)) != NULL )
  392.  
  393.                /* Get the address of the look up function from    */
  394.                /* user style information structure and display    */
  395.                /* the dialog.  The value selected within the    */
  396.                /* dialog will be automatically placed within    */
  397.                /* the required entry fields            */
  398.  
  399.            pust->pfnLookupSymbol(hWnd, EF_SYMBOL, EF_SYMBOLVALUE);
  400.            break;
  401.                /* Enter    pushbutton selected get    the definitions    */
  402.                /* for the control                */
  403.        case    DID_OK :
  404.  
  405.                /* Get the pointer to the user style information    */
  406.  
  407.            if ( (pust = PDATA32FROMDLG(hWnd)) != NULL )
  408.            {
  409.                /* Get the address of the symbol    validation    */
  410.                /* function from    the user style information    */
  411.                /* structure.  The function will    validate the    */
  412.                /* symbol and will check    for duplications of    */
  413.                /* values.  A return value of TRUE from the    */
  414.                /* validation function indicates    that the symbol    */
  415.                /* and value are    acceptable.  Conversely, a    */
  416.                /* FALSE    return value indicates that symbol or    */
  417.                /* value    was not    acceptable.  In    this case,    */
  418.                /* the dialog should not    be exited from and the    */
  419.                /* values within    the entry fields should    not be    */
  420.                /* saved.                    */
  421.  
  422.            if (    !pust->pfnValidateSymbol(hWnd, EF_SYMBOL, EF_SYMBOLVALUE) )
  423.                break;
  424.            else
  425.                {
  426.                pust->cText = 0;
  427.  
  428.                /* Get the symbol of the    control    and save within    */
  429.                /* the user style information structure for use    */
  430.                /* by Prominare Designer                */
  431.  
  432.                WinQueryDlgItemText(hWnd, EF_SYMBOL, CCHID, pust->szid);
  433.  
  434.                /* Get the id value of the control and save    */
  435.                /* within the user style    information structure    */
  436.                /* for use by Prominare Designer            */
  437.  
  438.                WinQueryDlgItemText(hWnd, EF_SYMBOLVALUE, 16L, szBuffer);
  439.                pust->id    = (ULONG)atol(szBuffer);
  440.  
  441.                cLines =    SHORT1FROMMR(WinSendDlgItemMsg(hWnd, MLE_LIST,
  442.                          MLM_QUERYLINECOUNT, 0L, 0L));
  443.  
  444.                DosAllocMem((PPVOID)(PVOID)&pchData, 16384UL, PAG_READ |    PAG_WRITE | PAG_COMMIT);
  445.                for ( i = n = cItems = 0, iptData = 0L; i < cLines; i++ )
  446.                if (    (cLen =    (INT)(cTextLen = (LONG)WinSendDlgItemMsg(hWnd, MLE_LIST,
  447.                                          MLM_QUERYLINELENGTH,
  448.                                          MPFROMLONG(iptData), 0L))) != 0 )
  449.                    {
  450.                    WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_SETIMPORTEXPORT,
  451.                          MPFROMP(szBuffer), MPFROMLONG((IPT)cTextLen));
  452.                    WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_EXPORT,
  453.                          MPFROMP(&iptData), MPFROMP(&cTextLen));
  454.  
  455.                    szBuffer[cLen] =    0;
  456.                    if ( (pch = strchr(szBuffer, '\r')) != NULL )
  457.                    *pch    = 0;
  458.                    else
  459.                    if (    (pch = strchr(szBuffer,    '\n')) != NULL )
  460.                        *pch = 0;
  461.  
  462.                    if ( szBuffer[0]    )
  463.                    {
  464.                    strcpy(&pchData[n], szBuffer);
  465.                    n +=    (INT)strlen(szBuffer) +    1;
  466.                    ++cItems;
  467.                    }
  468.                    }
  469.  
  470.                if ( WinQueryDlgItemTextLength(hWnd, EF_SND1) ||
  471.                 WinQueryDlgItemTextLength(hWnd, EF_SND2) )
  472.                {
  473.                WinQueryDlgItemText(hWnd, EF_SND1, CCHMAXPATH, szBuffer);
  474.                if (    szBuffer[0] )
  475.                    {
  476.                    strcpy(&pchData[n], szBuffer);
  477.                    n += (INT)strlen(szBuffer) + 1;
  478.                    }
  479.                else
  480.                    pchData[n++] = 0;
  481.                cSounds = 1;
  482.                if (    WinQueryDlgItemTextLength(hWnd,    EF_SND2) )
  483.                    {
  484.                    WinQueryDlgItemText(hWnd, EF_SND2, CCHMAXPATH, szBuffer);
  485.                    if ( szBuffer[0]    )
  486.                    {
  487.                    strcpy(&pchData[n], szBuffer);
  488.                    n +=    (INT)strlen(szBuffer) +    1;
  489.                    ++cSounds;
  490.                    }
  491.                    }
  492.                }
  493.                if ( !(pust->pbCtlData =    (PBYTE)pust->pfnRealloc(pust->pbCtlData,
  494.                                     n + sizeof(LISTBOXCDATA) - 1L))    )
  495.                {
  496.                WinMessageBox(HWND_DESKTOP, hWnd,
  497.                      "Memory error on reallocating control data!",
  498.                      "Super List Box Control", 0UL,    MB_OK |    MB_ICONEXCLAMATION);
  499.                return(0L);
  500.                }
  501.  
  502.                pust->cbCtlData = (ULONG)(sizeof(LISTBOXCDATA) -    1 + n);
  503.  
  504.                plbwcd =    (PLISTBOXCDATA)pust->pbCtlData;
  505.                plbwcd->cb = (ULONG)(sizeof(PLISTBOXCDATA) - 1 +    n);
  506.                plbwcd->vdata.lbcd1_1.cItems  = (ULONG)cItems;
  507.                plbwcd->vdata.lbcd1_1.cSounds = (ULONG)cSounds;
  508.                memcpy(plbwcd->vdata.lbcd1_1.abList, pchData, (UINT)n);
  509.                DosFreeMem((PVOID)pchData);
  510.  
  511.                pust->flStyle = 0UL;
  512.  
  513.                /* Check    to see if multiple selection desired    */
  514.                /* and if selected add style to base selected    */
  515.  
  516.                if ( WinSendDlgItemMsg(hWnd, CB_LS_MULTIPLESEL, BM_QUERYCHECK, 0L, 0L) )
  517.                pust->flStyle |= LS_MULTIPLESEL;
  518.  
  519.                /* Check    to see if owner    draw desired and if    */
  520.                /* selected add style to    base selected        */
  521.  
  522.                if ( WinSendDlgItemMsg(hWnd, CB_LS_OWNERDRAW, BM_QUERYCHECK, 0L,    0L) )
  523.                pust->flStyle |= LS_OWNERDRAW;
  524.  
  525.                /* Check    to see if no adjust position desired    */
  526.                /* and if selected add style to base selected    */
  527.  
  528.                if ( WinSendDlgItemMsg(hWnd, CB_LS_NOADJUSTPOS, BM_QUERYCHECK, 0L, 0L) )
  529.                pust->flStyle |= LS_NOADJUSTPOS;
  530.  
  531.                /* Check    to see if horizontal scroll desired and    */
  532.                /* if selected add style    to base    selected    */
  533.  
  534.                if ( WinSendDlgItemMsg(hWnd, CB_LS_HORZSCROLL, BM_QUERYCHECK, 0L, 0L) )
  535.                pust->flStyle |= LS_HORZSCROLL;
  536.  
  537.                /* Check    to see if extended selection desired    */
  538.                /* and if selected add style to base selected    */
  539.  
  540.                if ( WinSendDlgItemMsg(hWnd, CB_LS_EXTENDEDSEL, BM_QUERYCHECK, 0L, 0L) )
  541.                plbwcd->vdata.lbcd1_1.flExtStyles |=    LS_EXTENDEDSEL;
  542.  
  543.                /* Check    to see if check    box selection desired    */
  544.                /* and if selected add style to base selected    */
  545.  
  546.                if ( WinSendDlgItemMsg(hWnd, CB_LSXS_CHECKBOX, BM_QUERYCHECK, 0L, 0L) )
  547.                pust->flStyle |= LSXS_CHECKBOX;
  548.  
  549.                if ( WinSendDlgItemMsg(hWnd, CB_VISIBLE,
  550.                           BM_QUERYCHECK, 0L, 0L) )
  551.                pust->flStyle |= WS_VISIBLE;
  552.  
  553.                if ( WinSendDlgItemMsg(hWnd, CB_GROUP,
  554.                           BM_QUERYCHECK, 0L, 0L) )
  555.                pust->flStyle |= WS_GROUP;
  556.  
  557.                if ( WinSendDlgItemMsg(hWnd, CB_DISABLED,
  558.                           BM_QUERYCHECK, 0L, 0L) )
  559.                pust->flStyle |= WS_DISABLED;
  560.  
  561.                if ( WinSendDlgItemMsg(hWnd, CB_TABSTOP,
  562.                           BM_QUERYCHECK, 0L, 0L) )
  563.                pust->flStyle |= WS_TABSTOP;
  564.                }
  565.            }
  566.                /* Exit the dialogue indicating changes made    */
  567.  
  568.            WinDismissDlg(hWnd, TRUE);
  569.            break;
  570.                /* Cancel selected, exit    the dialogue without    */
  571.                /* changing anything                */
  572.  
  573.        case    DID_CANCEL :
  574.            WinDismissDlg(hWnd, FALSE);
  575.            break;
  576.        }
  577.        break;
  578.                /* Close    received, exit dialog            */
  579.    case    WM_CLOSE :
  580.        WinDismissDlg(hWnd, FALSE);
  581.        break;
  582.                /* Pass through unhandled messages        */
  583.    default :
  584.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  585.    }
  586. return(0L);
  587.  
  588. }
  589. #pragma    subtitle("   Super List Box DLL - Control Styles Dialogue Procedure")
  590. #pragma    page ( )
  591.  
  592. /* --- LBCCAnalystStyles ---------------------------- [    Public ] --- */
  593. /*                                    */
  594. /*     This function is    used for the custom control's styles dialogue   */
  595. /*     box procedure.                            */
  596. /*                                    */
  597. /*     When the    dialogue is invoked from Prominare Designer, the    */
  598. /*     address of the user style information is    contained in message    */
  599. /*     parameter 2.  The dialogue is responsible for saving the        */
  600. /*     address.     The best method to do this is to save the pointer    */
  601. /*     in the dialogue's reserved memory where it can be retrieved as   */
  602. /*     needed.                                */
  603. /*                                    */
  604. /*     Upon Entry:                            */
  605. /*                                    */
  606. /*     HWND   hWnd; = Dialog Window Handle                */
  607. /*     ULONG  msg;  = PM Message                    */
  608. /*     MPARAM mp1;  = Message Parameter    1                */
  609. /*     MPARAM mp2;  = Message Parameter    2                */
  610. /*                                    */
  611. /*     Upon Exit:                            */
  612. /*                                    */
  613. /*     LBCCAnalystStyles = Message Handling Result             */
  614. /*                                    */
  615. /* --------------------------------------------------------------------    */
  616.  
  617. MRESULT    EXPENTRY LBCCAnalystStyles(HWND    hWnd, ULONG msg, MPARAM    mp1, MPARAM mp2)
  618.  
  619. {
  620. CHAR          szBuffer[256];       /* Buffer                */
  621. INT          cItems;           /* Items Count            */
  622. INT          cLen;           /* Text Length            */
  623. INT          cLines;           /* Lines Count            */
  624. INT          cSounds;           /* Sounds Count            */
  625. INT          cTextLen;           /* Text Length            */
  626. IPT          iptData;           /* MLE Data Start Position        */
  627. PCHAR          pch;           /* Character    String Pointer        */
  628. PCHAR          pchData;           /* Data Pointer            */
  629. PLISTBOXCDATA plbwcd;           /* List Box CTLDATA Pointer        */
  630. PUSERSTYLE32  pust;           /* User Style Pointer        */
  631. SWP          swp;           /* Screen Window Position Holder    */
  632. register INT i,    n;           /* Loop Counter            */
  633.  
  634. switch ( msg )
  635.    {
  636.                /* Perform dialogue initialization        */
  637.    case    WM_INITDLG :
  638.                /* Save the pointer to user style information    */
  639.                /* within the dialog's reserved memory           */
  640.  
  641.        WinSetWindowPtr(hWnd, QWL_USER, (PVOID)mp2);
  642.  
  643.                /* Get the pointer to the user style information    */
  644.  
  645.        if ( (pust = (PUSERSTYLE32)mp2) != NULL )
  646.        {
  647.                /* Set the text,    ID symbol and value for    the    */
  648.                /* control                    */
  649.  
  650.        plbwcd = (PLISTBOXCDATA)pust->pbCtlData;
  651.  
  652.        if (    plbwcd->vdata.lbcd1_1.cItems )
  653.            {
  654.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_SETTEXTLIMIT,
  655.                  MPFROMLONG(16384L), 0L);
  656.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_DISABLEREFRESH, 0L, 0L);
  657.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_RESETUNDO,    0L, 0L);
  658.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_FORMAT,
  659.                  MPFROMSHORT(MLFIE_NOTRANS), 0L);
  660.            for ( i = n = 0,    iptData    = 0L; i    < plbwcd->vdata.lbcd1_1.cItems;    i++ )
  661.            {
  662.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_SETIMPORTEXPORT,
  663.                      MPFROMP(szBuffer),
  664.                      MPFROMLONG(cLen = (INT)strlen(strcat(strcpy(szBuffer,
  665.                                          &plbwcd->vdata.lbcd1_1.abList[n]),
  666.                                       "\n"))));
  667.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_IMPORT, MPFROMP(&iptData),
  668.                      MPFROMLONG(cLen));
  669.            n +=    (INT)strlen(&plbwcd->vdata.lbcd1_1.abList[n]) +    1;
  670.            }
  671.            WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_ENABLEREFRESH, 0L,    0L);
  672.            if ( plbwcd->vdata.lbcd1_1.cSounds )
  673.            {
  674.            WinSetDlgItemText(hWnd, EF_SND1, &plbwcd->vdata.lbcd1_1.abList[n]);
  675.            if (    plbwcd->vdata.lbcd1_1.cSounds == 2 )
  676.                {
  677.                n += (INT)strlen(&plbwcd->vdata.lbcd1_1.abList[n]) + 1;
  678.                WinSetDlgItemText(hWnd, EF_SND2,    &plbwcd->vdata.lbcd1_1.abList[n]);
  679.                }
  680.            }
  681.            }
  682.                /* Set multiple selection check box if selected    */
  683.  
  684.        if (    pust->flStyle &    LS_MULTIPLESEL )
  685.            WinSendDlgItemMsg(hWnd, CB_LS_MULTIPLESEL, BM_SETCHECK,
  686.                  MPFROMSHORT(TRUE), 0L);
  687.  
  688.                /* Set Owner draw check box if selected        */
  689.  
  690.        if (    pust->flStyle &    LS_OWNERDRAW )
  691.            WinSendDlgItemMsg(hWnd, CB_LS_OWNERDRAW,    BM_SETCHECK,
  692.                  MPFROMSHORT(TRUE), 0L);
  693.  
  694.                /* Set No adjust    position check box if selected    */
  695.  
  696.        if (    pust->flStyle &    LS_NOADJUSTPOS )
  697.            WinSendDlgItemMsg(hWnd, CB_LS_NOADJUSTPOS, BM_SETCHECK,
  698.                  MPFROMSHORT(TRUE), 0L);
  699.  
  700.                /* Set Horizontal scroll    check box if selected    */
  701.  
  702.        if (    pust->flStyle &    LS_HORZSCROLL )
  703.            WinSendDlgItemMsg(hWnd, CB_LS_HORZSCROLL, BM_SETCHECK,
  704.                  MPFROMSHORT(TRUE), 0L);
  705.  
  706.                /* Set Extended selection check box if selected    */
  707.  
  708.        if (    pust->flStyle &    LS_EXTENDEDSEL )
  709.            WinSendDlgItemMsg(hWnd, CB_LS_EXTENDEDSEL, BM_SETCHECK,
  710.                  MPFROMSHORT(TRUE), 0L);
  711.  
  712.                /* Set Check box    selection check    box if selected    */
  713.  
  714.        if (    plbwcd && plbwcd->vdata.lbcd1_1.flExtStyles & LSXS_CHECKBOX )
  715.            WinSendDlgItemMsg(hWnd, CB_LSXS_CHECKBOX, BM_SETCHECK,
  716.                  MPFROMSHORT(TRUE), 0L);
  717.  
  718.        if (    pust->flStyle &    WS_VISIBLE )
  719.            WinSendDlgItemMsg(hWnd, CB_VISIBLE, BM_SETCHECK,
  720.                  MPFROMSHORT(TRUE), 0L);
  721.  
  722.        if (    pust->flStyle &    WS_GROUP )
  723.            WinSendDlgItemMsg(hWnd, CB_GROUP, BM_SETCHECK,
  724.                  MPFROMSHORT(TRUE), 0L);
  725.  
  726.        if (    pust->flStyle &    WS_DISABLED )
  727.            WinSendDlgItemMsg(hWnd, CB_DISABLED, BM_SETCHECK,
  728.                  MPFROMSHORT(TRUE), 0L);
  729.  
  730.        if (    pust->flStyle &    WS_TABSTOP )
  731.            WinSendDlgItemMsg(hWnd, CB_TABSTOP, BM_SETCHECK,
  732.                  MPFROMSHORT(TRUE), 0L);
  733.        }
  734.                /* Centre dialog    on the screen            */
  735.  
  736.        WinQueryWindowPos(hWnd, (PSWP)&swp);
  737.        WinSetWindowPos(hWnd, HWND_TOP,
  738.                (WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN) - swp.cx) /    2L,
  739.                (WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - swp.cy) /    2L,
  740.                0L, 0L, SWP_MOVE);
  741.        break;
  742.                /* Process push button selections        */
  743.    case    WM_COMMAND :
  744.        switch (    SHORT1FROMMP(mp1) )
  745.        {
  746.                /* Presentation push button selected        */
  747.  
  748.        case    DID_PRESPARAM :
  749.  
  750.                /* Get the pointer to the user style information    */
  751.  
  752.            if ( (pust = PDATA32FROMDLG(hWnd)) != NULL )
  753.  
  754.                /* Get the address of the look up function from    */
  755.                /* user style information structure and display    */
  756.                /* the dialog.  The value selected within the    */
  757.                /* dialog will be automatically placed within    */
  758.                /* the required entry fields            */
  759.  
  760.            pust->pfnGetPresParams(hWnd);
  761.            break;
  762.                /* Enter    pushbutton selected get    the definitions    */
  763.                /* for the control                */
  764.        case    DID_OK :
  765.  
  766.                /* Get the pointer to the user style information    */
  767.  
  768.            if ( (pust = PDATA32FROMDLG(hWnd)) != NULL )
  769.            {
  770.                pust->cText = 0;
  771.  
  772.                cLines =    SHORT1FROMMR(WinSendDlgItemMsg(hWnd, MLE_LIST,
  773.                          MLM_QUERYLINECOUNT, 0L, 0L));
  774.  
  775.                DosAllocMem((PPVOID)(PVOID)&pchData, 16384UL, PAG_READ |    PAG_WRITE | PAG_COMMIT);
  776.                for ( i = n = cItems = 0, iptData = 0L; i < cLines; i++ )
  777.                if (    (cLen =    (INT)(cTextLen = (LONG)WinSendDlgItemMsg(hWnd, MLE_LIST,
  778.                                          MLM_QUERYLINELENGTH,
  779.                                          MPFROMLONG(iptData), 0L))) != 0 )
  780.                    {
  781.                    WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_SETIMPORTEXPORT,
  782.                          MPFROMP(szBuffer), MPFROMLONG((IPT)cTextLen));
  783.                    WinSendDlgItemMsg(hWnd, MLE_LIST, MLM_EXPORT,
  784.                          MPFROMP(&iptData), MPFROMP(&cTextLen));
  785.  
  786.                    szBuffer[cLen] =    0;
  787.                    if ( (pch = strchr(szBuffer, '\r')) != NULL )
  788.                    *pch    = 0;
  789.                    else
  790.                    if (    (pch = strchr(szBuffer,    '\n')) != NULL )
  791.                        *pch = 0;
  792.  
  793.                    if ( szBuffer[0]    )
  794.                    {
  795.                    strcpy(&pchData[n], szBuffer);
  796.                    n +=    (INT)strlen(szBuffer) +    1;
  797.                    ++cItems;
  798.                    }
  799.                    }
  800.  
  801.                if ( WinQueryDlgItemTextLength(hWnd, EF_SND1) ||
  802.                 WinQueryDlgItemTextLength(hWnd, EF_SND2) )
  803.                {
  804.                WinQueryDlgItemText(hWnd, EF_SND1, CCHMAXPATH, szBuffer);
  805.                if (    szBuffer[0] )
  806.                    {
  807.                    strcpy(&pchData[n], szBuffer);
  808.                    n += (INT)strlen(szBuffer) + 1;
  809.                    }
  810.                else
  811.                    pchData[n++] = 0;
  812.                cSounds = 1;
  813.                if (    WinQueryDlgItemTextLength(hWnd,    EF_SND2) )
  814.                    {
  815.                    WinQueryDlgItemText(hWnd, EF_SND2, CCHMAXPATH, szBuffer);
  816.                    if ( szBuffer[0]    )
  817.                    {
  818.                    strcpy(&pchData[n], szBuffer);
  819.                    n +=    (INT)strlen(szBuffer) +    1;
  820.                    ++cSounds;
  821.                    }
  822.                    }
  823.                }
  824.                if ( !(pust->pbCtlData =    (PBYTE)pust->pfnRealloc(pust->pbCtlData,
  825.                                     n + sizeof(LISTBOXCDATA) - 1L))    )
  826.                {
  827.                WinMessageBox(HWND_DESKTOP, hWnd,
  828.                      "Memory error on reallocating control data!",
  829.                      "Super List Box Control", 0UL,    MB_OK |    MB_ICONEXCLAMATION);
  830.                return(0L);
  831.                }
  832.  
  833.                pust->cbCtlData = (ULONG)(sizeof(LISTBOXCDATA) -    1 + n);
  834.  
  835.                plbwcd =    (PLISTBOXCDATA)pust->pbCtlData;
  836.                plbwcd->cb = (ULONG)(sizeof(PLISTBOXCDATA) - 1 +    n);
  837.                plbwcd->vdata.lbcd1_1.cItems  = (ULONG)cItems;
  838.                plbwcd->vdata.lbcd1_1.cSounds = (ULONG)cSounds;
  839.                memcpy(plbwcd->vdata.lbcd1_1.abList, pchData, (UINT)n);
  840.                DosFreeMem((PVOID)pchData);
  841.  
  842.                pust->flStyle = 0UL;
  843.  
  844.                /* Check    to see if multiple selection desired    */
  845.                /* and if selected add style to base selected    */
  846.  
  847.                if ( WinSendDlgItemMsg(hWnd, CB_LS_MULTIPLESEL, BM_QUERYCHECK, 0L, 0L) )
  848.                pust->flStyle |= LS_MULTIPLESEL;
  849.  
  850.                /* Check    to see if owner    draw desired and if    */
  851.                /* selected add style to    base selected        */
  852.  
  853.                if ( WinSendDlgItemMsg(hWnd, CB_LS_OWNERDRAW, BM_QUERYCHECK, 0L,    0L) )
  854.                pust->flStyle |= LS_OWNERDRAW;
  855.  
  856.                /* Check    to see if no adjust position desired    */
  857.                /* and if selected add style to base selected    */
  858.  
  859.                if ( WinSendDlgItemMsg(hWnd, CB_LS_NOADJUSTPOS, BM_QUERYCHECK, 0L, 0L) )
  860.                pust->flStyle |= LS_NOADJUSTPOS;
  861.  
  862.                /* Check    to see if horizontal scroll desired and    */
  863.                /* if selected add style    to base    selected    */
  864.  
  865.                if ( WinSendDlgItemMsg(hWnd, CB_LS_HORZSCROLL, BM_QUERYCHECK, 0L, 0L) )
  866.                pust->flStyle |= LS_HORZSCROLL;
  867.  
  868.                /* Check    to see if extended selection desired    */
  869.                /* and if selected add style to base selected    */
  870.  
  871.                if ( WinSendDlgItemMsg(hWnd, CB_LS_EXTENDEDSEL, BM_QUERYCHECK, 0L, 0L) )
  872.                plbwcd->vdata.lbcd1_1.flExtStyles |=    LS_EXTENDEDSEL;
  873.  
  874.                /* Check    to see if check    box selection desired    */
  875.                /* and if selected add style to base selected    */
  876.  
  877.                if ( WinSendDlgItemMsg(hWnd, CB_LSXS_CHECKBOX, BM_QUERYCHECK, 0L, 0L) )
  878.                pust->flStyle |= LSXS_CHECKBOX;
  879.  
  880.                if ( WinSendDlgItemMsg(hWnd, CB_VISIBLE,
  881.                           BM_QUERYCHECK, 0L, 0L) )
  882.                pust->flStyle |= WS_VISIBLE;
  883.  
  884.                if ( WinSendDlgItemMsg(hWnd, CB_GROUP,
  885.                           BM_QUERYCHECK, 0L, 0L) )
  886.                pust->flStyle |= WS_GROUP;
  887.  
  888.                if ( WinSendDlgItemMsg(hWnd, CB_DISABLED,
  889.                           BM_QUERYCHECK, 0L, 0L) )
  890.                pust->flStyle |= WS_DISABLED;
  891.  
  892.                if ( WinSendDlgItemMsg(hWnd, CB_TABSTOP,
  893.                           BM_QUERYCHECK, 0L, 0L) )
  894.                pust->flStyle |= WS_TABSTOP;
  895.            }
  896.                /* Exit the dialogue indicating changes made    */
  897.  
  898.            WinDismissDlg(hWnd, TRUE);
  899.            break;
  900.                /* Cancel selected, exit    the dialogue without    */
  901.                /* changing anything                */
  902.  
  903.        case    DID_CANCEL :
  904.            WinDismissDlg(hWnd, FALSE);
  905.            break;
  906.        }
  907.        break;
  908.                /* Close    received, exit dialog            */
  909.    case    WM_CLOSE :
  910.        WinDismissDlg(hWnd, FALSE);
  911.        break;
  912.                /* Pass through unhandled messages        */
  913.    default :
  914.        return(WinDefDlgProc(hWnd, msg, mp1, mp2));
  915.    }
  916. return(0L);
  917.  
  918. }
  919.