L_DispContainerGetActionCallBack

#include "ltivw.h"

L_INT EXT_FUNCTION L_DispContainerGetActionCallBack(hCon, ppfnCallBack, ppUserData)

HDISPCONTAINER hCon;

/* handle to the container */

DISPCONTAINERACTIONCALLBACK L_FAR * ppfnCallBack;

/* pointer to be updated with the callback function */

LPVOID L_FAR * ppUserData;

/* void pointer to be updated with user data */

Gets the current action callback function along with the user data, which were set using L_DispContainerSetActionCallBack. This function is available only in the Medical Imaging Suite toolkits.

Parameter

Description

hCon

Handle to the container.

ppfnCallBack

Pointer to a pointer to a callback function to be updated with the last action callback function set using L_DispContainerSetActionCallBack.

ppUserData

Void pointer to be updated with the value of user defined data associated with the tag callback. If you are not interested in the user-defined data, pass NULL for this parameter.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Required DLLs and Libraries

LTIVW

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

L_DispContainerSetTagCallBack, L_DispContainerGetTagCallBack, L_DispContainerSetActionCallBack, DISPCONTAINERTAGCALLBACK, DISPCONTAINERACTIONCALLBACK

Topics:

Applying Actions

 

Image Viewer Functions: Applying Actions

Example

// This structure will be the user data to sent for both action and tag callback.
typedef struct tagFIRSTCELLDATA
{
   L_INT       nValue;
   L_INT       nOldX;
   L_INT       nBrightness;
}
FIRSTCELLDATA, L_FAR * pFIRSTCELLDATA;


// Tag call back will write the brightness value of the top left corner of the cell.
L_INT L_FAR L_EXPORT TagCallBack(L_INT          nCellIndex,
                                 HDC            hDC,
                                 RECT L_FAR *   lpRect,
                                 L_VOID L_FAR * pUserData)
{
  pFIRSTCELLDATA pFirstCellData = (pFIRSTCELLDATA)pUserData;
  if (nCellIndex == 0)
   {
      L_TCHAR a[10] = "\0";
      static LOGFONT lf;
      HFONT hFont, hOldFont;
      lf.lfHeight = RECTHEIGHT(lpRect);
      lf.lfItalic = TRUE;
      wsprintf(lf.lfFaceName, "Times new Roman\0");
      SetTextAlign(hDC, TA_LEFT | TA_TOP);
      SetTextColor(hDC, RGB(255, 255, 255));
      hFont = CreateFontIndirect(&lf);
      hOldFont = SelectFont(hDC, hFont);
      if (pUserData != NULL)
         wsprintf(a, "B = %d", pFirstCellData->nValue);
      TextOut(hDC, lpRect->left, lpRect->top, a, strlen(a));
      SelectFont(hDC, hOldFont);
      DeleteFont(hFont);
   }

   return TRUE;
}

// This callback is called every time the user clicks on the left mouse button.
// This will modifies the brightness value as the user drags the mouse cursor to the left or to the right
// this function applies the brightness effect only on the first cell.
L_INT L_FAR L_EXPORT ActionCallBack(HBITMAPLIST L_FAR * phBitmapList,
                                    L_UINT                    uCount,
                                    L_INT                       nAction,
                                    L_UINT                    uMessage,
                                    L_UINT                    wParam,
                                    POINT L_FAR *     ptMousePos,
                                    L_VOID L_FAR *  pUserData)
{
   pFIRSTCELLDATA pFirstCellData = (pFIRSTCELLDATA)pUserData;
   L_INT          nI;
   L_INT          nCount;
   BITMAPHANDLE   Bitmap;
   HWND           hWnd;   

   switch(uMessage)
   {

   case WM_LBUTTONDOWN:
      pFirstCellData->nOldX = ptMousePos->x;
      break;
   case WM_MOUSEMOVE:
      L_GetBitmapListCount(phBitmapList[0], &nCount);

      pFirstCellData->nValue = pFirstCellData->nBrightness + ptMousePos->x - pFirstCellData->nOldX;
      pFirstCellData->nValue = max(-1000, min(1000, pFirstCellData->nValue));

      for (nI = 0; nI < nCount; nI++)
      {
         L_GetBitmapListItem (phBitmapList[0], nI, &Bitmap, sizeof(BITMAPHANDLE));
         L_SetPaintContrast (&Bitmap, pFirstCellData->nValue);
         L_SetBitmapListItem (phBitmapList[0], nI, &Bitmap);
      }

      // redraw the cell.
      hWnd = L_DispContainerGetCellWindowHandle(hCon, 0, 0);
      InvalidateRect(hWnd, NULL, FALSE);
      break;

   case WM_LBUTTONUP:
      pFirstCellData->nBrightness = pFirstCellData->nValue;

      break;
   }
   return TRUE;
}


#define CONTAINER_ACTION_BRIGHTNESS 100
DISPCONTAINERACTIONCALLBACK pOldActionCallBack;
DISPCONTAINERTAGCALLBACK    pOldTagCallBack;

// this function will add one cell and apply a custom action and tag on it.
L_VOID CreateCustomAction(HDISPCONTAINER hCon)
{
   L_INT                   nCellIndex;
   pFIRSTCELLDATA          pFirstCellData;
   L_INT                   nCount;
   L_INT                   nRet;
   HBITMAPLIST             hBitmapList;
   DISPOWNERACTIONPROPS    OwnerActionProp;

   if (hCon == NULL)
      return;

   // removes all the cells and starts over again.
   nCount = L_DispContainerGetCellCount (hCon, 0);
   if (nCount)
      L_DispContainerRemoveCell(hCon, -1, TRUE, 0);

   // load a bitmap list.
   nRet = L_LoadBitmapList ("C:/Image3.dic", &hBitmapList, 0, ORDER_BGRORGRAY, NULL, NULL);

   // if the image is corrupted, not found, or not supported, the program will destroy the container and terminate
   if (nRet != SUCCESS)
   {
      L_DispContainerDestroy (hCon, FALSE, 0);
      return;
   }

   // Insert a new cell at the end of the container cell queue.
   nCellIndex = L_DispContainerInsertCell (hCon, -1, 0);

   // Attach the loaded bitmaplist to the newly inserted cell.
   nRet = L_DispContainerSetCellBitmapList (hCon,
                                           nCellIndex,
                                           hBitmapList,
                                           TRUE,
                                           0);

   // Get the old action and tag callback.
   // We assumed here that there is neither old user data exist for the tag nor for the action.
   L_DispContainerGetTagCallBack(hCon, &pOldTagCallBack, NULL);
   L_DispContainerGetActionCallBack (hCon, &pOldActionCallBack, NULL);

   // Add some tags to the cell
   L_DispContainerSetCellTag(hCon, nCellIndex, 0, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_OWNERDRAW, NULL, 0);

   // add the custom action to the container.
   L_DispContainerAddAction(hCon, CONTAINER_ACTION_BRIGHTNESS, 0);
   nRet = L_DispContainerSetAction (hCon, CONTAINER_ACTION_BRIGHTNESS, CONTAINER_MOUSE_BUTTON_LEFT, DCACTION_ACTIVEONLY);
   OwnerActionProp.DispContainerActionProps.bCircularMouseMove = FALSE;
   OwnerActionProp.DispContainerActionProps.hCursor = NULL;
   OwnerActionProp.DispContainerActionProps.nChange = 100;
   OwnerActionProp.DispContainerActionProps.uStructSize = sizeof(DISPOWNERACTIONPROPS);

   L_DispContainerSetActionProperties(hCon, CONTAINER_ACTION_BRIGHTNESS, 0, 0, (long)&OwnerActionProp, 0);

   pFirstCellData = GlobalAllocPtr(GHND, sizeof(FIRSTCELLDATA));
   pFirstCellData->nBrightness = 0;

   // Sets the new callback functions for the action and for the tag.
   L_DispContainerSetActionCallBack(hCon, ActionCallBack, (L_VOID L_FAR *)pFirstCellData);
   L_DispContainerSetTagCallBack(hCon, TagCallBack, (L_VOID L_FAR * )pFirstCellData);
}