home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / except1.zip / 3DText.C < prev    next >
C/C++ Source or Header  |  1994-08-23  |  21KB  |  621 lines

  1. #pragma    title("Prominare Development System Support DLL  --  Version 3.0 -- (3DText.C)")
  2. #pragma    subtitle("  3D Text Control DLL - Interface Definitions")
  3.  
  4. #pragma    strings(readonly)
  5. #pragma    info(noext)
  6.  
  7. #define    INCL_GPI           /* Include OS/2 PM GPI Interface    */
  8. #define    INCL_WIN           /* Include OS/2 PM Windows Interface    */
  9.  
  10. #include <os2.h>
  11. #include <string.h>
  12. #include <stdio.h>
  13.  
  14. #include <ccls32.h>
  15. #include <heapmem.h>
  16.  
  17. #include "appdefs.h"
  18. #include "except.h"
  19.  
  20. /* This    module contains    an example installable control that can    be used    */
  21. /* by Prominare    Designer to include within applications    where        */
  22. /* additional facilities are provided that are not found within    the    */
  23. /* default controls of OS/2 Presentation Manager.            */
  24. /*                                    */
  25. /* For complete    details    regarding the Custom Control Library        */
  26. /* Specification (CCLS), Version 2.1c, consult Section 2 in the        */
  27. /* Prominare Development System    Programming Guide.            */
  28. /*                                    */
  29. /* The DLL is created using the    following options in Prominare Builder:    */
  30. /*                                    */
  31. /* Option           Value                        */
  32. /* ------           -----                        */
  33. /* Op Sys           OS/2 PM Static DLL                */
  34. /* Optimization           Maximize                        */
  35. /* Build Type           Subsystem                    */
  36. /* CPU               80486                        */
  37. /* Warning Level       3                        */
  38. /*                                    */
  39. /* Equivalent command line invocation:                    */
  40. /*                                    */
  41. /*     Icc -C -G4e -O+ -Rn -W3 3DText.C                    */
  42.  
  43. /* Filename:   3DText.C                            */
  44.  
  45. /*  Version:   3.0                            */
  46. /*  Created:   1994-08-23                        */
  47. /*  Revised:   1994-08-23                        */
  48.  
  49. /* Routines:   static VOID CalcSize(PRECTL prcl, PTEXTFIELD ptf);    */
  50. /*           static VOID SetDefaultColours(HWND hWnd,            */
  51. /*                         PTEXTFIELD ptf);    */
  52. /*           static HPS  hpsDrawText(HPS hPS,    PTEXTFIELD ptf);    */
  53. /*           MRESULT EXPENTRY    Text3DWndProc(HWND hWnd, ULONG msg,    */
  54. /*                          MPARAM mp1, MPARAM mp2);    */
  55.  
  56.  
  57. /* Copyright ╕ 1989-1994  Prominare Inc.  All Rights Reserved.        */
  58.  
  59. /* --------------------------------------------------------------------    */
  60.  
  61. typedef    struct _TEXTFIELD       /* tf */
  62.    {
  63.    POINTL aptl[4];           /* Entry Field Outline Points    */
  64.    RECTL  rcl;               /* Frame Rectangle            */
  65.    LONG      lClrLeftTop;           /* Left and Top Edge    Colour        */
  66.    LONG      lClrBottomRight;       /* Right and    Bottom Edge Colour    */
  67.    BOOL      fRaised;           /* Raised Field Flag            */
  68.    LONG      lClrText;           /* Text Colour            */
  69.    LONG      lClrBackground;       /* Background Colour            */
  70.    LONG      lClrBorder;           /* Border Colour            */
  71.    LONG      cText;           /* Text Length Holder        */
  72.    PSZ      pszText;           /* Text Holder            */
  73.    ULONG  flFormat;           /* Formatting Flags            */
  74.    ULONG  flStyle;           /* Style Flags            */
  75.    BOOL      fDraw;           /* Draw Flag                */
  76.    } TEXTFIELD ;
  77.  
  78. typedef    TEXTFIELD *PTEXTFIELD;
  79.  
  80. extern HHEAPMEM    hHeap;         /* Heap Handle                  */
  81.  
  82. #define    DT_MASK    (DT_LEFT | DT_CENTER | DT_RIGHT    | DT_TOP | DT_VCENTER |    DT_BOTTOM | DT_HALFTONE    | DT_MNEMONIC |    DT_WORDBREAK)
  83.  
  84. /* --- Module Prototype    Definitions -----------------------------------    */
  85.  
  86. static VOID CalcSize(PRECTL prcl, PTEXTFIELD ptf);
  87. static VOID SetDefaultColours(HWND hWnd, PTEXTFIELD ptf);
  88. static HPS  hpsDrawText(HPS hPS, PTEXTFIELD ptf);
  89.  
  90. static INTERNALADDRESSLIST aial[ ] = { { (PFNINTADD)CalcSize,           "CalcSize"       },
  91.                        { (PFNINTADD)SetDefaultColours, "SetDefaultColours" },
  92.                        { (PFNINTADD)hpsDrawText,       "hpsDrawText"       },
  93.                        { (PFNINTADD)Text3DWndProc,     "Text3DWndProc"       },
  94.                        { NULL, NULL } };
  95.  
  96. INTERNALADDRESS    intadd3DText =    { __FILE__, 0, aial };
  97.  
  98. #pragma    subtitle("   Shadowed Text DLL - Control Window Sizing Procedure")
  99. #pragma    page ( )
  100.  
  101. /* --- CalcSize    ---------------------------------------    [ Private ] ---    */
  102. /*                                    */
  103. /*     This function is    used to    calculate the sizes and    positions    */
  104. /*     of the various elements that are    used to    make up    a shadowed    */
  105. /*     text field.                            */
  106. /*                                    */
  107. /*     Upon Entry:                            */
  108. /*                                    */
  109. /*     PRECTL      prcl;    = Control Rectangle Pointer            */
  110. /*     PTEXTFIELD ptf;    = Group    Box Information    Pointer            */
  111. /*                                    */
  112. /*     Upon Exit:                            */
  113. /*                                    */
  114. /*     Nothing                                */
  115. /*                                    */
  116. /* --------------------------------------------------------------------    */
  117.  
  118. static VOID CalcSize(PRECTL prcl, PTEXTFIELD ptf)
  119.  
  120. {
  121.  
  122. if ( (prcl->yTop <= prcl->yBottom) || (prcl->xRight <= prcl->xLeft) )
  123.    ptf->fDraw =    FALSE;
  124. else
  125.    {
  126.    ptf->fDraw =    TRUE;
  127.                /* Save the rectangle for the control        */
  128.    ptf->rcl = *prcl;
  129.                /* Adjust the rectangle size for    the text which    */
  130.                /* resides inside the 3D    frame            */
  131.    ++ptf->rcl.xLeft;
  132.    ++ptf->rcl.yBottom;
  133.    ptf->rcl.yTop -= 2L;
  134.    ptf->rcl.xRight -= 2L;
  135.  
  136.            /*  Text    display    points                    */
  137.            /*                            */
  138.            /*      1                  2            */
  139.            /*       +-------------------------+            */
  140.            /*       |                 |            */
  141.            /*       |                 |            */
  142.            /*       |                 |            */
  143.            /*       |                 |            */
  144.            /*       +-------------------------+            */
  145.            /*      0 4                  3            */
  146.  
  147.    ptf->aptl[0].x = prcl->xLeft;
  148.    ptf->aptl[0].y = prcl->yTop     - 1L;
  149.    ptf->aptl[1].x = prcl->xRight - 1L;
  150.    ptf->aptl[1].y = prcl->yTop     - 1L;
  151.    ptf->aptl[2].x = prcl->xRight - 1L;
  152.    ptf->aptl[2].y = prcl->yBottom;
  153.    ptf->aptl[3].x = prcl->xLeft;
  154.    ptf->aptl[3].y = prcl->yBottom;
  155.  
  156.                /* Get the text formatting flags    and save    */
  157.  
  158.    ptf->flFormat = (ptf->flStyle &  DT_MASK) | DT_ERASERECT;
  159.    }
  160. }
  161. #pragma    subtitle("   Shadowed Text DLL - Default Colours Procedure")
  162. #pragma    page( )
  163.  
  164. /* --- SetDefaultColours ------------------------------    [ Private ] ---    */
  165. /*                                    */
  166. /*     This function is    used to    set the    default    colours    that the    */
  167. /*     image button should use within the internal paint routines.    */
  168. /*     The colour can either be    a presentation parameter that has    */
  169. /*     been set    or it can be the default colour    as defined within    */
  170. /*     control.                                */
  171. /*                                    */
  172. /*     Upon Entry:                            */
  173. /*                                    */
  174. /*     HWND      hWnd;    = Window Handle                    */
  175. /*     PTEXTFIELD ptf;    = Text Field Structure Pointer            */
  176. /*                                    */
  177. /*     Upon Exit:                            */
  178. /*                                    */
  179. /*     Nothing                                */
  180. /*                                    */
  181. /* --------------------------------------------------------------------    */
  182.  
  183. static VOID SetDefaultColours(HWND hWnd, PTEXTFIELD ptf)
  184.  
  185. {
  186.                /* Set up the colours that will be used within    */
  187.                /* the painting of the control.            */
  188.  
  189. ptf->lClrText        = lGetPresParam(hWnd, PP_FOREGROUNDCOLOR,
  190.                     PP_FOREGROUNDCOLORINDEX,
  191.                     SYSCLR_OUTPUTTEXT);
  192. ptf->lClrBackground = lGetPresParam(hWnd, PP_BACKGROUNDCOLOR,
  193.                     PP_BACKGROUNDCOLORINDEX,
  194.                     SYSCLR_DIALOGBACKGROUND);
  195. ptf->lClrBorder        = lGetPresParam(hWnd, PP_BORDERCOLOR,
  196.                     PP_BORDERCOLORINDEX,
  197.                     SYSCLR_BUTTONDARK);
  198. }
  199. #pragma    subtitle("   Shadowed Text DLL - 3D Text Window Procedure")
  200. #pragma    page ( )
  201.  
  202. /* --- DrawText    ---------------------------------------    [ Private ] ---    */
  203. /*                                    */
  204. /*     This function is    used to    draw the text and 3D outline.        */
  205. /*                                    */
  206. /*     Upon Entry:                            */
  207. /*                                    */
  208. /*     HPS      hPS; = Window    Presentation Space Handle        */
  209. /*     PTEXTFIELD ptf; = Text Field Pointer                */
  210. /*                                    */
  211. /*     Upon Exit:                            */
  212. /*                                    */
  213. /*     hpsDrawText = Window Presentation Space Handle            */
  214. /*                                    */
  215. /* --------------------------------------------------------------------    */
  216.  
  217. static HPS hpsDrawText(HPS hPS,    PTEXTFIELD ptf)
  218.  
  219. {
  220. FONTMETRICS fm3D;           /* Font Metrics Holder        */
  221. RECTL        rcl;           /* Rectangle    Holder            */
  222. register LONG i, k, n;           /* String Length Counter        */
  223.  
  224.                /* Get the presentation space for the control    */
  225.                /* and set the colour table to RGB mode        */
  226.  
  227. GpiCreateLogColorTable(hPS, 0L,    LCOLF_RGB, 0L, 0L, (PLONG)NULL);
  228.  
  229.                /* Check    to see if any text present and if the    */
  230.                /* case,    draw it    within the rectangle        */
  231.  
  232. if ( ptf->cText    )
  233.                /* Check    to see if the text is to be broken over    */
  234.                /* more than one    line if    the length of the text    */
  235.                /* is greater than the width of the control    */
  236.  
  237.    if (    ptf->flStyle & DT_WORDBREAK )
  238.        {
  239.                /* Word break style specified, set the drawing    */
  240.                /* of the text within a loop such that it can    */
  241.                /* be drawn on successive lines            */
  242.        n = ptf->cText;
  243.        GpiQueryFontMetrics(hPS,    sizeof(FONTMETRICS), &fm3D);
  244.        rcl = ptf->rcl;
  245.        i = 0;
  246.        do
  247.        {
  248.        n -=    (k = WinDrawText(hPS, n, &ptf->pszText[i], &rcl, ptf->lClrText,
  249.                  ptf->lClrBackground, ptf->flFormat));
  250.        i +=    k;
  251.        if (    (rcl.yTop -= fm3D.lMaxBaselineExt) < rcl.yBottom )
  252.            break;
  253.        } while ( n > 0 );
  254.        }
  255.    else
  256.        WinDrawText(hPS,    ptf->cText, ptf->pszText, &ptf->rcl, ptf->lClrText,
  257.            ptf->lClrBackground,    ptf->flFormat);
  258. else
  259.    WinFillRect(hPS, &ptf->rcl, ptf->lClrBackground);
  260.  
  261. GpiSetColor(hPS, ptf->lClrLeftTop);
  262.  
  263. GpiMove(hPS, &ptf->aptl[3]);
  264. GpiPolyLine(hPS, 2L, ptf->aptl);
  265.  
  266. GpiSetColor(hPS, ptf->lClrBottomRight);
  267. GpiPolyLine(hPS, 2L, &ptf->aptl[2]);
  268.  
  269. return(hPS);
  270. }
  271. #pragma    subtitle("   Shadowed Text DLL - 3D Text Window Procedure")
  272. #pragma    page ( )
  273.  
  274. /* --- Text3DWndProc ----------------------------------    [ Private ] ---    */
  275. /*                                    */
  276. /*     This function is    used to    handle the messages sent to the        */
  277. /*     installed control.  The window procedure    is designed to        */
  278. /*     allow for multiple instances and    to be totally re-entrant.    */
  279. /*                                    */
  280. /*     Upon Entry:                            */
  281. /*                                    */
  282. /*     HWND   hWnd; = Window Handle                    */
  283. /*     ULONG  msg;  = PM Message                    */
  284. /*     MPARAM mp1;  = Message Parameter    1                */
  285. /*     MPARAM mp2;  = Message Parameter    2                */
  286. /*                                    */
  287. /*     Upon Exit:                            */
  288. /*                                    */
  289. /*     Text3DWndProc = Message Handling    Result                */
  290. /*                                    */
  291. /* --------------------------------------------------------------------    */
  292.  
  293. MRESULT    EXPENTRY Text3DWndProc(HWND hWnd, ULONG    msg, MPARAM mp1, MPARAM    mp2)
  294.  
  295. {
  296. LONG           lClr;           /* Presentation Parameter Colour    */
  297. PCREATESTRUCT  pcrst;           /* Create Structure Pointer        */
  298. PTEXTFIELD     ptf;           /* Text Field Structure Pointer    */
  299. PWNDPARAMS     pwprm;           /* Window Parameters    Pointer        */
  300. RECTL           rcl;           /* Rectangle    Holder            */
  301. ULONG           flStyle;           /* Control Style            */
  302. ULONG           ulID;           /* Presentation Parameter ID        */
  303.  
  304. switch ( msg )
  305.    {
  306.                /* Perform control initialization when the    */
  307.                /* control is created                */
  308.    case    WM_CREATE :
  309.                /* Save the address of the text string pointer    */
  310.                /* in the control's reserved memory to allow it  */
  311.                /* to be    referenced as required by the control    */
  312.  
  313.        WinSetWindowPtr(hWnd, QWW_CDATA,
  314.                (PVOID)(ptf = (PTEXTFIELD)HeapMalloc(hHeap, sizeof(TEXTFIELD))));
  315.  
  316.                /* Get the control's creation structure address  */
  317.                /* to copy the default text of the control to    */
  318.                /* the memory in    the heap            */
  319.  
  320.        pcrst = (PCREATESTRUCT)PVOIDFROMMP(mp2);
  321.  
  322.        if ( pcrst->pszText )
  323.        {
  324.        ptf->pszText    = (PSZ)HeapMalloc(hHeap, (ULONG)(ptf->cText = (LONG)strlen(pcrst->pszText)) + 1UL);
  325.        memcpy(ptf->pszText,    pcrst->pszText,    (UINT)ptf->cText);
  326.        }
  327.                /* Set up the colours that will be used within    */
  328.                /* the painting of the control.            */
  329.  
  330.        SetDefaultColours(hWnd, ptf);
  331.  
  332.                /* Check    to see if the user provided font that    */
  333.                /* should override the default font that    would    */
  334.                /* be set                    */
  335.  
  336.        if ( !WinQueryPresParam(hWnd, PP_FONTNAMESIZE, 0L, &ulID, 4L,
  337.                    (PVOID)&lClr, QPF_NOINHERIT) )
  338.  
  339.                /* System indicates not set since not data was    */
  340.                /* returned, therefore set default font for the    */
  341.                /* control                    */
  342.  
  343.        WinSetPresParam(hWnd, PP_FONTNAMESIZE, 8L, (PVOID)"10.Helv");
  344.  
  345.        if ( (ptf->flStyle = pcrst->flStyle) & DS_RAISED    )
  346.        {
  347.        ptf->fRaised    = TRUE;
  348.        ptf->lClrLeftTop    = RGB_WHITE;
  349.        ptf->lClrBottomRight    = ptf->lClrBorder;
  350.        }
  351.        else
  352.        {
  353.        ptf->fRaised    = FALSE;
  354.        ptf->lClrLeftTop    = ptf->lClrBorder;
  355.        ptf->lClrBottomRight    = RGB_WHITE;
  356.        }
  357.  
  358.        if ( ((rcl.xRight = pcrst->cx) >    0L) && ((rcl.yTop = pcrst->cy) > 0L) )
  359.        {
  360.        rcl.xLeft = rcl.yBottom = 0L;
  361.        CalcSize(&rcl, ptf);
  362.        }
  363.        break;
  364.                /* Control size changing, update    the rectangle    */
  365.                /* points for the 3D text control        */
  366.    case    WM_SIZE    :
  367.        if ( ((LONG)(SHORT)SHORT1FROMMP(mp2) > 0L) && ((LONG)(SHORT)SHORT2FROMMP(mp2) > 0L) )
  368.        {
  369.        WinQueryWindowRect(hWnd, &rcl);
  370.        CalcSize(&rcl, (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA));
  371.        }
  372.        else
  373.        {
  374.        ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  375.        ptf->fDraw =    FALSE;
  376.        }
  377.        break;
  378.                /* Process window parameters setting        */
  379.  
  380.    case    WM_SETWINDOWPARAMS :
  381.  
  382.                /* Get the address for the windows parameters    */
  383.                /* structure                    */
  384.  
  385.        pwprm = (PWNDPARAMS)PVOIDFROMMP(mp1);
  386.  
  387.                /* Check    to see if the text for the control is    */
  388.                /* being    set                    */
  389.  
  390.        if ( pwprm->fsStatus & WPM_TEXT )
  391.        {
  392.                /* Text being set, get the address of the text    */
  393.                /* string stored    in the heap            */
  394.  
  395.        ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  396.  
  397.                /* Check    to see if any text is being set        */
  398.  
  399.        if (    pwprm->cchText )
  400.            {
  401.            if ( ptf->cText )
  402.            ptf->pszText    = (PSZ)HeapRealloc(hHeap, ptf->pszText,
  403.                            (ULONG)(ptf->cText =    (LONG)pwprm->cchText) +    1UL);
  404.            else
  405.            ptf->pszText    = (PSZ)HeapMalloc(hHeap, (ULONG)(ptf->cText = (LONG)pwprm->cchText) + 1UL);
  406.  
  407.                /* Check    to make    sure that the text that    is to    */
  408.                /* be set is not    greater    than the memory        */
  409.                /* allocated                    */
  410.  
  411.            memcpy(ptf->pszText, pwprm->pszText, (UINT)pwprm->cchText);
  412.            ptf->pszText[ptf->cText]    = 0;
  413.            }
  414.        else
  415.            {
  416.            if ( ptf->cText )
  417.            HeapFree(hHeap, ptf->pszText);
  418.  
  419.                /* No text is being set,    clear any existing text    */
  420.  
  421.            ptf->cText = 0L;
  422.            }
  423.  
  424.        if (    ptf->fDraw )
  425.            WinReleasePS(hpsDrawText(WinGetPS(hWnd),    ptf));
  426.        }
  427.        break;
  428.                /* Process window parameters query        */
  429.  
  430.    case    WM_QUERYWINDOWPARAMS :
  431.  
  432.                /* Get the address for the windows parameters    */
  433.                /* structure                    */
  434.  
  435.        pwprm = (PWNDPARAMS)PVOIDFROMMP(mp1);
  436.  
  437.                /* Determine the    type of    query            */
  438.  
  439.        switch (    pwprm->fsStatus    )
  440.        {
  441.                /* Query    type:  get text                */
  442.  
  443.        case    WPM_TEXT :
  444.  
  445.                /* Text being asked for,    get the    address    of the    */
  446.                /* text string stored in    the heap        */
  447.  
  448.            ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  449.  
  450.                /* Copy the text    from the string    to the        */
  451.                /* structure                    */
  452.  
  453.            memcpy(pwprm->pszText, ptf->pszText, (UINT)(ptf->cText +    1));
  454.            break;
  455.                /* Query    type:  get text    length            */
  456.  
  457.        case    WPM_CCHTEXT :
  458.  
  459.                /* Text length being asked for, get the address    */
  460.                /* of the text string stored in the heap        */
  461.  
  462.            ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  463.  
  464.                /* Place    the length the string within the    */
  465.                /* structure                    */
  466.  
  467.            pwprm->cchText =    (ULONG)ptf->cText;
  468.            break;
  469.                /* Query    type:  get control data    length        */
  470.  
  471.        case    WPM_CBCTLDATA :
  472.  
  473.                /* Set the control data length to zero        */
  474.  
  475.            pwprm->cbCtlData    = 0;
  476.            break;
  477.  
  478.        default :
  479.            return(WinDefWindowProc(hWnd, msg, mp1, mp2));
  480.        }
  481.        break;
  482.                /* Presentation parameters changed, record the    */
  483.                /* change internally                */
  484.  
  485.    case    WM_PRESPARAMCHANGED :
  486.  
  487.                /* Check    to see if an individual    presentation    */
  488.                /* parameter has    changed    if so, get the new    */
  489.                /* colour value for use by the painting routines    */
  490.  
  491.        if ( LONGFROMMP(mp1) && (LONGFROMMP(mp1)    < PP_FONTNAMESIZE) )
  492.        {
  493.                /* Get the address of the control info from the    */
  494.                /* control's reserved memory                     */
  495.  
  496.        ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  497.  
  498.                /* Get the new presentation parameter colour for    */
  499.                /* the presentation parameter that has changed.    */
  500.                /* Get the colour as a RGB value    so as to be    */
  501.                /* able to get an exact value and not an        */
  502.                /* approximation    which could happen if the    */
  503.                /* presentation parameter was set as a RGB but    */
  504.                /* queried as an    index.    When WinQueryPresParam    */
  505.                /* returns a 0, it indicates that no        */
  506.                /* presentation parameter set and the default    */
  507.                /* colours should be used.            */
  508.  
  509.        switch ( LONGFROMMP(mp1) )
  510.            {
  511.            case PP_FOREGROUNDCOLOR :
  512.            case PP_FOREGROUNDCOLORINDEX :
  513.            ptf->lClrText = lGetPresParam(hWnd, PP_FOREGROUNDCOLOR,
  514.                         PP_FOREGROUNDCOLORINDEX,
  515.                         SYSCLR_OUTPUTTEXT);
  516.            break;
  517.  
  518.            case PP_BACKGROUNDCOLOR :
  519.            case PP_BACKGROUNDCOLORINDEX :
  520.            ptf->lClrBackground = lGetPresParam(hWnd, PP_BACKGROUNDCOLOR,
  521.                         PP_BACKGROUNDCOLORINDEX,
  522.                         SYSCLR_DIALOGBACKGROUND);
  523.            break;
  524.  
  525.            case PP_BORDERCOLOR :
  526.            case PP_BORDERCOLORINDEX    :
  527.            ptf->lClrBorder = lGetPresParam(hWnd, PP_BORDERCOLOR,
  528.                         PP_BORDERCOLORINDEX,
  529.                         SYSCLR_BUTTONDARK);
  530.            break;
  531.            }
  532.        if (    ptf->fRaised )
  533.            ptf->lClrBottomRight = ptf->lClrBorder;
  534.        else
  535.            ptf->lClrLeftTop        = ptf->lClrBorder;
  536.  
  537.                /* Invalidate the button    to force to use    the    */
  538.                /* new colours just set or removed        */
  539.  
  540.        if (    ptf->fDraw )
  541.            WinReleasePS(hpsDrawText(WinGetPS(hWnd),    ptf));
  542.        }
  543.        else
  544.                /* Determine if the Scheme Palette has forced a    */
  545.                /* global scheme    update in which    case, check all    */
  546.                /* of the presentation parameters to see    if they    */
  547.                /* have been added or removed            */
  548.  
  549.        if (    LONGFROMMP(mp1)    == 0L )
  550.  
  551.                /* Set up the colours that will be used within    */
  552.                /* the painting of the control.            */
  553.  
  554.            SetDefaultColours(hWnd,
  555.                  ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA));
  556.        break;
  557.                /* Mouse    being passed over the control, imply    */
  558.                /* that the control is transparent to the    */
  559.                /* system                    */
  560.    case    WM_HITTEST :
  561.        return(MRFROMLONG(HT_TRANSPARENT));
  562.  
  563.                /* Erase    control    background            */
  564.  
  565.    case    WM_ERASEBACKGROUND :
  566.        return(MRFROMLONG(TRUE));
  567.  
  568.                /* Paint    the Control                */
  569.    case    WM_PAINT :
  570.                /* Get the address of the text from the        */
  571.                /* control's reserved memory                     */
  572.  
  573.        ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  574.  
  575.                /* Before painting, check to see    if the style of    */
  576.                /* the control has changed.  When it has    changed    */
  577.                /* make sure that the control internal values    */
  578.                /* are updated to reflect any changes made.    */
  579.  
  580.        if ( ((flStyle =    WinQueryWindowULong(hWnd, QWL_STYLE)) &    (DT_MASK && SS_TEXT)) !=
  581.         (ptf->flStyle & (DT_MASK &&    SS_TEXT)) )
  582.        {
  583.        if (    (ptf->flStyle =    flStyle) & DS_RAISED )
  584.            {
  585.            ptf->fRaised = TRUE;
  586.            ptf->lClrLeftTop        = RGB_WHITE;
  587.            ptf->lClrBottomRight = ptf->lClrBorder;
  588.            }
  589.        else
  590.            {
  591.            ptf->fRaised = FALSE;
  592.            ptf->lClrLeftTop        = ptf->lClrBorder;
  593.            ptf->lClrBottomRight = RGB_WHITE;
  594.            }
  595.  
  596.        WinQueryWindowRect(hWnd, &rcl);
  597.        CalcSize(&rcl, ptf);
  598.        }
  599.                /* Get the presentation space for the control    */
  600.                /* and set the colour table to RGB mode        */
  601.        if ( ptf->fDraw )
  602.        WinEndPaint(hpsDrawText(WinBeginPaint(hWnd, (HPS)NULL, (PRECTL)NULL), ptf));
  603.        break;
  604.                /* Control being    destroyed            */
  605.    case    WM_DESTROY :
  606.                /* Release the heap allocated for use by    the    */
  607.                /* control                    */
  608.  
  609.        ptf = (PTEXTFIELD)WinQueryWindowPtr(hWnd, QWW_CDATA);
  610.        if ( ptf->cText )
  611.        HeapFree(hHeap, ptf->pszText);
  612.        HeapFree(hHeap, ptf);
  613.        break;
  614.                /* Default message processing            */
  615.    default :
  616.        return(WinDefWindowProc(hWnd, msg, mp1, mp2));
  617.    }
  618.  
  619. return(0L);
  620. }
  621.