Using the DicomFileInsert Event (Delphi)
//global
LEADDicomDir1: TLEADDicomDir;
LEADDicomFactory1: TLEADDicomFactory;
Procedure TForm1.CreateDicomDir();
var
strLic: String;
DicomKernel: LEADDicomKernel;
begin
strLic:= 'LEADTOOLS OCX Copyright (c) 1991-2005 LEAD Technologies, Inc.';
DicomKernel:= LEADDicomFactory1.CreateObject ('LEADDicomKernel.LEADDicomKernel', strLic) as ILEADDicomKernel;
DicomKernel.UnlockSupport (L_SUPPORT_MEDICAL, L_KEY_MEDICAL);
if(DicomKernel.IsSupportLocked (L_SUPPORT_MEDICAL))then
begin
Application.MessageBox('Medical Support must be unlocked for this demo!', 'Error', MB_OK + MB_ICONEXCLAMATION);
Exit;
end;
// Set the destination folder
LEADDicomDir1.ResetDicomDir ('C:\Medical Images');
// Files in subfolders should also be included
LEADDicomDir1.IncludeSubfolders:= True;
// Add all the DICOM files to the Directory
LEADDicomDir1.InsertDicomFile ('');
// Save the DICOMDIR File
LEADDicomDir1.SaveDicomDir ();
end;
procedure TForm1.LEADDicomDir1DicomFileInsert(ASender: TObject;
const bstrFileName: WideString; hDicomDS: Integer; nStatus: Smallint;
out pReturnVal: Smallint);
var
strBuffer: String;
nResult: Integer;
begin
if(nStatus = DICOMDIR_INSERTDICOMFILE_PREADD)then
begin
strBuffer:= 'About to add the file ''' + bstrFileName + '''.' + Chr(13) + Chr(13) + 'Proceed?';
nResult:= Application.MessageBox(PChar(strBuffer), 'DICOM Directory Sample', MB_YESNOCANCEL);
if(nResult = mrNo)then
begin
pReturnVal:= DICOM_ERROR_FORMAT; // Skip the file
Exit;
end
else
begin
if(nResult = mrCancel)then
begin
pReturnVal:= DICOM_ERROR_END; // Abort
Exit;
end;
end;
end
else
begin
if(nStatus = DICOM_SUCCESS)then
begin
strBuffer:= 'The file ''' + bstrFileName + ''' has been added successfully.' + Chr(13) + Char(13) + 'Continue?';
nResult:= Application.MessageBox(PChar(strBuffer), 'DICOM Directory Sample', MB_YESNO);
if(nResult = mrNo)then
begin
pReturnVal:= DICOM_ERROR_END; // Abort
Exit;
end;
end;
end;
end;