Hi together,

creating a new struct in OnDrop(), I cannot delete this object later on
without getting my Application to crash down. I don't know why!?

In my code _drag_drop_data_from_in_list is a struct with simple self
built data-members like Int, CStrings.
In my code it is also not possible to delete the pointer after ending
the Drag&Drop action, it will also crash down!
Later on I pass the code snippet of my OnDrop()code!

Thanks in Advance

Daniel


HGLOBAL hmem = pDataObject->GetGlobalData( nCF_VISIT_FROM_LISTCTRL );

_drag_drop_data_from_in_list bfVisitStruct;

CMemFile sf(( BYTE* ) ::GlobalLock( hmem ), ::GlobalSize( hmem ));
sf.Read( &bfVisitStruct, sizeof( bfVisitStruct ) );
::GlobalUnlock( hmem );
::GlobalFree( hmem );

_drag_drop_data_from_in_list* pVisitStruct = new
_drag_drop_data_from_in_list;

pVisitStruct->idNr = bfVisitStruct.idNr;
pVisitStruct->ndAVDatum = bfVisitStruct.ndAVDatum;
pVisitStruct->ndGeburtsdatum = bfVisitStruct.ndGeburtsdatum;
pVisitStruct->ndVerlegungsdatum = bfVisitStruct.ndVerlegungsdatum;
pVisitStruct->nIndex = bfVisitStruct.nIndex;
pVisitStruct->nstrName = bfVisitStruct.nstrName;
pVisitStruct->nstrPreward = bfVisitStruct.nstrPreward;
pVisitStruct->nstrVerlegungPlanStatus =
bfVisitStruct.nstrVerlegungPlanStatus;
pVisitStruct->nstrVorname = bfVisitStruct.nstrVorname;

if( dynamic_cast (pWnd)->GetVisitsDataItem() ==
NULL )
{
if( TransferVisitFromListCtrl( pVisitStruct->idNr,
pVisitStruct->nIndex, dynamic_cast (pWnd) ) )
{
COccDispLibId idVisit = bfVisitStruct.idNr;
COccDispLibId idBed = dynamic_cast
(pWnd)->GetBedId();
m_pDocument->TransferVisitInDocDelayed( idVisit, idBed );

SAFE_DEL(pVisitStruct); // if I delete her, it will crash down !
return TRUE;
}
else
{
SAFE_DEL(pVisitStruct); // if I delete her, it will crash down !
return FALSE;
}
}
SAFE_DEL(pVisitStruct); // if I delete her, it will crash down !
}