Gets the current action callback function along with the user data, which were set using L_DispContainerSetActionCallBack.
#include "ltivw.h"
L_LTIVW_API L_INT L_DispContainerGetActionCallBack(hCellWnd, ppfnCallBack, ppUserData)
A handle to the window that represents the Medical Viewer Cell.
Pointer to a pointer to a callback function to be updated with the last action callback function set using L_DispContainerSetActionCallBack.
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.
| Value | Meaning |
|---|---|
| SUCCESS | The function was successful. |
| < 1 | An error occurred. Refer to Return Codes. |
This function will add one cell and apply a custom action and tag on it.
// 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, * pFIRSTCELLDATA;// Tag call back will write the brightness value of the top left corner of the cell.L_INT EXT_CALLBACK TagCallBack(HWND hCellWnd,L_INT nCellIndex,HDC hDC,RECT * lpRect,L_VOID * pUserData){UNREFERENCED_PARAMETER(hCellWnd);pFIRSTCELLDATA pFirstCellData = (pFIRSTCELLDATA)pUserData;if (nCellIndex == 0){L_TCHAR a[10] = TEXT("\0");static LOGFONT lf;HFONT hFont, hOldFont;lf.lfHeight = lpRect->bottom - lpRect->top ;lf.lfItalic = TRUE;wsprintf(lf.lfFaceName, TEXT("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, TEXT("B = %d"), pFirstCellData->nValue);TextOut(hDC, lpRect->left, lpRect->top, a, lstrlen(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 EXT_CALLBACK ActionCallBack(HBITMAPLIST * phBitmapList,L_UINT uCount,L_INT nAction,L_UINT uMessage,L_UINT wParam,POINT * ptMousePos,L_VOID * pUserData){pFIRSTCELLDATA pFirstCellData = (pFIRSTCELLDATA)pUserData;L_INT nI;L_INT nCount;BITMAPHANDLE Bitmap;HWND hWnd;UNREFERENCED_PARAMETER(wParam);UNREFERENCED_PARAMETER(nAction);UNREFERENCED_PARAMETER(uCount);switch(uMessage){case WM_LBUTTONDOWN:pFirstCellData->nOldX = ptMousePos->x;break;case WM_MOUSEMOVE:L_GetBitmapListCount(phBitmapList[0], (L_UINT *)&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 101DISPCONTAINERACTIONCALLBACK pOldActionCallBack;DISPCONTAINERTAGCALLBACK pOldTagCallBack;L_INT DispContainerGetActionCallBackExample(HDISPCONTAINER hCon){L_INT nCellIndex;pFIRSTCELLDATA pFirstCellData;L_INT nCount;L_INT nRet;HBITMAPLIST hBitmapList;DISPOWNERACTIONPROPS OwnerActionProp;if (hCon == NULL)return ERROR_NO_MEMORY ;// removes all the cells and starts over again.nCount = L_DispContainerGetCellCount (hCon, 0);if (nCount){nRet = L_DispContainerRemoveCell(hCon, -1, 0);if(nRet != SUCCESS)return nRet;}// load a bitmap list.nRet = L_LoadBitmapList (MAKE_IMAGE_PATH(TEXT("Image2.cmp")), &hBitmapList, 0, ORDER_BGRORGRAY, NULL, NULL);// if the image is corrupted, not found, or not supported, the program will destroy the container and terminateif (nRet != SUCCESS){L_DispContainerDestroy (hCon, 0);return nRet;}HWND hConWnd = L_DispContainerGetWindowHandle(hCon, 0);HWND hCellWnd = L_DispContainerCreateCell(hConWnd, 0);// Insert a new cell at the end of the container cell queue.nCellIndex = L_DispContainerInsertCell (hCon, hCellWnd, -1, 0);// Attach the loaded bitmaplist to the newly inserted cell.nRet = L_DispContainerSetCellBitmapList (hCellWnd,hBitmapList,TRUE,0);if(nRet != SUCCESS)return nRet;// 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.nRet = L_DispContainerGetTagCallBack(hCellWnd, &pOldTagCallBack, NULL);if(nRet != SUCCESS)return nRet;nRet = L_DispContainerGetActionCallBack (hCellWnd, &pOldActionCallBack, NULL);if(nRet != SUCCESS)return nRet;// Add some tags to the cellnRet = L_DispContainerSetCellTag(hCellWnd, 0, DISPWIN_ALIGN_TOPLEFT, DISPWIN_TYPE_OWNERDRAW, NULL, 0);if(nRet != SUCCESS)return nRet;// add the custom action to the container.nRet = L_DispContainerAddAction(hCellWnd, CONTAINER_ACTION_BRIGHTNESS, 0);if(nRet != SUCCESS)return nRet;nRet = L_DispContainerSetAction (hCellWnd, CONTAINER_ACTION_BRIGHTNESS, CONTAINER_MOUSE_BUTTON_LEFT, DCACTION_ACTIVEONLY);if(nRet != SUCCESS)return nRet;OwnerActionProp.DispContainerActionProps.bCircularMouseMove = FALSE;OwnerActionProp.DispContainerActionProps.hCursor = NULL;OwnerActionProp.DispContainerActionProps.nChange = 100;OwnerActionProp.DispContainerActionProps.uStructSize = sizeof(DISPOWNERACTIONPROPS);nRet = L_DispContainerSetActionProperties(hCellWnd, CONTAINER_ACTION_BRIGHTNESS, 0, &OwnerActionProp, 0);if(nRet != SUCCESS)return nRet;pFirstCellData = (pFIRSTCELLDATA)GlobalAllocPtr(GHND, sizeof(FIRSTCELLDATA));pFirstCellData->nBrightness = 0;// Sets the new callback functions for the action and for the tag.nRet = L_DispContainerSetActionCallBack(hCellWnd, ActionCallBack, (L_VOID *)pFirstCellData);if(nRet != SUCCESS)return nRet;nRet = L_DispContainerSetTagCallBack(hCellWnd, TagCallBack, (L_VOID * )pFirstCellData);if(nRet != SUCCESS)return nRet;return SUCCESS;}