home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / inole / gizmoapi.c < prev    next >
C/C++ Source or Header  |  1995-05-03  |  20KB  |  880 lines

  1. /*
  2.  * GIZMOAPI.C
  3.  *
  4.  * API functions affecting a GizmoBar and a message processing
  5.  * function to handle the equivalent called through messages.
  6.  *
  7.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Microsoft
  10.  * Internet  :  kraigb@microsoft.com
  11.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  12.  */
  13.  
  14.  
  15. #include "inoledll.h"
  16.  
  17.  
  18. /*
  19.  * GBMessageHandler
  20.  *
  21.  * Purpose:
  22.  *  Processes control messages that are equivalents of available
  23.  *  control API.  The data passed with these messages is simply
  24.  *  extracted from structures and passed as parameters to their
  25.  *  equivalent function.
  26.  *
  27.  * Parameters:
  28.  *  <Standard Message Parameters> plus
  29.  *  pGB             PGIZMOBAR providing control-specific data.
  30.  *
  31.  * Return Value:
  32.  *  LRESULT         Return value from equivalent API function.
  33.  */
  34.  
  35. LRESULT GBMessageHandler(HWND hWnd, UINT iMsg, WPARAM wParam
  36.     , LPARAM lParam, PGIZMOBAR pGB)
  37.     {
  38.     LRESULT         lRet=0L;
  39.     LPCREATEGIZMO   pCG;
  40.     LPGBMSG         pMsg;
  41.     LPGBGETTEXT     pGT;
  42.     LPGBGETINT      pGI;
  43.     LPGBSETINT      pSI;
  44.  
  45.     if (NULL==pGB)
  46.         return 0L;
  47.  
  48.     switch (iMsg)
  49.         {
  50.         case GBM_HWNDASSOCIATESET:
  51.             lRet=(LRESULT)(UINT)GBHwndAssociateSet(hWnd
  52.                 , (HWND)wParam);
  53.             break;
  54.  
  55.         case GBM_HWNDASSOCIATEGET:
  56.             lRet=(LRESULT)(UINT)GBHwndAssociateGet(hWnd);
  57.             break;
  58.  
  59.         case GBM_GIZMOADD:
  60.             pCG=(LPCREATEGIZMO)lParam;
  61.             lRet=(LRESULT)GBGizmoAdd(pCG->hWndParent, pCG->iType
  62.                 , pCG->iGizmo, pCG->uID, pCG->dx, pCG->dy
  63.                 , pCG->pszText, pCG->hBmp, pCG->iImage, pCG->uState);
  64.             break;
  65.  
  66.         case GBM_GIZMOREMOVE:
  67.             lRet=(LRESULT)GBGizmoRemove(hWnd, wParam);
  68.             break;
  69.  
  70.         case GBM_GIZMOSENDMESSAGE:
  71.             pMsg=(LPGBMSG)lParam;
  72.             lRet=GBGizmoSendMessage(hWnd, wParam, pMsg->iMsg
  73.                 , pMsg->wParam, pMsg->lParam);
  74.             break;
  75.  
  76.         case GBM_GIZMOSHOW:
  77.             lRet=(LRESULT)GBGizmoShow(hWnd, wParam
  78.                 , (BOOL)LOWORD(lParam));
  79.             break;
  80.  
  81.         case GBM_GIZMOENABLE:
  82.             lRet=(LRESULT)GBGizmoEnable(hWnd, wParam
  83.                 , (BOOL)LOWORD(lParam));
  84.             break;
  85.  
  86.         case GBM_GIZMOCHECK:
  87.             lRet=(LRESULT)GBGizmoCheck(hWnd, wParam
  88.                 , (BOOL)LOWORD(lParam));
  89.             break;
  90.  
  91.         case GBM_GIZMOFOCUSSET:
  92.             lRet=(LRESULT)GBGizmoFocusSet(hWnd, wParam);
  93.             break;
  94.  
  95.         case GBM_GIZMOEXIST:
  96.             lRet=(LRESULT)GBGizmoExist(hWnd, wParam);
  97.             break;
  98.  
  99.         case GBM_GIZMOTYPEGET:
  100.             lRet=(LRESULT)GBGizmoTypeGet(hWnd, wParam);
  101.             break;
  102.  
  103.         case GBM_GIZMODATASET:
  104.             lRet=(LRESULT)GBGizmoDataSet(hWnd, wParam
  105.                 , (DWORD)lParam);
  106.             break;
  107.  
  108.         case GBM_GIZMODATAGET:
  109.             lRet=(LRESULT)GBGizmoDataGet(hWnd, wParam);
  110.             break;
  111.  
  112.         case GBM_GIZMONOTIFYSET:
  113.             lRet=(LRESULT)GBGizmoNotifySet(hWnd, wParam
  114.                 , (BOOL)LOWORD(lParam));
  115.             break;
  116.  
  117.         case GBM_GIZMONOTIFYGET:
  118.             lRet=(LRESULT)GBGizmoNotifyGet(hWnd, wParam);
  119.             break;
  120.  
  121.         case GBM_GIZMOTEXTGET:
  122.             pGT=(LPGBGETTEXT)lParam;
  123.             lRet=(LRESULT)GBGizmoTextGet(hWnd, wParam, pGT->psz
  124.                 , pGT->cch);
  125.             break;
  126.  
  127.         case GBM_GIZMOTEXTSET:
  128.             GBGizmoTextSet(hWnd, wParam, (LPTSTR)lParam);
  129.             break;
  130.  
  131.         case GBM_GIZMOINTGET:
  132.             pGI=(LPGBGETINT)lParam;
  133.             lRet=(LRESULT)GBGizmoIntGet(hWnd, wParam, &pGI->fSuccess
  134.                 , pGI->fSigned);
  135.             break;
  136.  
  137.  
  138.         case GBM_GIZMOINTSET:
  139.             pSI=(LPGBSETINT)lParam;
  140.             GBGizmoIntSet(hWnd, wParam, pSI->uValue, pSI->fSigned);
  141.             break;
  142.  
  143.         default:
  144.             break;
  145.         }
  146.  
  147.     return lRet;
  148.     }
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159. /*
  160.  * PGizmoFromHwndID
  161.  *
  162.  * Purpose:
  163.  *  Retrieves the pGizmo for the given GizmoBar and the gizmo ID.
  164.  *
  165.  * Parameters:
  166.  *  hWnd            HWND of a GizmoBar.
  167.  *  uID             UINT gizmo identifier.
  168.  *
  169.  * Return Value:
  170.  *  PGIZMO          NULL if the gizmo does not exist or hWnd is
  171.  *                  invalid.  Non-NULL PGIZMO otherwise.
  172.  */
  173.  
  174. PGIZMO PGizmoFromHwndID(HWND hWnd, UINT uID)
  175.     {
  176.     PGIZMOBAR     pGB;
  177.  
  178.     if (!IsWindow(hWnd))
  179.         return FALSE;
  180.  
  181.     pGB=(PGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE);
  182.  
  183.     if (NULL==pGB)
  184.         return FALSE;
  185.  
  186.     return GizmoPFind(&pGB->pGizmos, uID);
  187.     }
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194. /*
  195.  * GBHwndAssociateSet
  196.  *
  197.  * Purpose:
  198.  *  Changes the associate window of a GizmoBar.
  199.  *
  200.  * Parameters:
  201.  *  hWnd            HWND of the control window.
  202.  *
  203.  * Set Parameters:
  204.  *  hWndAssociate   HWND of new associate.
  205.  *
  206.  * Return Value:
  207.  *  HWND            Handle of previous associate.
  208.  */
  209.  
  210. HWND WINAPI GBHwndAssociateSet(HWND hWnd, HWND hWndNew)
  211.     {
  212.     HWND        hWndOld=NULL;
  213.     PGIZMOBAR   pGB;
  214.  
  215.     pGB=(PGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE);
  216.  
  217.     if (NULL!=pGB)
  218.         {
  219.         hWndOld=pGB->hWndAssociate;
  220.         pGB->hWndAssociate=hWndNew;
  221.  
  222.         if (NULL!=hWndOld)
  223.             SendCommand(hWndOld, pGB->uID, GBN_ASSOCIATELOSS, hWnd);
  224.  
  225.         if (NULL!=hWndNew)
  226.             SendCommand(hWndNew, pGB->uID, GBN_ASSOCIATEGAIN, hWnd);
  227.         }
  228.  
  229.     return hWndOld;
  230.     }
  231.  
  232.  
  233.  
  234.  
  235.  
  236. /*
  237.  * GBHwndAssociateGet
  238.  *
  239.  * Purpose:
  240.  *  Retrieves the associate window of a GizmoBar
  241.  *
  242.  * Parameters:
  243.  *  hWnd            HWND of the control window.
  244.  *
  245.  * Set Parameters:
  246.  *  hWndAssociate   HWND of new associate.
  247.  *
  248.  * Return Value:
  249.  *  HWND            Handle of current associate.
  250.  */
  251.  
  252. HWND WINAPI GBHwndAssociateGet(HWND hWnd)
  253.     {
  254.     HWND        hWndOld=NULL;
  255.     PGIZMOBAR   pGB;
  256.  
  257.     pGB=(PGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE);
  258.  
  259.     if (NULL!=pGB)
  260.         hWndOld=pGB->hWndAssociate;
  261.  
  262.     return hWndOld;
  263.     }
  264.  
  265.  
  266.  
  267.  
  268.  
  269. /*
  270.  * GBGizmoAdd
  271.  *
  272.  * Purpose:
  273.  *  Creates a new gizmo on the GizmoBar.  Subsequent operations
  274.  *  should be done using the identifier, uID, for this gizmo.
  275.  *
  276.  * Parameters:
  277.  *  hWnd            HWND of the GizmoBar.
  278.  *  iType           UINT type of the gizmo to create.
  279.  *  iGizmo          UINT position (zero-based) at which to place the
  280.  *                  gizmo.
  281.  *  uID             UINT identifier for WM_COMMAND from this gizmo.
  282.  *  dx, dy          UINT dimensions of the gizmo.
  283.  *  pszText         LPTSTR initial text for edit, list, combo, and
  284.  *                  text gizmos.
  285.  *  hBitmap         HBITMAP for gizmos of the button types (COMMAND
  286.  *                  or ATTRIBUTE) specifies a source bitmap from
  287.  *                  which the button image is taken.
  288.  *  iImage          UINT index into hBitmap for the image for this
  289.  *                  button.
  290.  *  uState          UINT initial state of the gizmo.
  291.  *
  292.  * Return Value:
  293.  *  BOOL            TRUE if creation succeeded, FALSE otherwise.
  294.  */
  295.  
  296. BOOL WINAPI GBGizmoAdd(HWND hWnd, UINT iType, UINT iGizmo, UINT uID
  297.     , UINT dx, UINT dy, LPTSTR pszText, HBITMAP hBmp, UINT iImage
  298.     , UINT uState)
  299.     {
  300.     BOOL        fSuccess;
  301.     PGIZMOBAR   pGB;
  302.     PGIZMO      pGizmo;
  303.  
  304.     if (!IsWindow(hWnd))
  305.         return FALSE;
  306.  
  307.     pGB=(PGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE);
  308.  
  309.     if (NULL==pGB)
  310.         return FALSE;
  311.  
  312.     /*
  313.      * This automatically creates the windows, allocates structures,
  314.      * includes the gizmo in pGB->pGizmos, and so forth.
  315.      */
  316.     pGizmo=GizmoPAllocate(&fSuccess, &pGB->pGizmos, hWnd, iType
  317.         , iGizmo, uID, dx, dy, pszText, hBmp, iImage, uState);
  318.  
  319.     if (fSuccess)
  320.         {
  321.         if (NULL!=pGB->hWndAssociate)
  322.             {
  323.             SendCommand(pGB->hWndAssociate,GBN_GIZMOADDED, pGB->uID
  324.                 , hWnd);
  325.             }
  326.  
  327.         InvalidateRect(hWnd, NULL, TRUE);
  328.         UpdateWindow(hWnd);
  329.         }
  330.     else
  331.         GizmoPFree(&pGB->pGizmos, pGizmo);
  332.  
  333.     return fSuccess;
  334.     }
  335.  
  336.  
  337.  
  338.  
  339.  
  340. /*
  341.  * GBGizmoRemove
  342.  *
  343.  * Purpose:
  344.  *  Removes an existing gizmo from the GizmoBar.
  345.  *
  346.  * Parameters:
  347.  *  hWnd            HWND of the GizmoBar.
  348.  *  uID             UINT identifier for this gizmo.
  349.  *
  350.  * Return Value:
  351.  *  BOOL            TRUE if deletion succeeded, FALSE otherwise.
  352.  */
  353.  
  354. BOOL WINAPI GBGizmoRemove(HWND hWnd, UINT uID)
  355.     {
  356.     PGIZMOBAR   pGB;
  357.     PGIZMO      pGizmo;
  358.  
  359.     if (!IsWindow(hWnd))
  360.         return FALSE;
  361.  
  362.     pGB=(PGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE);
  363.  
  364.     if (NULL==pGB)
  365.         return FALSE;
  366.  
  367.     pGizmo=GizmoPFind(&pGB->pGizmos, uID);
  368.  
  369.     if (NULL==pGizmo)
  370.         return FALSE;
  371.  
  372.     GizmoPFree(&pGB->pGizmos, pGizmo);
  373.  
  374.     if (NULL!=pGB->hWndAssociate)
  375.         {
  376.         SendCommand(pGB->hWndAssociate, GBN_GIZMOREMOVED, pGB->uID
  377.             , hWnd);
  378.         }
  379.  
  380.     InvalidateRect(hWnd, NULL, TRUE);
  381.     UpdateWindow(hWnd);
  382.     return TRUE;
  383.     }
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390. /*
  391.  * GBGizmoSendMessage
  392.  *
  393.  * Purpose:
  394.  *  Implements the equivalent of SendMessage to a gizmo in the
  395.  *  GizmoBar.  Separators, command buttons, and attribute buttons
  396.  *  do not accept messages.
  397.  *
  398.  * Parameters:
  399.  *  hWnd            HWND of the GizmoBar.
  400.  *  uID             UINT identifier of the gizmo to affect.
  401.  *  iMsg            UINT message to send.
  402.  *  wParam          WPARAM of the message.
  403.  *  lParam          LPARAM of the message.
  404.  *
  405.  * Return Value:
  406.  *  LRESULT         Return value from the message.  0L if the
  407.  *                  gizmo does not accept messages.
  408.  */
  409.  
  410. LRESULT WINAPI GBGizmoSendMessage(HWND hWnd, UINT uID, UINT iMsg
  411.     , WPARAM wParam, LPARAM lParam)
  412.     {
  413.     PGIZMO      pGizmo;
  414.     LONG        lRet=0L;
  415.  
  416.     pGizmo=PGizmoFromHwndID(hWnd, uID);
  417.  
  418.     if (NULL!=pGizmo && NULL!=pGizmo->hWnd)
  419.         lRet=SendMessage(pGizmo->hWnd, iMsg, wParam, lParam);
  420.  
  421.     return lRet;
  422.     }
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429. /*
  430.  * GBGizmoShow
  431.  *
  432.  * Purpose:
  433.  *  Shows or hides a control, adjusting the positions of all others
  434.  *  to make room for or reuse the space for this control.
  435.  *
  436.  * Parameters:
  437.  *  hWnd            HWND of the GizmoBar.
  438.  *  uID             UINT identifier of the gizmo to affect.
  439.  *  fShow           BOOL TRUE to show the gizmo, FALSE to hide it.
  440.  *
  441.  * Return Value:
  442.  *  BOOL            TRUE if the function was successful, FALSE
  443.  *                  otherwise.
  444.  */
  445.  
  446. BOOL WINAPI GBGizmoShow(HWND hWnd, UINT uID, BOOL fShow)
  447.     {
  448.     BOOL        fRet=FALSE;
  449.     PGIZMO      pGizmo;
  450.  
  451.     pGizmo=PGizmoFromHwndID(hWnd, uID);
  452.  
  453.     if (NULL!=pGizmo)
  454.         {
  455.         if (fShow && pGizmo->fHidden)
  456.             {
  457.             if (NULL!=pGizmo->hWnd)
  458.                 ShowWindow(pGizmo->hWnd, SW_SHOWNORMAL);
  459.  
  460.             GizmosExpand(pGizmo);
  461.             }
  462.  
  463.         if (!fShow && !pGizmo->fHidden)
  464.             {
  465.             if (NULL!=pGizmo->hWnd)
  466.                 ShowWindow(pGizmo->hWnd, SW_HIDE);
  467.  
  468.             GizmosCompact(pGizmo);
  469.             }
  470.  
  471.         //This will be right even if we didn't change anything.
  472.         pGizmo->fHidden=!fShow;
  473.         }
  474.  
  475.     InvalidateRect(hWnd, NULL, TRUE);
  476.     UpdateWindow(hWnd);
  477.     return fRet;
  478.     }
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485. /*
  486.  * GBGizmoEnable
  487.  *
  488.  * Purpose:
  489.  *  Enables or disables a control on the GizmoBar.
  490.  *
  491.  * Parameters:
  492.  *  hWnd            HWND of the GizmoBar.
  493.  *  uID             UINT identifier of the gizmo to affect.
  494.  *  fEnable         BOOL TRUE to enable the gizmo, FALSE otherwise.
  495.  *
  496.  * Return Value:
  497.  *  BOOL            TRUE if the gizmo was previously disabled, FALSE
  498.  *                  otherwise.
  499.  */
  500.  
  501. BOOL WINAPI GBGizmoEnable(HWND hWnd, UINT uID, BOOL fEnable)
  502.     {
  503.     PGIZMO      pGizmo;
  504.     BOOL        fRet=FALSE;
  505.  
  506.     pGizmo=PGizmoFromHwndID(hWnd, uID);
  507.  
  508.     if (NULL==pGizmo)
  509.         return FALSE;
  510.  
  511.     fRet=(BOOL)(BUTTONGROUP_DISABLED & pGizmo->uState);
  512.  
  513.     //Use windows to enable or disable window gizmos
  514.     if (NULL!=pGizmo->hWnd)
  515.         EnableWindow(pGizmo->hWnd, fEnable);
  516.     else
  517.         {
  518.         /*
  519.          * If we're not down, command and attribute buttons act
  520.          * the same.
  521.          */
  522.         if (!(BUTTONGROUP_DOWN & pGizmo->uState))
  523.             {
  524.             GizmoPStateSet(hWnd, pGizmo, fEnable
  525.                 ? COMMANDBUTTON_UP : COMMANDBUTTON_DISABLED);
  526.             }
  527.         else
  528.             {
  529.             /*
  530.              * Attribute buttons are a little more sensitive with
  531.              * DOWNDISABLED
  532.              */
  533.             GizmoPStateSet(hWnd, pGizmo, fEnable
  534.                 ? ATTRIBUTEBUTTON_DOWN
  535.                 : ATTRIBUTEBUTTON_DOWNDISABLED);
  536.             }
  537.         }
  538.  
  539.     return fRet;
  540.     }
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548. /*
  549.  * GBGizmoCheck
  550.  *
  551.  * Purpose:
  552.  *  Checks or unchecks an attribute button in the GizmoBar.  If the
  553.  *  gizmo is part of a group of mutually exclusive attributes, then
  554.  *  other gizmos are unchecked when this one is checked.  If this is
  555.  *  the only one checked in these circumstances, this function is a
  556.  *  NOP.
  557.  *
  558.  * Parameters:
  559.  *  hWnd            HWND of the GizmoBar.
  560.  *  uID             UINT identifier of the gizmo to affect.
  561.  *  fCheck          BOOL TRUE to check this gizmo, FALSE to uncheck.
  562.  *
  563.  * Return Value:
  564.  *  BOOL            TRUE if the change took place.  FALSE otherwise.
  565.  */
  566.  
  567. BOOL WINAPI GBGizmoCheck(HWND hWnd, UINT uID, BOOL fCheck)
  568.     {
  569.     PGIZMOBAR   pGB;
  570.     PGIZMO      pGizmo;
  571.  
  572.     if (!IsWindow(hWnd))
  573.         return FALSE;
  574.  
  575.     pGB=(PGIZMOBAR)GetWindowLong(hWnd, GBWL_STRUCTURE);
  576.  
  577.     if (NULL==pGB)
  578.         return FALSE;
  579.  
  580.     pGizmo=GizmoPFind(&pGB->pGizmos, uID);
  581.  
  582.     if (NULL!=pGizmo)
  583.         GizmoPCheck(hWnd, pGizmo, fCheck);
  584.  
  585.     return TRUE;
  586.     }
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593. /*
  594.  * GBGizmoFocusSet
  595.  *
  596.  * Purpose:
  597.  *  Sets the focus to a partuclar gizmo in the gizmo if that gizmo
  598.  *  can accept the focus.  Separators, attribute buttons, text,
  599.  *  and command buttons cannot have the focus.
  600.  *
  601.  * Parameters:
  602.  *  hWnd            HWND of the GizmoBar.
  603.  *  uID             UINT identifier of the gizmo to affect.
  604.  *
  605.  * Return Value:
  606.  *  BOOL            TRUE if the focus was set.  FALSE otherwise,
  607.  *                  such as when uID identifies a control that cannot
  608.  *                  have focus.
  609.  */
  610.  
  611. UINT WINAPI GBGizmoFocusSet(HWND hWnd, UINT uID)
  612.     {
  613.     PGIZMO      pGizmo;
  614.     BOOL        fRet=FALSE;
  615.  
  616.     pGizmo=PGizmoFromHwndID(hWnd, uID);
  617.  
  618.     if (NULL!=pGizmo && NULL!=pGizmo->hWnd)
  619.         {
  620.         fRet=TRUE;
  621.         SetFocus(pGizmo->hWnd);
  622.         }
  623.  
  624.     return fRet;
  625.     }
  626.  
  627.  
  628.  
  629.  
  630.  
  631. /*
  632.  * GBGizmoExist
  633.  *
  634.  * Purpose:
  635.  *  Determines if a gizmo of a given identifier exists in the
  636.  *  GizmoBar.
  637.  *
  638.  * Parameters:
  639.  *  hWnd            HWND of the GizmoBar.
  640.  *  uID             UINT identifier to verify.
  641.  *
  642.  * Return Value:
  643.  *  BOOL            TRUE if the gizmo exists, FALSE otherwise.
  644.  */
  645.  
  646. BOOL WINAPI GBGizmoExist(HWND hWnd, UINT uID)
  647.     {
  648.     return (NULL!=PGizmoFromHwndID(hWnd, uID));
  649.     }
  650.  
  651.  
  652.  
  653.  
  654.  
  655. /*
  656.  * GBGizmoTypeGet
  657.  *
  658.  * Purpose:
  659.  *  Returns the type of the gizmo specified by the given identifer.
  660.  *
  661.  * Parameters:
  662.  *  hWnd            HWND of the GizmoBar.
  663.  *  uID             UINT identifier to find.
  664.  *
  665.  * Return Value:
  666.  *  int             A GIZMOTYPE_* value if the function is
  667.  *                  successful, otherwise -1.
  668.  */
  669.  
  670. int WINAPI GBGizmoTypeGet(HWND hWnd, UINT uID)
  671.     {
  672.     int         iRet=-1;
  673.     PGIZMO      pGizmo;
  674.  
  675.     pGizmo=PGizmoFromHwndID(hWnd, uID);
  676.  
  677.     if (NULL!=pGizmo)
  678.         iRet=pGizmo->iType;
  679.  
  680.     return iRet;
  681.     }
  682.  
  683.  
  684.  
  685.  
  686.  
  687. /*
  688.  * GBGizmoDataSet
  689.  * GBGizmoDataGet
  690.  *
  691.  * Purpose:
  692.  *  Sets or retrieves an extra DWORD value associated with the given
  693.  *  gizmo.  Applications can store any information here they please.
  694.  *
  695.  * Parameters:
  696.  *  hWnd            HWND of the GizmoBar.
  697.  *  uID             UINT identifier of the gizmo.
  698.  *  dwData          (Set only) DWORD data to store with the gizmo.
  699.  *
  700.  * Return Value:
  701.  *  DWORD           Set:  Previous value
  702.  *                  Get:  Current value
  703.  */
  704.  
  705. DWORD WINAPI GBGizmoDataSet(HWND hWnd, UINT uID, DWORD dwData)
  706.     {
  707.     PGIZMO      pGizmo;
  708.     DWORD       dw=0L;
  709.  
  710.     pGizmo=PGizmoFromHwndID(hWnd, uID);
  711.  
  712.     if (NULL!=pGizmo)
  713.         {
  714.         dw=pGizmo->dwData;
  715.         pGizmo->dwData=dwData;
  716.         }
  717.  
  718.     return dw;
  719.     }
  720.  
  721.  
  722.  
  723. DWORD WINAPI GBGizmoDataGet(HWND hWnd, UINT uID)
  724.     {
  725.     PGIZMO      pGizmo;
  726.     DWORD       dw=0L;
  727.  
  728.     pGizmo=PGizmoFromHwndID(hWnd, uID);
  729.  
  730.     if (NULL!=pGizmo)
  731.         dw=pGizmo->dwData;
  732.  
  733.     return dw;
  734.     }
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741. /*
  742.  * GBGizmoNotifySet
  743.  * GBGizmoNotifyGet
  744.  *
  745.  * Purpose:
  746.  *  Sets or retrieves the notify status of a gizmo.  If notify is
  747.  *  FALSE, the no WM_COMMAND messages are sent from the GizmoBar to
  748.  *  the parent window when this gizmo is used.
  749.  *
  750.  * Parameters:
  751.  *  hWnd            HWND of the GizmoBar.
  752.  *  uID             UINT identifier of the gizmo.
  753.  *  fNotify         (Set only) BOOL new notify status to set.
  754.  *
  755.  * Return Value:
  756.  *  BOOL            Set:  Previous value of the notify flag.
  757.  *                  Get:  Current value of the notify flag.
  758.  */
  759.  
  760. BOOL WINAPI GBGizmoNotifySet(HWND hWnd, UINT uID, BOOL fNotify)
  761.     {
  762.     PGIZMO      pGizmo;
  763.     BOOL        fRet=FALSE;
  764.  
  765.     pGizmo=PGizmoFromHwndID(hWnd, uID);
  766.  
  767.     if (NULL!=pGizmo)
  768.         {
  769.         fRet=pGizmo->fNotify;
  770.         pGizmo->fNotify=fNotify;
  771.         }
  772.  
  773.     return fRet;
  774.     }
  775.  
  776.  
  777. BOOL WINAPI GBGizmoNotifyGet(HWND hWnd, UINT uID)
  778.     {
  779.     PGIZMO      pGizmo;
  780.     BOOL        fRet=FALSE;
  781.  
  782.     pGizmo=PGizmoFromHwndID(hWnd, uID);
  783.  
  784.     if (NULL!=pGizmo)
  785.         fRet=pGizmo->fNotify;
  786.  
  787.     return fRet;
  788.     }
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. /*
  797.  * GBGizmoTextSet
  798.  * GBGizmoTextGet
  799.  *
  800.  * Purpose:
  801.  *  Retrieves or sets text in a GizmoBar gizmo.  Separators, command
  802.  *  buttons, and attribute buttons are not affected by this call.
  803.  *
  804.  * Parameters:
  805.  *  hWnd            HWND of the GizmoBar.
  806.  *  uID             UINT identifying the gizmo.
  807.  *  psz             LPTSTR (Set) providing the text to show in the
  808.  *                  window or (Get) pointing to a buffer to receive
  809.  *                  the text.
  810.  *  cch             (Get only) UINT maximum number of chars to copy
  811.  *                  to psz.
  812.  *
  813.  * Return Value:
  814.  *  int             Number of characters copied to psz.
  815.  */
  816.  
  817. void WINAPI GBGizmoTextSet(HWND hWnd, UINT uID, LPTSTR psz)
  818.     {
  819.     //This fails on non-windowed gizmos anyway, so we don't check.
  820.     SetDlgItemText(hWnd, uID, psz);
  821.     return;
  822.     }
  823.  
  824.  
  825. int WINAPI GBGizmoTextGet(HWND hWnd, UINT uID, LPTSTR psz, UINT cch)
  826.     {
  827.     //This fails on non-windowed gizmos anyway, so we don't check.
  828.     return GetDlgItemText(hWnd, uID, psz, cch);
  829.     }
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838. /*
  839.  * GBGizmoIntSet
  840.  * GBGizmoIntGet
  841.  *
  842.  * Purpose:
  843.  *  Retrieves or sets an integer in a GizmoBar gizmo.  Separators,
  844.  *  command buttons, and attribute buttons are not affected by this
  845.  *  call.
  846.  *
  847.  * Parameters:
  848.  *  hWnd            HWND of the GizmoBar.
  849.  *  uID             UINT identifying the gizmo.
  850.  *
  851.  *  (Set only)
  852.  *  u               UINT value to set in the gizmo.
  853.  *  fSigned         BOOL TRUE to indicate if the value is signed.
  854.  *
  855.  *  (Get only)
  856.  *  pfTrans         BOOL FAR * in which the success of the function
  857.  *                  is returned.
  858.  *  fSigned         BOOL TRUE to indicate if the value is signed.
  859.  *
  860.  * Return Value:
  861.  *  (Set): None
  862.  *  (Get): UINT     Integer translation of the gizmo's text.
  863.  */
  864.  
  865. void WINAPI GBGizmoIntSet(HWND hWnd, UINT uID, UINT u, BOOL fSigned)
  866.     {
  867.     //This fails on non-windowed gizmos anyway, so we don't check.
  868.     SetDlgItemInt(hWnd, uID, u, fSigned);
  869.     return;
  870.     }
  871.  
  872.  
  873.  
  874. UINT WINAPI GBGizmoIntGet(HWND hWnd, UINT uID, BOOL FAR *pfTrans
  875.     , BOOL fSigned)
  876.     {
  877.     //This fails on non-windowed gizmos anyway, so we don't check.
  878.     return GetDlgItemInt(hWnd, uID, pfTrans, fSigned);
  879.     }
  880.