include "l_bitmap.h"

ularL_SetStatusCallBack

\

L_LTKRN_API L_VOID L_SetStatusCallBack(pfnCallback, pUserData, pfnOldCallback, ppOldUserData)

Sets the new status callback function and gets the old status callback.

Parameters

STATUSCALLBACK pfnCallback

Pointer to your callback function. The callback function must adhere to the function syntax specified in STATUSCALLBACK Function.

This callback function must return SUCCESS if the operation was successfully done, or any error if the function call was a failure. If the callback function returns a failure, the current function will terminate and return the same error that the callback returned.

L_VOID* pUserData

Void pointer that used to pass one or more additional parameters that the callback function needs.

To use this feature, assign a value to a variable or create a structure that contains as many fields as needed Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID*. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access the variable or structure.

If the additional parameters are not needed, pass NULL in this parameter.

STATUSCALLBACK * pfnOldCallback

Pointer to a variable which will be updated with the old status callback function.

L_VOID** ppOldUserData

Pointer to a variable which will be updated with the user data for the old status callback function.

Returns

None.

Comments

The status callback is returned through a parameter. You used to have to call L_GetStatusCallBack to get the user data prior to calling L_SetStatusCallback. Now you can get the old callback and set the new callback in one function call.

Use this function to specify a callback for any of the following functions:

Both the old status callback function and the user data required for the old status callback function are updated in the pfnOldCallback and ppOldUserData parameters, respectively.

  1. Call the L_SetStatusCallBack function, assigning its return value to a STATUSCALLBACK variable, and passing the pointer to your callback as the new value.

  2. Call the function that uses the callback (for example L_AverageFilterBitmap.

  3. Call the L_SetStatusCallBack function again, restoring the original value by passing the variable that you saved in Step 1.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

/* This is the STATUSCALLBACK function, which stops the process if the user has pressed the interrupt key. */ 
L_BOOL KillProgress; 
 
L_INT EXT_CALLBACK StatusCallBack (L_INT nPercent, L_VOID *pUserData) 
{ 
   HWND hWnd=NULL; 
   L_TCHAR achMsg[80]; /* message string */ 
   MSG msg; 
 
   hWnd = (HWND)pUserData; 
 
   /* Let the application detect other events - good for cancel */ 
   while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) 
   { 
      TranslateMessage (&msg); 
      DispatchMessage (&msg); 
   } 
 
   /* Check the global variable and return an error if necessary */ 
   if (KillProgress) 
   { 
      wsprintf (achMsg, TEXT("Interrupted by the user with %d percent finished"),nPercent); 
      MessageBox (hWnd, achMsg, TEXT("Notice"), MB_OK); 
      return (ERROR_USER_ABORT); 
   } 
 
   wsprintf(achMsg, TEXT("Percentage: %d\n"), nPercent); 
   OutputDebugString(achMsg); 
 
   return SUCCESS; 
} 
 
/* This function uses L_SetStatusCallBack to implement the STATUSCALLBACK 
function when applying a median filter. */ 
L_INT SetStatusCallbackExample(BITMAPHANDLE *pBitmap) 
{ 
   STATUSCALLBACK lpfnOldStatusCB;  /* Pointer to the previous STATUSCALLBACK function */ 
   L_INT nRet=SUCCESS; 
   L_VOID * pOldData; /* Pointer to the user data for the previous status callback function */ 
   /* Set the STATUSCALLBACK function, saving the pointer to the previous one */ 
   L_SetStatusCallBack(StatusCallBack, NULL, &lpfnOldStatusCB, &pOldData ); 
   /* Apply an intentionally slow median filter with a neighborhood of 7x7 pixels */ 
   KillProgress = FALSE; 
 
   nRet = L_MedianFilterBitmap(pBitmap, 7, 0); 
   /* Restore the previous STATUSCALLBACK function */ 
   L_SetStatusCallBack (lpfnOldStatusCB, pOldData, NULL, NULL); 
   return nRet; 
} 
Help Version 21.0.2023.2.15
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.