#include "Ltdic.h"

virtual L_UINT16 LDicomDir::OnInsertDicomFile(pszFileName, pDataSet, uStatus)

Called for each DICOM file enumerated by LDicomDir::InsertDicomFile.


const L_TCHAR* pszFileName

Character string that contains the name of the file being added to the DICOM Directory.

LDicomDS* pDataSet

Pointer to an LDicomDS object that specifies the Data Set contained by the DICOM file being processed. If the Data Set wasnt loaded successfully, this parameter is set to NULL.

L_UINT16 uStatus

The status code. Possible values are:

Value Meaning
DICOMDIR_INSERTDICOMFILE_PREADD [300] The Data Set in the file was loaded successfully and the file is about to be added to the DICOM Directory.
DICOM_SUCCESS [0] The file has been added successfully to the DICOM Directory.
Any other value [> 0] An error occurred. Refer to Return Codes.


Value Meaning
0 The function was successful.
> 0 An error occurred. Refer to Return Codes.


If the parameter passed to LDicomDir::InsertDicomFile is NULL, then all files in the destination folder will be enumerated. If the bIncludeSubfolders member of a DICOMDIROPTIONS structure is set to TRUE and set using LDicomDir::SetOptions, and then LDicomDir::InsertDicomFile is called with pszFileName set to NULL, then all files in the destination folder and all files in all of the subfolders of the destination folder will be enumerated. For each file, the callback function OnInsertDicomFile is called once or twice:

If the callback function returned a value other than DICOM_SUCCESS or DICOM_ERROR_FORMAT, the function LDicomDir::InsertDicomFile will stop adding new files and will return the same value returned by the callback function. Therefore, to keep adding the DICOM files, the callback function should return DICOM_SUCCESS, or DICOM_ERROR_FORMAT if only the current file is to be skipped (which can be done during the first call).

The function LDicomDir::InsertDicomFile will stop adding new files if an error occurred and it will return an error value.

The implementation of the LDicomDir class for the function OnInsertDicomFile simply returns DICOM_SUCCESS. In order to make use of this callback function, you should create a new class derived from the LDicomDir class and override the function OnInsertDicomFile providing the desired implementation.

Required DLLs and Libraries


Win32, x64

See Also




class LUserDicomDir : public LDicomDir 
   LUserDicomDir(L_TCHAR* pszDICOMDIRDstFolder = NULL, L_TCHAR* pszPath = NULL) : 
      LDicomDir(pszDICOMDIRDstFolder, pszPath) { } 
   L_UINT16 OnInsertDicomFile(const L_TCHAR* pszFileName, LDicomDS* pDataSet, L_UINT16 uStatus) 
      L_TCHAR szBuffer[512]; 
         wsprintf(szBuffer, TEXT("About to add the file \"%s\".\n\nProceed?"), pszFileName); 
         switch (MessageBox(NULL, szBuffer, TEXT("DICOM Directory Sample"), MB_YESNOCANCEL)) 
         case IDYES: // Add the file 
         case IDNO: // Skip the file 
            return DICOM_ERROR_FORMAT; 
         case IDCANCEL: // Abort 
            return DICOM_ERROR_END; 
      else if (uStatus == DICOM_SUCCESS) 
         wsprintf(szBuffer, TEXT("The file \"%s\" has been added successfully.\n\nContinue?"), pszFileName); 
         switch (MessageBox(NULL, szBuffer, TEXT("DICOM Directory Sample"), MB_YESNO)) 
         case IDYES: // Continue 
         case IDNO: // Abort 
            return DICOM_ERROR_END; 
      return DICOM_SUCCESS; 
L_INT LDicomDir_OnInsertDicomFileExample() 
   L_INT nRet; 
   LUserDicomDir DicomDir(MAKE_IMAGE_PATH(TEXT(""))); 
   // Add all the DICOM files to the Directory 
   nRet = DicomDir.InsertDicomFile(NULL); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   // Save the DICOMDIR File 
   nRet = DicomDir.SaveDicomDir(); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   return DICOM_SUCCESS; 
Help Version 21.0.2021.4.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C++ Class Library Help